Registry Persistence via AppInit DLL

AppInit DLLs are dynamic-link libraries (DLLs) that are loaded into every process that creates a user interface (loads user32.dll) on Microsoft Windows operating systems. The AppInit DLL mechanism is used to load custom code into user-mode processes, allowing for the customization of the user interface and the behavior of Windows-based applications. Attackers who add those DLLs to the registry locations can execute code with elevated privileges, similar to process injection, and provide a solid and constant persistence on the machine.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2020/11/18"
  3integration = ["endpoint", "windows", "m365_defender", "sentinel_one_cloud_funnel", "crowdstrike"]
  4maturity = "production"
  5updated_date = "2026/09/18"
  6[transform]
  7[[transform.osquery]]
  8label = "Osquery - Retrieve AppInit Registry Value"
  9query = """
 10SELECT * FROM registry r where (r.key == 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Windows'
 11or r.key == 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows NT\\CurrentVersion\\Windows') and r.name ==
 12'AppInit_DLLs'
 13"""
 14
 15[[transform.osquery]]
 16label = "Osquery - Retrieve DNS Cache"
 17query = "SELECT * FROM dns_cache"
 18
 19[[transform.osquery]]
 20label = "Osquery - Retrieve All Services"
 21query = "SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services"
 22
 23[[transform.osquery]]
 24label = "Osquery - Retrieve Services Running on User Accounts"
 25query = """
 26SELECT description, display_name, name, path, pid, service_type, start_type, status, user_account FROM services WHERE
 27NOT (user_account LIKE '%LocalSystem' OR user_account LIKE '%LocalService' OR user_account LIKE '%NetworkService' OR
 28user_account == null)
 29"""
 30
 31[[transform.osquery]]
 32label = "Osquery - Retrieve Service Unsigned Executables with Virustotal Link"
 33query = """
 34SELECT concat('https://www.virustotal.com/gui/file/', sha1) AS VtLink, name, description, start_type, status, pid,
 35services.path FROM services JOIN authenticode ON services.path = authenticode.path OR services.module_path =
 36authenticode.path JOIN hash ON services.path = hash.path WHERE authenticode.result != 'trusted'
 37"""
 38
 39
 40[rule]
 41author = ["Elastic"]
 42description = """
 43AppInit DLLs are dynamic-link libraries (DLLs) that are loaded into every process that creates a user interface (loads
 44user32.dll) on Microsoft Windows operating systems. The AppInit DLL mechanism is used to load custom code into user-mode
 45processes, allowing for the customization of the user interface and the behavior of Windows-based applications.
 46Attackers who add those DLLs to the registry locations can execute code with elevated privileges, similar to process
 47injection, and provide a solid and constant persistence on the machine.
 48"""
 49from = "now-9m"
 50index = [
 51    "winlogbeat-*",
 52    "logs-endpoint.events.registry-*",
 53    "logs-windows.sysmon_operational-*",
 54    "endgame-*",
 55    "logs-m365_defender.event-*",
 56    "logs-sentinel_one_cloud_funnel.*",
 57    "logs-crowdstrike.fdr*",
 58]
 59language = "eql"
 60license = "Elastic License v2"
 61name = "Registry Persistence via AppInit DLL"
 62note = """## Triage and analysis
 63
 64### Investigating Registry Persistence via AppInit DLL
 65
 66AppInit DLLs are dynamic-link libraries (DLLs) that are loaded into every process that creates a user interface (loads `user32.dll`) on Microsoft Windows operating systems. The AppInit DLL mechanism is used to load custom code into user-mode processes, allowing for the customization of the user interface and the behavior of Windows-based applications.
 67
 68Attackers who add those DLLs to the registry locations can execute code with elevated privileges, similar to process injection, and provide a solid and constant persistence on the machine.
 69
 70This rule identifies modifications on the AppInit registry keys.
 71
 72> **Note**:
 73> This investigation guide uses the [Osquery Markdown Plugin](https://www.elastic.co/guide/en/security/current/invest-guide-run-osquery.html) introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.
 74
 75#### Possible investigation steps
 76
 77- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
 78- Review the source process and related DLL file tied to the Windows Registry entry.
 79  - Check whether the DLL is signed, and tied to a authorized program used on your environment.
 80- Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts.
 81- Retrieve all DLLs under the AppInit registry keys:
 82  - $osquery_0
 83- Examine the host for derived artifacts that indicate suspicious activities:
 84  - Analyze the process executable and the DLLs using a private sandboxed analysis system.
 85  - Observe and collect information about the following activities in both the sandbox and the alert subject host:
 86    - Attempts to contact external domains and addresses.
 87      - Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process' `process.entity_id`.
 88      - Examine the DNS cache for suspicious or anomalous entries.
 89        - $osquery_1
 90    - Use the Elastic Defend registry events to examine registry keys accessed, modified, or created by the related processes in the process tree.
 91    - Examine the host services for suspicious or anomalous entries.
 92      - $osquery_2
 93      - $osquery_3
 94      - $osquery_4
 95  - Retrieve the files' SHA-256 hash values using the PowerShell `Get-FileHash` cmdlet and search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.
 96
 97### False positive analysis
 98
 99- This activity is unlikely to happen legitimately. Benign true positives (B-TPs) can be added as exceptions if necessary.
100
101### Response and remediation
102
103- Initiate the incident response process based on the outcome of the triage.
104- Isolate the involved host to prevent further post-compromise behavior.
105- If the triage identified malware, search the environment for additional compromised hosts.
106  - Implement temporary network rules, procedures, and segmentation to contain the malware.
107  - Stop suspicious processes.
108  - Immediately block the identified indicators of compromise (IoCs).
109  - Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
110- Remove and block malicious artifacts identified during triage.
111- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
112- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
113- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
114"""
115
116setup = """## Setup
117
118This rule is designed for data generated by [Elastic Defend](https://www.elastic.co/security/endpoint-security), which provides native endpoint detection and response, along with event enrichments designed to work with our detection rules.
119
120Setup instructions: https://ela.st/install-elastic-defend
121
122### Additional data sources
123
124This rule also supports the following third-party data sources. For setup instructions, refer to the links below:
125
126- [CrowdStrike](https://ela.st/crowdstrike-integration)
127- [Microsoft Defender XDR](https://ela.st/m365-defender)
128- [SentinelOne Cloud Funnel](https://ela.st/sentinel-one-cloud-funnel)
129- [Sysmon Registry Events](https://ela.st/sysmon-event-reg-setup)
130"""
131
132risk_score = 47
133rule_id = "d0e159cf-73e9-40d1-a9ed-077e3158a855"
134severity = "medium"
135tags = [
136    "Domain: Endpoint",
137    "OS: Windows",
138    "Use Case: Threat Detection",
139    "Tactic: Persistence",
140    "Tactic: Defense Evasion",
141    "Resources: Investigation Guide",
142    "Data Source: Elastic Endgame",
143    "Data Source: Elastic Defend",
144    "Data Source: Sysmon",
145    "Data Source: Microsoft Defender XDR",
146    "Data Source: SentinelOne",
147    "Data Source: Crowdstrike",
148    "Noise: Medium",
149    "Performance: Normal",
150    "Rule Type: Event Correlation (EQL)",
151    "Platform: Windows",
152    "Resources: Osquery",
153]
154timestamp_override = "event.ingested"
155type = "eql"
156
157query = '''
158registry where host.os.type == "windows" and event.type == "change" and
159  registry.value : "AppInit_Dlls" and
160  not process.executable : (
161     "?:\\Windows\\System32\\DriverStore\\FileRepository\\*\\Display.NvContainer\\NVDisplay.Container.exe",
162     "?:\\Windows\\System32\\msiexec.exe",
163     "?:\\Windows\\SysWOW64\\msiexec.exe",
164     "?:\\Program Files\\Commvault\\Base\\cvd.exe",
165     "?:\\Program Files\\Commvault\\ContentStore*\\Base\\cvd.exe",
166     "?:\\Program Files (x86)\\Commvault\\Base\\cvd.exe",
167     "?:\\Program Files (x86)\\Commvault\\ContentStore*\\Base\\cvd.exe",
168     "?:\\Program Files\\NVIDIA Corporation\\Display.NvContainer\\NVDisplay.Container.exe",
169
170     /* Crowdstrike specific condition as it uses NT Object paths */
171     "\\Device\\HarddiskVolume*\\Windows\\System32\\DriverStore\\FileRepository\\*\\Display.NvContainer\\NVDisplay.Container.exe",
172     "\\Device\\HarddiskVolume*\\Windows\\System32\\msiexec.exe",
173     "\\Device\\HarddiskVolume*\\Windows\\SysWOW64\\msiexec.exe",
174     "\\Device\\HarddiskVolume*\\Program Files\\Commvault\\Base\\cvd.exe",
175     "\\Device\\HarddiskVolume*\\Program Files\\Commvault\\ContentStore*\\Base\\cvd.exe",
176     "\\Device\\HarddiskVolume*\\Program Files (x86)\\Commvault\\Base\\cvd.exe",
177     "\\Device\\HarddiskVolume*\\Program Files (x86)\\Commvault\\ContentStore*\\Base\\cvd.exe",
178     "\\Device\\HarddiskVolume*\\Program Files\\NVIDIA Corporation\\Display.NvContainer\\NVDisplay.Container.exe"
179  )
180  /*
181    Full registry key path omitted due to data source variations:
182    "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\AppInit_Dlls"
183    "HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows NT\\CurrentVersion\\Windows\\AppInit_Dlls"
184  */
185'''
186
187
188[[rule.threat]]
189framework = "MITRE ATT&CK"
190[[rule.threat.technique]]
191id = "T1546"
192name = "Event Triggered Execution"
193reference = "https://attack.mitre.org/techniques/T1546/"
194[[rule.threat.technique.subtechnique]]
195id = "T1546.010"
196name = "AppInit DLLs"
197reference = "https://attack.mitre.org/techniques/T1546/010/"
198
199
200
201[rule.threat.tactic]
202id = "TA0003"
203name = "Persistence"
204reference = "https://attack.mitre.org/tactics/TA0003/"
205[[rule.threat]]
206framework = "MITRE ATT&CK"
207[[rule.threat.technique]]
208id = "T1112"
209name = "Modify Registry"
210reference = "https://attack.mitre.org/techniques/T1112/"
211
212
213[rule.threat.tactic]
214id = "TA0005"
215name = "Defense Evasion"
216reference = "https://attack.mitre.org/tactics/TA0005/"

