20/05/2025
What is DLL Hijacking?
DLL Hijacking is a technique used by attackers to exploit how Windows applications load Dynamic Link Library (DLL) files. When a program runs, it often loads additional code from DLL files. If it doesn’t specify a full path, Windows searches for the DLL in a set order—starting with the application directory.
This order can be abused: if an attacker places a malicious DLL with the same name as a required one in the right location, the application may load the malicious version. This gives the attacker control of the process and, often, the whole system.
How DLL Hijacking Works
Here's a simplified breakdown:
Application searches for a DLL – It expects a legitimate system or custom DLL.
No path specified – The app relies on Windows to find the DLL.
Windows searches in specific directories – Starting with the app’s folder.
Attacker places a malicious DLL – Using the same name as the expected DLL.
Malicious code is loaded – The app unknowingly executes the attacker's code.
This vulnerability has existed for years and remains a common attack vector.
Real-World Case: U.S. Federal Agencies Breach
In 2020, one of the most significant cyberattacks in U.S. history came to light—an attack that breached:
The Department of Homeland Security
The Department of State
The U.S. Treasury
Other federal and private organizations
The breach was linked to a supply chain attack on SolarWinds, an IT management company. The attackers inserted malicious code into an update of SolarWinds' Orion software, which was downloaded by around 18,000 organizations.
While the primary breach method was a software supply chain attack, DLL hijacking was one of the key techniques used during post-exploitation to escalate privileges, maintain persistence, and move laterally across networks.
The attackers, likely linked to Russian intelligence (APT29/Cozy Bear), used advanced tactics—but the simplicity of DLL hijacking was part of their toolkit.
Why DLL Hijacking is Still Effective
Low detection rates – Antivirus tools may not flag a DLL in a trusted folder.
No code injection required – The system loads the malicious DLL like any other.
Can bypass UAC (User Account Control) – If exploited correctly.
Common in trusted apps – Many legitimate applications still don’t fully specify DLL paths.
How to Defend Against DLL Hijacking
Use absolute paths – Applications should load DLLs using full paths.
Enable Safe DLL Search Mode – Ensures Windows checks system directories before others.
Digitally sign and validate DLLs – Helps ensure authenticity.
Restrict write permissions – Limit attacker access to application directories.
Monitor DLL loading behavior – Use tools like Sysinternals Process Monitor to detect unusual activity.
Patch and audit software regularly – Vulnerable apps must be updated or hardened.