Check out the results from our first round of ATT&CK Evaluations at attackevals.mitre.org!

DLL Search Order Hijacking

Windows systems use a common method to look for required DLLs to load into a program. [1] Adversaries may take advantage of the Windows DLL search order and programs that ambiguously specify DLLs to gain privilege escalation and persistence.

Adversaries may perform DLL preloading, also called binary planting attacks, [2] by placing a malicious DLL with the same name as an ambiguously specified DLL in a location that Windows searches before the legitimate DLL. Often this location is the current working directory of the program. Remote DLL preloading attacks occur when a program sets its current directory to a remote location such as a Web share before loading a DLL. [3] Adversaries may use this behavior to cause the program to load a malicious DLL.

Adversaries may also directly modify the way a program loads DLLs by replacing an existing DLL or modifying a .manifest or .local redirection file, directory, or junction to cause the program to load a different DLL to maintain persistence or privilege escalation. [4] [5] [6]

If a search order-vulnerable program is configured to run at a higher privilege level, then the adversary-controlled DLL that is loaded will also be executed at the higher level. In this case, the technique could be used for privilege escalation from user to administrator or SYSTEM or from administrator to SYSTEM, depending on the program.

Programs that fall victim to path hijacking may appear to behave normally because malicious DLLs may be configured to also load the legitimate DLLs they were meant to replace.

ID: T1038

Tactic: Persistence, Privilege Escalation, Defense Evasion

Platform:  Windows

Permissions Required:  User, Administrator, SYSTEM

Effective Permissions:  User, Administrator, SYSTEM

Data Sources:  File monitoring, DLL monitoring, Process monitoring, Process command-line parameters

Defense Bypassed:  Process whitelisting

CAPEC ID:  CAPEC-471

Contributors:  Stefan Kanthak, Travis Smith, Tripwire

Version: 1.0

Examples

NameDescription
Downdelph

Downdelph uses search order hijacking of the Windows executable sysprep.exe to escalate privileges.[7]

FinFisher

A FinFisher variant uses DLL search order hijacking.[8][9]

HTTPBrowser

HTTPBrowser abuses the Windows DLL load order by using a legitimate Symantec anti-virus binary, VPDN_LU.exe, to load a malicious DLL that mimics a legitimate Symantec DLL, navlu.dll.[10]

InvisiMole

InvisiMole can be launched by using DLL search order hijacking in which the wrapper DLL is placed in the same folder as explorer.exe and loaded during startup into the Windows Explorer process instead of the legitimate library.[11]

menuPass

menuPass has used DLL search order hijacking.[12]

MirageFox

MirageFox is likely loaded via DLL hijacking into a legitimate McAfee binary.[13]

PowerSploit

PowerSploit contains a collection of Privesc-PowerUp modules that can discover and exploit DLL hijacking opportunities in services and processes.[14][15]

Prikormka

Prikormka uses DLL search order hijacking for persistence by saving itself as ntshrui.dll to the Windows directory so it will load before the legitimate ntshrui.dll saved in the System32 subdirectory.[16]

RedLeaves

RedLeaves is launched through use of DLL search order hijacking to load a malicious dll.[17]

Threat Group-3390

Threat Group-3390 has performed DLL search order hijacking to execute their payload.[18]

WEBC2

Variants of WEBC2 achieve persistence by using DLL search order hijacking, usually by copying the DLL file to %SYSTEMROOT% (C:\WINDOWS\ntshrui.dll).[19]

Mitigation

Disallow loading of remote DLLs. [20] This is included by default in Windows Server 2012+ and is available by patch for XP+ and Server 2003+. [1] Path Algorithm

Enable Safe DLL Search Mode to force search for system DLLs in directories with greater restrictions (e.g. %SYSTEMROOT%)to be used before local directory DLLs (e.g. a user's home directory). The Safe DLL Search Mode can be enabled via Group Policy at Computer Configuration > [Policies] > Administrative Templates > MSS (Legacy): MSS: (SafeDllSearchMode) Enable Safe DLL search mode. The associated Windows Registry key for this is located at HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\SafeDLLSearchMode [1]

Use auditing tools capable of detecting DLL search order hijacking opportunities on systems within an enterprise and correct them. Toolkits like the PowerSploit framework contain PowerUp modules that can be used to explore systems for DLL hijacking weaknesses. [21]

Identify and block potentially malicious software that may be executed through search order hijacking by using whitelisting [22] tools like AppLocker [23] [24] that are capable of auditing and/or blocking unknown DLLs.

Detection

Monitor file systems for moving, renaming, replacing, or modifying DLLs. Changes in the set of DLLs that are loaded by a process (compared with past behavior) that do not correlate with known software, patches, etc., are suspicious. Monitor DLLs loaded into a process and detect DLLs that have the same file name but abnormal paths. Modifications to or creation of .manifest and .local redirection files that do not correlate with software updates are suspicious.

References