DLL hijacking occurs when an application loads a dynamic library from a location an attacker can control. If a privileged process searches a writable directory first, the attacker can replace or plant a library that the process loads and executes with elevated rights.
Expanded Definition
DLL hijacking is a path-based loading flaw, not a flaw in the DLL itself. The application’s search order, deployment layout, and privilege context determine whether an attacker can place a library where it will be loaded first. In Windows environments, this becomes especially dangerous when a service, scheduled task, or desktop application runs with elevated rights and resolves a DLL from a writable directory before a trusted system location. That makes the issue relevant to NHI security because agentic services, automation runners, and integration hosts often depend on libraries loaded at startup or during plugin discovery.
Definitions vary across vendors on whether a case should be called DLL hijacking, side-loading, or search-order hijacking, but the security outcome is the same: untrusted code execution through library resolution. Microsoft guidance on Dynamic-Link Library Security and control mapping in NIST SP 800-53 Rev 5 Security and Privacy Controls both emphasize reducing unsafe loading paths and enforcing integrity for executable content. The most common misapplication is assuming the application is safe because the DLL file is signed, which occurs when the loader still searches a writable directory before a trusted path.
Examples and Use Cases
Implementing protection against DLL hijacking rigorously often introduces deployment and compatibility constraints, requiring organisations to weigh safe loading behavior against legacy application convenience.
- A privileged Windows service loads a missing dependency from its working directory, allowing a lower-privileged attacker to plant a malicious DLL and gain code execution.
- An agentic automation host loads optional plugins from a writable folder, creating an execution path that bypasses expected trust boundaries and undermines Ultimate Guide to NHIs guidance on limiting NHI exposure.
- A signed desktop app relies on relative search paths, so a local attacker places a lookalike library near the executable and triggers execution when the process starts.
- A CI/CD runner launches helper binaries with inherited privileges and loads shared libraries from build directories, making library resolution part of the pipeline attack surface.
- Security teams verify path hardening and library-loading behavior against NIST SP 800-53 Rev 5 Security and Privacy Controls and operational patterns documented in Ultimate Guide to NHIs.
Why It Matters in NHI Security
DLL hijacking matters because it turns ordinary software maintenance into a privilege escalation opportunity. Once an attacker can influence what a service loads, they may inherit the service’s access to secrets, APIs, infrastructure tooling, or signing operations. That is especially risky in NHI-heavy environments where service accounts and automation identities already hold broad permissions. NHI Mgmt Group notes that Ultimate Guide to NHIs reports 97% of NHIs carry excessive privileges, which means a successful DLL load compromise can become a high-impact lateral movement path rather than a single-host issue.
Mitigation usually requires strict library search ordering, restricted write permissions, application allowlisting, and deployment reviews for services that execute with elevated rights. The operational lesson is that trust must extend to every file lookup, not just the signed binary. This is also why NIST guidance on executable integrity and access control remains relevant alongside NHI governance. Organisations typically encounter credential theft, tampered automation, or unexplained service behavior only after a privileged process has already loaded the wrong library, at which point DLL hijacking becomes operationally unavoidable to address.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10 and OWASP Agentic AI Top 10 address the attack and risk surface, while NIST CSF 2.0, NIST SP 800-63 and NIST Zero Trust (SP 800-207) set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-02 | Addresses unsafe secret and execution paths that let attackers hijack NHI-bearing processes. |
| NIST CSF 2.0 | PR.AC-4 | Least-privilege access limits the blast radius when a hijacked process executes attacker code. |
| NIST SP 800-63 | Credential assurance is undermined when a hijacked process can impersonate trusted automation. | |
| NIST Zero Trust (SP 800-207) | SC-7 | Zero Trust requires validating execution context, not assuming trusted local paths. |
| OWASP Agentic AI Top 10 | A2 | Agentic systems inherit risk when tools or runtime libraries can be hijacked. |
Treat NHI process integrity as part of identity assurance and monitor for unauthorized execution changes.
Related resources from NHI Mgmt Group
Deepen Your Knowledge
Reviewed and updated by the NHIMG editorial team on August 2, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org