SHIM me what you got: Manipulating Shim and Office for Code Injection
This talk demonstrates a novel fileless and registry-less code injection technique by manipulating the Windows Application Compatibility (Shim) framework. By reverse-engineering the undocumented NtApphelpCacheControl API and leveraging opportunistic locks (OpLocks), the researchers force a legitimate process to load a malicious DLL. This technique achieves privilege escalation to NT AUTHORITY\SYSTEM and effectively bypasses EDR monitoring by performing the injection in an early process initialization stage.
Bypassing EDR with Fileless DLL Injection via the Windows Shim Framework
TLDR: Researchers at DEF CON 2024 demonstrated a novel technique to achieve code injection and privilege escalation by abusing the Windows Application Compatibility (Shim) framework. By reverse-engineering the undocumented
NtApphelpCacheControlAPI and using opportunistic locks (OpLocks), they force legitimate processes to load malicious DLLs without writing to the registry or disk. This method effectively bypasses EDR monitoring by executing during the early stages of process initialization.
Modern endpoint detection and response (EDR) solutions are heavily optimized to catch common injection patterns like CreateRemoteThread or suspicious WriteProcessMemory calls. However, these tools often rely on the assumption that malicious activity occurs after a process is fully initialized. By targeting the Windows Application Compatibility framework—a legacy mechanism designed to ensure older software runs on newer OS versions—researchers have found a way to execute code before most security hooks are even active.
The Mechanics of the Shim Abuse
The Windows Shim framework uses Shim Database (SDB) files to store compatibility fixes. These files tell the OS how to handle specific applications that might otherwise fail on modern Windows versions. While Microsoft maintains the primary sysmain.sdb file, the system also allows for custom SDB files. Historically, attackers have registered custom SDB files to achieve persistence or execute code, but this approach is noisy and easily detected by monitoring registry keys like HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Custom.
The research presented at DEF CON shifts the focus from registering new SDBs to manipulating the way the system processes existing ones. The core of this technique involves the undocumented NtApphelpCacheControl API. This API manages the cache of compatibility information, and by reverse-engineering it, the researchers discovered they could influence how the system applies fixes to specific processes.
Achieving Fileless Injection
To perform the injection, the researchers targeted the OfficeClickToRun service, which runs as NT AUTHORITY\SYSTEM. The goal was to force this service to load a malicious DLL into a child process. The attack flow is elegant in its simplicity:
- Preparation: The attacker writes a malicious DLL to a non-suspicious location.
- Locking: Using Opportunistic Locks (OpLocks), the attacker locks
sysmain.sdb. This forces the system to wait when it attempts to read the database. - Triggering: The attacker triggers a scheduled task that relies on compatibility fixes. Because the database is locked, the service pauses, waiting for the file to become available.
- Injection: While the service is paused, the attacker uses the
NtApphelpCacheControlAPI to manipulate the process environment block (PEB) of the suspended child process, pointing it toward the malicious DLL. - Execution: The lock is released, the service resumes, and the child process loads the malicious DLL instead of the intended one.
This approach is particularly effective because the injection happens during the early stages of process creation. By the time the process is fully initialized and the EDR has hooked the necessary APIs, the malicious code is already running within the context of a trusted, system-level service.
Practical Implications for Pentesters
For those conducting red team engagements, this technique offers a significant advantage: it avoids the most common indicators of compromise (IoCs) associated with process injection. Since the injection is performed by a legitimate system service, the process tree often looks benign.
To reproduce this, you need to identify a target process that is susceptible to shim fixes. You can use SDB Explorer to inspect the contents of sysmain.sdb and identify which applications have associated fixes. During an engagement, look for processes that frequently interact with the shim cache. The researchers released their proof-of-concept tool, ShimMe, which automates the process of identifying targets and performing the injection.
Defensive Considerations
Defending against this class of attack is difficult because it abuses legitimate OS functionality. Standard signature-based detection will fail here. Instead, blue teams should focus on behavioral monitoring. Specifically, monitor for:
- Unexpected calls to
NtApphelpCacheControlfrom non-system processes. - The use of OpLocks on critical system files like
sysmain.sdb. - Processes spawning child processes with unusual command-line arguments or loading DLLs from non-standard paths.
The OWASP A03:2021 – Injection category is highly relevant here, as the attack relies on injecting malicious intent into a legitimate system process. While this specific technique targets the Shim framework, the underlying principle—abusing early-stage process initialization—is a broader area that warrants further investigation.
This research highlights a critical reality: as EDRs become better at monitoring the "front door" of process execution, attackers are moving further back into the initialization sequence. If you are testing the resilience of your environment, start by auditing which processes are allowed to interact with the shim cache and ensure that your monitoring stack is capable of capturing events that occur before the main entry point of a process. The rabbit hole goes deep, and the Shim framework is just one of many legacy components waiting to be re-examined.
Vulnerability Classes
Target Technologies
Attack Techniques
OWASP Categories
All Tags
Up Next From This Conference

Breaking Secure Web Gateways for Fun and Profit

Listen to the Whispers: Web Timing Attacks That Actually Work

Abusing Windows Hello Without a Severed Hand
Similar Talks

Hacking Apple's USB-C Port Controller

Unmasking the Snitch Puck: The Creepy IoT Surveillance Tech in the School Bathroom