Triage and analysis

Investigating Registry Persistence via AppInit DLL

AppInit DLLs are dynamic-link libraries (DLLs) that are loaded into every process that creates a user interface (loads user32.dll) on Microsoft Windows operating systems. The AppInit DLL mechanism is used to load custom code into user-mode processes, allowing for the customization of the user interface and the behavior of Windows-based applications.

Attackers who add those DLLs to the registry locations can execute code with elevated privileges, similar to process injection, and provide a solid and constant persistence on the machine.

This rule identifies modifications on the AppInit registry keys.

Note: This investigation guide uses the Osquery Markdown Plugin introduced in Elastic Stack version 8.5.0. Older Elastic Stack versions will display unrendered Markdown in this guide.

Possible investigation steps

  • Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
  • Review the source process and related DLL file tied to the Windows Registry entry.
    • Check whether the DLL is signed, and tied to a authorized program used on your environment.
  • Assess whether this behavior is prevalent in the environment by looking for similar occurrences across hosts.
  • Retrieve all DLLs under the AppInit registry keys:
    • $osquery_0
  • Examine the host for derived artifacts that indicate suspicious activities:
    • Analyze the process executable and the DLLs using a private sandboxed analysis system.
    • Observe and collect information about the following activities in both the sandbox and the alert subject host:
      • Attempts to contact external domains and addresses.
        • Use the Elastic Defend network events to determine domains and addresses contacted by the subject process by filtering by the process' process.entity_id.
        • Examine the DNS cache for suspicious or anomalous entries.
          • $osquery_1
      • Use the Elastic Defend registry events to examine registry keys accessed, modified, or created by the related processes in the process tree.
      • Examine the host services for suspicious or anomalous entries.
        • $osquery_2
        • $osquery_3
        • $osquery_4
    • Retrieve the files' SHA-256 hash values using the PowerShell Get-FileHash cmdlet and search for the existence and reputation of the hashes in resources like VirusTotal, Hybrid-Analysis, CISCO Talos, Any.run, etc.

False positive analysis

  • This activity is unlikely to happen legitimately. Benign true positives (B-TPs) can be added as exceptions if necessary.

Response and remediation

  • Initiate the incident response process based on the outcome of the triage.
  • Isolate the involved host to prevent further post-compromise behavior.
  • If the triage identified malware, search the environment for additional compromised hosts.
    • Implement temporary network rules, procedures, and segmentation to contain the malware.
    • Stop suspicious processes.
    • Immediately block the identified indicators of compromise (IoCs).
    • Inspect the affected systems for additional malware backdoors like reverse shells, reverse proxies, or droppers that attackers could use to reinfect the system.
  • Remove and block malicious artifacts identified during triage.
  • Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
  • Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
  • Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).

Related rules

to-top