Detection of Malicious Shim Database (.sdb) File Creation
Attackers can use Application Compatibility Database (.sdb) files to intercept API calls, allowing for privilege escalation and persistence by bypassing Windows security controls.
Windows Application Compatibility shims are a legitimate mechanism used to ensure older applications run correctly on newer versions of the operating system by intercepting and redirecting API calls. However, this functionality is frequently abused by attackers to gain persistence or elevate privileges. By creating a custom shim database (.sdb) and installing it via the sdbinst.exe utility, an attacker can force the operating system to load malicious code into processes or bypass security checks. This detection focuses on monitoring filesystem writes to the %SystemRoot%\AppPatch\Custom directory, which is the standard location for user-defined shim databases. While legitimate administrative activity can occur here, unexpected file creation in this directory is a high-fidelity signal for security operations teams to investigate potential unauthorized persistence mechanisms.
Attack Chain
- Attacker gains local administrative access to the target Windows system.
- Attacker crafts a malicious Shim Database (.sdb) file containing redefined API hooks.
- Attacker uses
sdbinst.exeto register the malicious .sdb file within the system. - The malicious shim database is written to the
%SystemRoot%\AppPatch\Customdirectory. - The OS loads the shim database during process execution or system boot, depending on the scope of the shim.
- API calls made by targeted applications or processes are redirected to the attacker-supplied malicious code.
- Attacker achieves persistence or privilege escalation through the executed code.
Impact
Successful abuse of the shim mechanism can lead to persistent code execution and privilege escalation, as the malicious code is loaded by legitimate processes. This allows attackers to hide activities, bypass security software, and maintain long-term access to compromised environments.
Recommendation
- Enable Sysmon Event ID 11 (FileCreate) to capture filesystem modifications.
- Deploy the provided Sigma rule to detect file writes in the specified AppPatch directory.
- Investigate any file creations in
C:\Windows\AppPatch\Custom\that lack a clear association with authorized software installation or maintenance. - Monitor for executions of
sdbinst.exeassociated with the creation of new .sdb files.
Immediate actions
Deploy Sigma rule to monitor for .sdb file creation in AppPatch\Custom
Threat Hunt
Search for existing .sdb files in C:\Windows\AppPatch\Custom\ that have been modified recently
Data: Filesystem telemetry
Mitigations
Review and audit all installed shim databases using sdbinst.exe /query
T1546.011
Detection coverage 1
Detect Shim Database (.sdb) File Creation
mediumDetects the creation of shim database files (.sdb) in the Windows AppPatch Custom directory, which may indicate the installation of malicious shim databases.
Detection queries are available on the platform. Get full rules →