vendredi 6 août 2010
How Microsoft fixed the LNK vulnerability... and other things
Par Sylvain SARMEJEANNE, vendredi 6 août 2010 à 19:48 :: General
Microsoft released the awaited patch fixing the LNK vulnerability on Monday. Let's have a look at how Microsoft fixed it, by performing a differential analysis on the shell32.dll library for Windows XP SP3.
Several new functions have been added to the fixed version of the DLL; knowing that the vulnerability is related to the way shortcuts to control panel (CPL) elements are handled, the new CControlPanelFolder:: _IsRegisteredCPLApplet() function immediately focuses our attention. The CControlPanelFolder:GetUIObjectOf() function has been altered to add a new block calling this function:

At the bottom of the screenshot, there is a call to _ControlExtractIcon_CreateInstance(), which will initiate the extraction of the icon. This call will therefore be performed only if the return code of _IsRegisteredCPLApplet() is not null.
Looking at _IsRegisteredCPLApplet(), we see that after having fetched the registered control panel elements with CPLD_GetModules(), the function iterates with DSA_GetItemPtr() until a match is found by CompareString() with the DLL pointed by the shortcut (return value of 2, namely CSTR_EQUAL, in which case _IsRegisteredCPLApplet() returns 1), or if there is no more element to compare with (in which case _IsRegisteredCPLApplet() returns 0):

If we create a CPL shortcut pointing to C:\Windows\system32\zuaucpl.dll (instead of the legitimate wuaucpl.dll), we observe that Windows does compare the name of our DLL with the registered control panel elements:

Windows will therefore only load a CPL to retrieve its icon if it was registered in a legitimate way.
This update also adds support for the HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\IsAutorunForCDROMOnly registry value (without creating it by default), enabling to disable AutoRun on any media except CDs and DVDs. This is the default behavior on Windows 7 and Microsoft released the KB971029 for the previous Windows versions.
In fact, there is a call to a new _IsAutorunForCDROMOnly() function at the top of the CMountPoint::_ProcessAutoRunFile() and CContentTypeData::Init() functions:

At the bottom of CContentTypeData::Init(), a new test has been added to decide whether AddRemovableOrFixedDiskAutorunINFHandler() should be called, depending on the return value of _IsAutorunForCDROMOnly() (in CMountPoint::_ProcessAutoRunFile(), there are multiple places where this is checked):

The _IsAutorunForCDROMOnly() simply retrieves the registry value:

More surprising, this update also adds several functions (InitializeFormatDlg(), BeginFormat() and FileSysChange()) which add a new "exFAT" item to the disk format dialog:

But only the dialog has been modified; the exFAT driver is not installed and formating the disk will therefore not be possible... exFAT support requires a distinct update, KB955704, which install several other files, not only shell32.dll.
Besides the security fix, this new version of shell32.dll also comes with two functional updates (support for the complete AutoRun disabling except for CDs and DVDs, as well as a partial support for exFAT disk format), which is, to our knowledge, not documented anywhere (except in shell32.dll updates in previously released KBs).