[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[CVE-2016-0014] Executable installers are vulnerable^WEVIL (case 1): Microsoft's IExpress resp. WExtract, SFXCab, BoxStub, ...



Hi @ll,

IExpress (<https://msdn.microsoft.com/en-us/library/dd346760.aspx>)
creates executable installers [°] or self-extracting archives for
Windows by embedding a .CAB archive and some strings as resources
into a copy of the program %SystemRoot%\System32\WExtract.exe.

These self-extracting archives/executable installers, especially
those made by Microsoft ['] (available in the Microsoft download
center or distributed per Windows Update), are vulnerable:

1. If built with WExtract.exe of a system supporting the NTFS
   "encrypting file system", i.e. Windows NT5.x, Windows NT6.x or
   Windows 10, and run under these versions of Windows, they load
   and execute a rogue/bogus/malicious FEClient.dll [²] eventually
   found in the directory they are started from (the "application
   directory").

   For software downloaded with a web browser this is typically the
   "Downloads" directory: see
   <https://insights.sei.cmu.edu/cert/2008/09/carpet-bombing-and-directory-poisoning.html>,
   <http://blog.acrossecurity.com/2012/02/downloads-folder-binary-planting.html>
   and <http://seclists.org/fulldisclosure/2012/Aug/134>

   If FEClient.dll gets planted in the "Downloads" directory per
   "drive-by download" this vulnerability becomes a remote code
   execution.

   Due to an application manifest embedded in the executable which
   specifies "requireAdministrator" or the "installer detection" (see
   <https://technet.microsoft.com/en-us/library/dd835540.aspx#BKMK_InstDet>)
   of Windows' "user account control" executable installers are
   typically started with administrative privileges ("protected"
   administrators are prompted for consent, unprivileged standard
   users are prompted for an administrator password); execution of
   FEClient.dll then results in an escalation of privilege!

2. They call CreateProcess() with command line(s) set during package
   creation.
   These command lines have to be specified with unqualified (simple)
   filenames since the absolute pathnames on the target system are
   unknown. Due to CreateProcess() process search order they will run
   rogue executables with the specified simple filename(s) eventually
   found in the directory they are started from.

   See <http://seclists.org/fulldisclosure/2013/Oct/5>.

   DON'T USE <https://msdn.microsoft.com/en-us/library/ff553615.aspx>
   (especially step 8. which uses simple filenames in the command
   line)!

   DON'T USE <https://msdn.microsoft.com/en-us/library/dd293575.aspx>
   (especially step 3.h. which uses simple filenames in the command
   line)!

3. They extract their payload to an unsafe temporary (sub)directory
   "%TEMP%\IXP<3_digits>.TMP\" and process or execute it from there [³].

   The files comprising the payload can be overwritten or compromised
   by an unprivileged user after extraction and before their later use.

4. Executable (un)installers distributed per software deployment system
   (for example WSUS) or wrapped into a .MSI for deployment per group
   policies are (typically) run under "LocalSystem" account.

   From <https://technet.microsoft.com/en-us/library/dn265983.aspx>:

   | The list of trusted root certificates is available as a self-
   | extracting IEXPRESS package in the Microsoft Download Center, the
   | Windows catalog, or by using Windows Server Update Services (WSUS).
   ...
   | The list of untrusted certificates comes as a self-extracting
   | IEXPRESS package in a mandatory security Windows Update.

   Processes running under "LocalSystem" account use the global
   %TEMP% directory %SystemRoot%\Temp where (unprivileged) users
   can create (or overwrite) files and conduct all these attacks.

   For a recent example of such a vulnerability see
   <https://code.google.com/p/google-security-research/issues/detail?id=440>


Proof of concept/demonstration:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1. visit <http://home.arcor.de/skanthak/sentinel.html>, download
   <http://home.arcor.de/skanthak/download/SENTINEL.DLL> and save
   it as FEClient.dll in your "Downloads" directory;

2. download the AntiMalware Definition Updater MPAM-D.EXE or
   MPAM-FE[X64].EXE (see <https://support.microsoft.com/en-us/kb/935934>,
   <https://technet.microsoft.com/en-us/library/gg398041.aspx> and
   <http://www.microsoft.com/security/portal/definitions/adl.aspx>)
   and save it in your "Downloads" directory;

3. execute MPAM-*.EXE from your "Downloads" directory;

4. notice the message box displayed from FEClient.dll placed in step 1.


Instead of MPAM-*.EXE you can use ALMOST ANY other executable installer
available from the Microsoft Download Center or via Windows Update!

Just to pick (pun intended.-) a few:

* Windows-KB890830-v*.exe, the malicious software removal tool,
  <http://www.microsoft.com/en-us/download/malicious-software-removal-tool-details.aspx?id=16>
  or
  <http://www.microsoft.com/en-us/download/malicious-software-removal-tool-details.aspx?id=9905>

* ROOTSUPD-KB931125-*.exe, the root certificate updater, see
  <https://support.microsoft.com/kb/931125>

* RVKROOTS.EXE, the root certificate revocation list updater,
  available from the SECURITY (sic!) advisories
  <https://support.microsoft.com/en-us/kb/2728973>
  <https://support.microsoft.com/en-us/kb/2798897>
  <https://support.microsoft.com/en-us/kb/2917500>
  <https://support.microsoft.com/en-us/kb/2982792>
  <httpa://support.microsoft.com/en-us/kb/3046310>
  <https://support.microsoft.com/en-us/kb/3050995>
  or the Microsoft Update Catalog
  <https://catalog.update.microsoft.com/v7/site/ScopedViewInline.aspx?updateid=416de864-839a-4a61-907f-d18cabcc6dda>

* ALL installers of the .NET Framework:
  NDP46-KB3045557-x86-x64-AllOS-ENU.exe,
  NDP46-KB3045557-x86-x64-AllOS-DEU.exe,
  NDP46-KB3045557-x86-x64-AllOS-*.exe,
  dotNetFx40_Full_x86_x64.exe,
  dotNetFx40_Client_x86_x64.exe,
  NDP40-KB2656405-x86.exe,
  NDP40-KB2656405-x64.exe,
  ...,
  NDP*.exe,
  DotNETFX.Exe,
  LangPack.Exe

* Windows Defender Offline, see
  <http://windows.microsoft.com/en-US/windows/what-is-windows-defender-offline>

* ALL Visual C++ Runtime 20xy Redistributable Packages

* ALL hotfixes and updates for Windows 2000, Windows XP, Windows
  Embedded POSReady 2009, Windows Server 2003 (Windows*-KB*-*.exe)

and THOUSANDS more!



Cause:
~~~~~~

About 16 years ago Microsoft introduced the NTFS "encrypting file
system".

<https://technet.microsoft.com/en-us/library/cc781588.aspx>:

| When a user modifies EFS options for a file or folder, or when an
| application attempts to access an encrypted file on an NTFS volume,
| the Win32 application programming interface (API) passes the
| resulting EFS-related calls to the Feclient DLL. Feclient then
| calls the EFS remote procedure call (RPC) interfaces in the LSA.

FEClient.dll is loaded on demand by AdvAPI32.dll (one of the Win32
core components) without its well-known fully qualified pathname,
resulting in the vulnerability now fixed with MS16-007 alias KB3121918.


Mitigation(s):
~~~~~~~~~~~~~~

0. DON'T USE EXECUTABLE INSTALLERS [°]!

   If your favourite applications are not distributed in the native
   installer package format of the resp. target platform: ask^WURGE
   their vendors/developers to provide native installation packages.
   If they don't: dump these applications, stay away from such cruft!

1. Turn off UAC's privilege elevation for standard users and installer
   detection for all users:

   [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
   "ConsentPromptBehaviorUser"=dword:00000000 ; Automatically deny elevation requests
   "EnableInstallerDetection"=dword:00000000

   See <https://technet.microsoft.com/en-us/library/dd835564.aspx#BKMK_RegistryKeys>

2. NEVER execute files in UNSAFE directories (like "Downloads" and
   and "%TEMP%")!

3. Deny execution (at least) in the "Downloads" directories and all
   "%TEMP%" directories and their subdirectories:

   * Add the NTFS ACE "(D;OIIO;WP;;;WD)" meaning "deny execution of
     files in this directory for everyone, inheritable to all files
     in all subdirectories" (use CACLS.EXE /S:<SDDL> for example);

   * Use "software restriction policies" resp. AppLocker.

   Consider to apply either/both to every "%USERPROFILE%" as well as
   "%ALLUSERSPROFILE%" alias %ProgramData%" and "%PUBLIC%": Windows
   doesn't place executables in these directories and beyond.

   See <http://home.arcor.de/skanthak/safer.html> as well as
   <http://mechbgon.com/srp/> plus
   <http://csrc.nist.gov/itsec/SP800-68r1.pdf>,
   <https://www.nsa.gov/ia/_files/os/win2k/application_whitelisting_using_srp.pdf>
   or <https://books.google.de/books?isbn=1437914926> and finally
   <http://www.asd.gov.au/infosec/top35mitigationstrategies.htm>!


stay tuned
Stefan Kanthak


PS: for "case 0" see <http://seclists.org/fulldisclosure/2015/Sep/21>,
    for "case 0.5" see <http://seclists.org/fulldisclosure/2013/Oct/5>;
    the case numbers are not in chronological order.

PPS: see <http://seclists.org/fulldisclosure/2015/Nov/101> (resp. the
     not yet finished <http://home.arcor.de/skanthak/!execute.html>)
     for more details!


[°] Self-extracting archives and executable installers are flawed^W
    b(rainde)ad in concept and dangerous in practice.

    DON'T USE SUCH CRUFT!
    ALWAYS use the resp. target platforms native package and archive
    format.

    For Windows these are .INF (plus .CAB) and .MSI (plus .CAB),
    introduced 20 years ago (with Windows 95 and Windows NT4) resp.
    16 years ago (with Office 2000).

    Both .INF and .MSI are "opened" by programs residing in
    %SystemRoot%\System32\ which are therefore immune to this kind
    of "DLL and EXE Search Order Hijacking" attack.
    Since both .INF and .MSI access the contents of .CAB directly
    they eliminate the attack vector "unsafe temporary directory"
    too.

['] Current IExpress installers created by Microsoft have an
    application manifest that specifies "requireAdministrator".
    For example:

    * ROOTSUPD-KB931125-*.exe, the root certificate updater, see
      <https://support.microsoft.com/kb/931125>

    * RVKROOTS.EXE, the root certificate revocation list updater,
      available from the security (SIC!) advisories
      <https://support.microsoft.com/en-us/kb/2728973>,
      <https://support.microsoft.com/en-us/kb/2798897>,
      <https://support.microsoft.com/en-us/kb/2917500>,
      <https://support.microsoft.com/en-us/kb/2982792>,
      <httpa://support.microsoft.com/en-us/kb/3046310>,
      <https://support.microsoft.com/en-us/kb/3050995>
      or the Microsoft Update Catalog
      <https://catalog.update.microsoft.com/v7/site/ScopedViewInline.aspx?updateid=416de864-839a-4a61-907f-d18cabcc6dda>

    Older IExpress installers created by Microsoft have NO
    application manifest and are therefore subject to UAC's
    installer detection.
    For example:

    * CAPICOM-KB931906-v2102.exe, a security (SIC!) update available
      from <https://support.microsoft.com/en-us/kb/931906>
      or <https://technet.microsoft.com/en-us/library/ms07-028.aspx>.

[²] A well-known (trivial, easy to avoid, easy to detect,
    easy to exploit and easy to fix) and well-documented
    vulnerability: see
    <https://cwe.mitre.org/data/definitions/426.html>,
    <https://cwe.mitre.org/data/definitions/427.html>,
    <https://capec.mitre.org/data/definitions/471.html>,
    <https://technet.microsoft.com/en-us/library/2269637.aspx>,
    <https://msdn.microsoft.com/en-us/library/ff919712.aspx> and
    <https://msdn.microsoft.com/en-us/library/ms682586.aspx>

[³] Another well-known (trivial, easy to avoid, easy to detect,
    easy to exploit and easy to fix) and well-documented
    vulnerability: see
    <https://cwe.mitre.org/data/definitions/377.html>,
    <https://cwe.mitre.org/data/definitions/379.html>,
    <https://capec.mitre.org/data/definitions/27.html>,
    <https://capec.mitre.org/data/definitions/29.html> ...