ID PACKETSTORM:134692 Type packetstorm Reporter Stefan Kanthak Modified 2015-12-08T00:00:00
Description
`Hi @ll,
the executable installers [°] of the videolan client (VLC, see
<http://www.videolan.org/>) are vulnerable:
1. They load and execute a rogue/bogus/malicious ShFolder.dll ['][²]
(and other DLLs like SetupAPI.dll or UXTheme.dll too) 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 ShFolder.dll (or any of the other DLLs) 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
ShFolder.dll et. al. then results in an escalation of privilege!
2. They extract embedded DLLs (System.dll, LangInfo.dll, UAC.dll, ...)
to an unsafe temporary (sub)directory "%TEMP%\ns<letter><random>.tmp\"
and load them from there [³].
These DLLs can be overwritten by an unprivileged user between their
creation and execution, resulting in an escalation of privilege.
3. Their uninstaller copies itself to "%TEMP%\~nsu.tmp\<letter>u_.exe"
and runs its copy from there, again loading
"%TEMP%\~nsu.tmp\ShFolder.dll" and other DLLs, which can be created
(in advance) or overwritten by an unprivileged user.
Since "%TEMP%\~nsu.tmp\<letter>u_.exe" is typically started with
administrative privileges this results in another escalation of
privilege.
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 ShFolder.dll in your "Downloads" directory, then copy it
as UXTheme.dll and SetupAPI.dll there too;
2. download
<http://get.videolan.org/vlc/2.2.1/win32/vlc-2.2.1-win32.exe>
(via <http://www.videolan.org/> and save it in your "Downloads"
directory;
3. execute vlc-2.2.1-win32.exe from your "Downloads" directory;
4. notice the message boxes displayed from ShFolder.dll etc. placed
in step 1.
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 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> and/or
<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: see <http://seclists.org/fulldisclosure/2015/Nov/101> (resp. the
not yet finished <http://home.arcor.de/skanthak/!execute.html>)
for more details!
PPS: the case numbers are not in chronological order.
[°] 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.
['] ShFolder.dll is cruft from the last millennium, it was used on
Windows 9x without Internet Explorer 4; see
<https://support.microsoft.com/en-us/kb/241733>
DONT USE the sample code shown in this MSKB article!
[²] A well-known (trivial, easy to exploit and easy to avoid) 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 exploit and easy to avoid)
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> ...
Timeline:
~~~~~~~~~
2015-12-06 vulnerability report sent to authors
2015-12-07 response from author:
"the issue is not in VLC, but in NSIS."
I really LOVE this sort of $%§*@ attitude:
"Once the rockets are up who cares where they come down,
'That's not my department', says Wernher von Braun"
2015-12-07 it's YOUR software, it's YOUR decision to use NSIS, it's
YOUR (IR)responsibility!
2015-12-07 report published
`
{"hash": "b21ac82424dc978852af04504ca9cf2b750351504d5f1f6ace23fef1ddea4951", "sourceHref": "https://packetstormsecurity.com/files/download/134692/videolan-dllhijack.txt", "title": "VLC DLL Hijack", "id": "PACKETSTORM:134692", "published": "2015-12-08T00:00:00", "description": "", "modified": "2015-12-08T00:00:00", "sourceData": "`Hi @ll, \n \nthe executable installers [\u00b0] of the videolan client (VLC, see \n<http://www.videolan.org/>) are vulnerable: \n \n1. They load and execute a rogue/bogus/malicious ShFolder.dll ['][\u00b2] \n(and other DLLs like SetupAPI.dll or UXTheme.dll too) eventually \nfound in the directory they are started from (the \"application \ndirectory\"). \n \nFor software downloaded with a web browser this is typically the \n\"Downloads\" directory: see \n<https://insights.sei.cmu.edu/cert/2008/09/carpet-bombing-and-directory-poisoning.html>, \n<http://blog.acrossecurity.com/2012/02/downloads-folder-binary-planting.html> \nand <http://seclists.org/fulldisclosure/2012/Aug/134> \n \nIf ShFolder.dll (or any of the other DLLs) gets planted in the \n\"Downloads\" directory per \"drive-by download\" this vulnerability \nbecomes a remote code execution. \n \nDue to an application manifest embedded in the executable which \nspecifies \"requireAdministrator\" or the \"installer detection\" (see \n<https://technet.microsoft.com/en-us/library/dd835540.aspx#BKMK_InstDet>) \nof Windows' \"user account control\" executable installers are \ntypically started with administrative privileges (\"protected\" \nadministrators are prompted for consent, unprivileged standard \nusers are prompted for an administrator password); execution of \nShFolder.dll et. al. then results in an escalation of privilege! \n \n2. They extract embedded DLLs (System.dll, LangInfo.dll, UAC.dll, ...) \nto an unsafe temporary (sub)directory \"%TEMP%\\ns<letter><random>.tmp\\\" \nand load them from there [\u00b3]. \n \nThese DLLs can be overwritten by an unprivileged user between their \ncreation and execution, resulting in an escalation of privilege. \n \n3. Their uninstaller copies itself to \"%TEMP%\\~nsu.tmp\\<letter>u_.exe\" \nand runs its copy from there, again loading \n\"%TEMP%\\~nsu.tmp\\ShFolder.dll\" and other DLLs, which can be created \n(in advance) or overwritten by an unprivileged user. \n \nSince \"%TEMP%\\~nsu.tmp\\<letter>u_.exe\" is typically started with \nadministrative privileges this results in another escalation of \nprivilege. \n \n \nProof of concept/demonstration: \n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \n \n1. visit <http://home.arcor.de/skanthak/sentinel.html>, download \n<http://home.arcor.de/skanthak/download/SENTINEL.DLL> and save \nit as ShFolder.dll in your \"Downloads\" directory, then copy it \nas UXTheme.dll and SetupAPI.dll there too; \n \n2. download \n<http://get.videolan.org/vlc/2.2.1/win32/vlc-2.2.1-win32.exe> \n(via <http://www.videolan.org/> and save it in your \"Downloads\" \ndirectory; \n \n3. execute vlc-2.2.1-win32.exe from your \"Downloads\" directory; \n \n4. notice the message boxes displayed from ShFolder.dll etc. placed \nin step 1. \n \n \nMitigation(s): \n~~~~~~~~~~~~~~ \n \n0. DON'T USE EXECUTABLE INSTALLERS [\u00b0]! \n \nIf your favourite applications are not distributed in the native \ninstaller package format of the resp. target platform: ask^WURGE \ntheir vendors/developers to provide native installation packages. \nIf they don't: dump these applications, stay away from such cruft! \n \n1. Turn off privilege elevation for standard users and installer \ndetection for all users: \n \n[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System] \n\"ConsentPromptBehaviorUser\"=dword:00000000 ; Automatically deny elevation requests \n\"EnableInstallerDetection\"=dword:00000000 \n \nSee <https://technet.microsoft.com/en-us/library/dd835564.aspx#BKMK_RegistryKeys> \n \n2. NEVER execute files in UNSAFE directories (like \"Downloads\" and \nand \"%TEMP%\")! \n \n3. Deny execution (at least) in the \"Downloads\" directories and all \n\"%TEMP%\" directories and their subdirectories: \n \n* Add the NTFS ACE \"(D;OIIO;WP;;;WD)\" meaning \"deny execution of \nfiles in this directory for everyone, inheritable to all files \nin all subdirectories\" (use CACLS.EXE /S:<SDDL> for example); \n \n* Use \"software restriction policies\" resp. AppLocker. \n \nConsider to apply either/both to every \"%USERPROFILE%\" as well as \n\"%ALLUSERSPROFILE%\" alias %ProgramData%\" and \"%PUBLIC%\": Windows \ndoesn't place executables in these directories and beyond. \n \nSee <http://home.arcor.de/skanthak/safer.html> and/or \n<http://mechbgon.com/srp/> plus \n<http://csrc.nist.gov/itsec/SP800-68r1.pdf>, \n<https://www.nsa.gov/ia/_files/os/win2k/application_whitelisting_using_srp.pdf> \nor <https://books.google.de/books?isbn=1437914926> and finally \n<http://www.asd.gov.au/infosec/top35mitigationstrategies.htm>! \n \n \nstay tuned \nStefan Kanthak \n \n \nPS: see <http://seclists.org/fulldisclosure/2015/Nov/101> (resp. the \nnot yet finished <http://home.arcor.de/skanthak/!execute.html>) \nfor more details! \n \nPPS: the case numbers are not in chronological order. \n \n \n[\u00b0] Self-extracting archives and executable installers are flawed^W \nb(rainde)ad in concept and dangerous in practice. \n \nDON'T USE SUCH CRUFT! \nALWAYS use the resp. target platforms native package and archive \nformat. \n \nFor Windows these are .INF (plus .CAB) and .MSI (plus .CAB), \nintroduced 20 years ago (with Windows 95 and Windows NT4) resp. \n16 years ago (with Office 2000). \n \nBoth .INF and .MSI are \"opened\" by programs residing in \n%SystemRoot%\\System32\\ which are therefore immune to this kind of \n\"DLL (and EXE) Search Order Hijacking\" attack. \nSince both .INF and .MSI access the contents of .CAB directly \nthey eliminate the attack vector \"unsafe temporary directory\" too. \n \n['] ShFolder.dll is cruft from the last millennium, it was used on \nWindows 9x without Internet Explorer 4; see \n<https://support.microsoft.com/en-us/kb/241733> \n \nDONT USE the sample code shown in this MSKB article! \n \n[\u00b2] A well-known (trivial, easy to exploit and easy to avoid) and \nwell-documented vulnerability: see \n<https://cwe.mitre.org/data/definitions/426.html>, \n<https://cwe.mitre.org/data/definitions/427.html>, \n<https://capec.mitre.org/data/definitions/471.html>, \n<https://technet.microsoft.com/en-us/library/2269637.aspx>, \n<https://msdn.microsoft.com/en-us/library/ff919712.aspx> and \n<https://msdn.microsoft.com/en-us/library/ms682586.aspx> \n \n[\u00b3] Another well-known (trivial, easy to exploit and easy to avoid) \nand well-documented vulnerability: see \n<https://cwe.mitre.org/data/definitions/377.html>, \n<https://cwe.mitre.org/data/definitions/379.html>, \n<https://capec.mitre.org/data/definitions/27.html>, \n<https://capec.mitre.org/data/definitions/29.html> ... \n \n \nTimeline: \n~~~~~~~~~ \n \n2015-12-06 vulnerability report sent to authors \n \n2015-12-07 response from author: \n\"the issue is not in VLC, but in NSIS.\" \n \nI really LOVE this sort of $%\u00a7*@ attitude: \n\"Once the rockets are up who cares where they come down, \n'That's not my department', says Wernher von Braun\" \n \n2015-12-07 it's YOUR software, it's YOUR decision to use NSIS, it's \nYOUR (IR)responsibility! \n \n2015-12-07 report published \n`\n", "reporter": "Stefan Kanthak", "hashmap": [{"key": "bulletinFamily", "hash": "708697c63f7eb369319c6523380bdf7a"}, {"key": "cvelist", "hash": "d41d8cd98f00b204e9800998ecf8427e"}, {"key": "cvss", "hash": "d4be9c4fc84262b4f39f89565918568f"}, {"key": "description", "hash": "d41d8cd98f00b204e9800998ecf8427e"}, {"key": "href", "hash": "ec8b6e5bfeac49e1ec93fdd0d6f6ff16"}, {"key": "modified", "hash": "4783d05d9c31996002206accb4d9274a"}, {"key": "objectVersion", "hash": "56765472680401499c79732468ba4340"}, {"key": "published", "hash": "4783d05d9c31996002206accb4d9274a"}, {"key": "references", "hash": "d41d8cd98f00b204e9800998ecf8427e"}, {"key": "reporter", "hash": "0b0500f12418f6b1bf549dc35a1819f1"}, {"key": "sourceData", "hash": "d72a4c07be0f04cad2e243209be4e80b"}, {"key": "sourceHref", "hash": "2fcfbdb74618cc7660ddec4615eb5c43"}, {"key": "title", "hash": "6d439076eb982dc93a9e3ea352e58e51"}, {"key": "type", "hash": "6466ca3735f647eeaed965d9e71bd35d"}], "cvss": {"vector": "NONE", "score": 0.0}, "references": [], "type": "packetstorm", "cvelist": [], "history": [], "bulletinFamily": "exploit", "objectVersion": "1.2", "edition": 1, "href": "https://packetstormsecurity.com/files/134692/VLC-DLL-Hijack.html", "lastseen": "2016-11-03T10:21:37", "viewCount": 0, "enchantments": {"vulnersScore": 7.2}}