Public Vulnerability Reports

Microsoft MSHTA Script Execution Vulnerability

04.12.05

BACKGROUND

Microsoft HTML Application Host (MSHTA) is part of the Microsoft Windows
operating system and is needed to execute .HTA files.

DESCRIPTION

Remote exploitation of a design error vulnerability in Microsoft Corp.'s
Windows operating system allows attackers to execute arbitrary script
code from a non-executable object.

Various files, such as a Microsoft Word documents will be opened by the
appropriate program even if they are renamed with an unknown extension.
The reason for this is that the CLSID of the Microsoft Word program is
stored within the OLE2 document. The CLSID of a given file can be
manipulated to specify that another program should handle the opening of
the file. The CLSID is located after the Unicode string "Root Entry" as
seen in the following excerpt:

b800h: 52 00 6F 00 6F 00 74 00 20 00 45 00 6E 00 74 00 R.o.o.t. .E.n.t.
b810h: 72 00 79 00 00 00 00 00 00 00 00 00 00 00 00 00 r.y.............
b820h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
b830h: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
b840h: 16 00 05 01 FF FF FF FF FF FF FF FF 03 00 00 00 ....ÿÿÿÿÿÿÿÿ....
b850h: 06 09 02 00 00 00 00 00 C0 00 00 00 00 00 00 46 ........À......F

In the above example, the CLSID {00020906-0000-0000-C000-000000000046},
can be found at the hex offset 0xb850 from above. An attacker can
execute arbitrary script code from a seemingly non-executable object by
appending script code to the end of a file and modifying the CLSID to be
that of the Microsoft HTML Application Host (MSHTA). The MSHTA CLSID can
be found in the Windows Registry. This attack works because MSHTA.EXE
will completely scan the file passed in as an argument in search of
script code. If found, the code will be executed.

While the given example is built on modifications to a Microsoft Word
document, it is important to note that this vulnerability is not Word
specific or dependant and in fact can not manifest in Word documents
containing a handled file extension.

ANALYSIS

Successful exploitation allows remote attackers to execute arbitrary
script code from a non-executable object. This vulnerability can be
leveraged by attackers when distributing malicious content as it will
appear harmless to most users. Exploitation requires that a target user
double-click on a malicious file that contains an unhandled extension.
An attacker may use an extension such as .d0c (numeric zero in place of
letter 'o') to mask the malicious file as a Word document.

Windows XP Service Pack 2 has added a new security feature to Internet
Explorer that prevents and/or warns the user when unsigned executable
content is selected for download. The described vulnerability also
allows an attacker to bypass this security protection.

DETECTION

iDEFENSE has confirmed the existence of this vulnerability in Microsoft
Windows 2000 and Microsoft Windows XP. It is suspected that all versions
of Microsoft Windows operating systems are vulnerable.

WORKAROUND

Removing the associated CLSID for MSHTA from system registry prevents
exploitation of the described vulnerability:

    HKEY_CLASSES_ROOTCLSID{3050f4d8-98B5-11CF-BB82-00AA00BDCE0B}

This key should be backed-up before removal. Please note that removing
this key may cause other problems. Preliminary testing shows that the
key is not necessary for regular system usage.

VENDOR RESPONSE

This vulnerability is addressed in Microsoft Security Bulletin MS05-016
available at:

http://www.microsoft.com/technet/security/Bulletin/MS05-016.mspx

CVE INFORMATION

The Common Vulnerabilities and Exposures (CVE) project has assigned the
name CAN-2005-0063 to this issue. This is a candidate for inclusion
in the CVE list (http://cve.mitre.org), which standardizes names for
security problems.

DISCLOSURE TIMELINE

11/02/2004   Initial vendor notification
11/02/2004   Initial vendor response
04/12/2005   Coordinated public disclosure

CREDIT

The discoverer of this vulnerability wishes to remain anonymous.

Get paid for vulnerability research
http://www.idefense.com/poi/teams/vcp.jsp

Free tools, research and upcoming events
http://labs.idefense.com

LEGAL NOTICES

Copyright © 2005 Verisign, Inc.

Permission is granted for the redistribution of this alert
electronically. It may not be edited in any way without the express
written consent of iDEFENSE. If you wish to reprint the whole or any
part of this alert in any other medium other than electronically, please
email customerservice@idefense.com for permission.

Disclaimer: The information in the advisory is believed to be accurate
at the time of publishing based on currently available information. Use
of the information constitutes acceptance for use in an AS IS condition.
There are no warranties with regard to this information. Neither the
author nor the publisher accepts any liability for any direct, indirect,
or consequential loss or damage arising from use of, or reliance on,
this information.