DLL Hijacking
What is DLL Hijacking?
DLL HijackingAn attack that abuses Windows DLL search order to make a legitimate program load an attacker-controlled library instead of the intended one.
DLL hijacking (MITRE ATT&CK T1574.001) exploits the way Windows resolves dynamic-link libraries: when an application requests a DLL by name without a fully qualified path, the loader walks a predictable list of directories. Under the default SafeDllSearchMode, that order is the application directory, then the system directories (System32, System16), then the Windows directory, then the current working directory, then each entry in %PATH%. An attacker who can write a malicious DLL into a higher-priority location than the legitimate one — the app folder, a writable PATH entry, or a WebDAV/SMB share the program opens — gets code executed inside a trusted, often code-signed process. The technique yields execution, privilege context, and persistence, and it slips past allowlists that trust the parent EXE.
The problem reached public attention with Microsoft Security Advisory 2269637 (August 2010), which labelled the class "insecure library loading" after researchers (notably Mitja Kolšek of ACROS Security) reported roughly 200 affected Windows applications that would load a planted DLL from a remote share — "binary planting." Microsoft's response, KB2533623, added the SetDefaultDllDirectories / LoadLibraryEx flags and the CWDIllegalInDllSearch registry control so developers could remove the current directory from the search path. The pattern is still a staple of real intrusions: attackers "sideload" a benign signed EXE (from vendors such as antivirus or productivity suites) alongside a rogue DLL — a favourite of groups like PlugX operators — to run under a reputable signature.
Defences: load with fully qualified paths, call SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32), apply WDAC/AppLocker rules, keep installers patched, and monitor image loads with Sysmon event ID 7 (unsigned or unusual module loads from writable directories).
flowchart TD
A["App calls LoadLibrary for foo.dll<br/>with no full path"] --> B{Search order<br/>SafeDllSearchMode}
B -->|1. App directory| C[Attacker-planted foo.dll here]
B -->|2. System32| D[Legitimate foo.dll]
B -->|3. Windows dir| D
B -->|4. CWD / WebDAV share| C
B -->|5. PATH entries| C
C -->|loaded first| E[Malicious code runs<br/>inside signed, trusted process]
E --> F[Execution + persistence<br/>bypasses app allowlist]● Examples
- 01
Dropping a malicious version.dll next to a signed installer that loads it from its own folder.
- 02
Planting a DLL in a writable PATH directory to be loaded by a system service.
● Frequently asked questions
What is DLL Hijacking?
An attack that abuses Windows DLL search order to make a legitimate program load an attacker-controlled library instead of the intended one. It belongs to the Attacks & Threats category of cybersecurity.
What does DLL Hijacking mean?
An attack that abuses Windows DLL search order to make a legitimate program load an attacker-controlled library instead of the intended one.
How do you defend against DLL Hijacking?
Defences for DLL Hijacking typically combine technical controls and operational practices, as detailed in the full definition above.
What are other names for DLL Hijacking?
Common alternative names include: DLL search-order hijacking, DLL preloading, Binary planting.