ES1.3 Windows Registry as an Attack Surface
Figure ES1.3 — The eight most commonly abused registry persistence locations. Each location has a corresponding MITRE ATT&CK technique ID and detection mechanism. Sysmon Event IDs 12 (RegistryEvent Object created/deleted) and 13 (RegistryEvent Value set) are the primary detection sources for registry-based persistence.
Why the registry is the persistence surface of choice
The registry is attractive for persistence because it is ubiquitous (every Windows system has it), it survives reboots (registry hives are stored on disk), it is complex (thousands of keys and values, making manual inspection impractical), and most registry modifications are legitimate (software installation, configuration changes, Windows updates all write to the registry constantly). The attacker’s modification hides in the noise of legitimate registry activity.
The critical distinction for detection: WHICH keys are modified matters more than THAT a modification occurred. A write to HKCU\Software\Microsoft\Windows\CurrentVersion\Run is a persistence attempt until proven otherwise — this key causes a program to execute every time the user logs in. A write to HKCU\Software\SomeApplication\Settings\WindowSize is a legitimate application saving its configuration. The detection strategy focuses on specific high-value keys, not all registry modifications.
Run and RunOnce keys are the simplest and most common persistence mechanism. The attacker adds a value to HKCU\Software\Microsoft\Windows\CurrentVersion\Run (executes at user logon) or HKLM\Software\Microsoft\Windows\CurrentVersion\Run (executes at system boot for all users). The value contains the path to the malicious executable or a command line (powershell.exe -enc …). Detection: Sysmon Event ID 13 captures the value set with the full path and data. MDE DeviceRegistryEvents captures the same. The detection query filters on the specific Run key paths and evaluates the value data — encoded PowerShell, paths to unusual locations (%TEMP%, %APPDATA%), or paths containing obfuscated filenames are strong indicators.
Services provide SYSTEM-level persistence. The attacker creates a service (or modifies an existing one) by writing to HKLM\SYSTEM\CurrentControlSet\Services\{ServiceName}. The ImagePath value contains the executable path. The Start value determines when the service starts (2 = automatic at boot, 3 = manual, 4 = disabled). A new service with Start=2 and an ImagePath pointing to an unusual location is a strong persistence indicator. Detection: Windows Event ID 7045 (new service installed) and Sysmon Event ID 12/13 for the registry modification.
What MDE and Sysmon capture for registry detection
MDE’s DeviceRegistryEvents table captures registry modifications with: the timestamp, the device name, the registry key path, the registry value name, the value data, the action type (RegistryValueSet, RegistryKeyCreated), and the process that made the modification (InitiatingProcessFileName). This provides the “who changed what” context that raw event logs do not.
Sysmon provides more granular registry monitoring through three event types: Event ID 12 (RegistryEvent — Object create or delete), Event ID 13 (RegistryEvent — Value Set), and Event ID 14 (RegistryEvent — Key and Value Rename). Sysmon configurations (like the SwiftOnSecurity baseline) filter these events to capture only modifications to security-relevant keys — reducing the volume from millions of events per day to thousands of actionable events.
The detection strategy: monitor a defined list of persistence-relevant registry keys for modifications by unexpected processes. A modification to a Run key by explorer.exe (user adding a startup program through the UI) is normal. A modification to a Run key by powershell.exe (script adding a startup entry) warrants investigation. A modification to a Run key by mshta.exe (HTA application adding persistence) is almost certainly malicious.
Your Sysmon configuration captures all registry modifications to the Run keys, Services keys, and COM registration keys. The daily event volume is 15,000 events. Most are legitimate software installations and Windows updates. Do you (A) build a detection rule that alerts on every modification to these keys, or (B) build a detection rule that filters to modifications by specific suspicious parent processes? Option B. An unfiltered alert on 15,000 daily events creates immediate alert fatigue and the rule will be ignored or disabled within a week. The effective detection filters on: the modifying process (PowerShell, cmd, mshta, wscript, cscript, rundll32), the value data pattern (encoded commands, paths to temp directories, obfuscated filenames), and the timing (modifications outside business hours, modifications immediately following a process creation from a suspicious parent chain). The goal is 5-15 actionable alerts per day, not 15,000.
Try it: enumerate persistence locations on your endpoint
Run this PowerShell to check the most common persistence locations:
| |
Any unexpected entries in Run keys, services with paths outside of system directories, or IFEO Debugger entries warrant investigation. On a clean system, Run keys contain only legitimate startup applications, all services point to system32 or known application directories, and IFEO has no Debugger entries.
Registry persistence: what investigators look for
The registry is the most common persistence mechanism on Windows endpoints because it requires no file drops, no service installation, and no scheduled task creation — just a single registry value that causes code to execute at logon or system startup. The four registry locations that investigators check first during triage:
HKCU and HKLM Run keys (SOFTWARE\Microsoft\Windows\CurrentVersion\Run and RunOnce): values in these keys execute automatically when the user logs in (HKCU) or when any user logs in (HKLM). An attacker who writes a value pointing to their payload ensures execution survives a reboot. MDE captures this through DeviceRegistryEvents, and the custom detection NE-PERS-001 from ES8.6 alerts on run key modifications by unexpected processes.
Services (HKLM\SYSTEM\CurrentControlSet\Services): each Windows service has a registry key with an ImagePath value pointing to the service binary. An attacker who creates a new service (or modifies an existing service’s ImagePath) gains execution as SYSTEM at every boot. Sysmon Event ID 13 captures service-related registry modifications with the process context that DeviceRegistryEvents may not include.
COM object hijacking (HKCU\Software\Classes\CLSID): COM objects are loaded by applications that call CoCreateInstance with a specific CLSID. If an attacker creates a CLSID entry in HKCU that points to their malicious DLL, the DLL is loaded whenever any application creates that COM object. This persistence method is particularly stealthy because HKCU COM entries override HKLM entries — the attacker hijacks an existing COM object without modifying any system-wide configuration.
Image File Execution Options (HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options): IFEO entries can specify a debugger for any executable. An attacker who sets the Debugger value for a commonly used application (e.g., notepad.exe) causes their payload to execute every time that application launches. This is a less common persistence method but difficult to detect without specific registry monitoring.
The myth: The registry is modified millions of times per day on an active endpoint. Monitoring it is impractical because the volume drowns out the malicious modifications.
The reality: Monitoring ALL registry modifications is impractical and unnecessary. Monitoring SPECIFIC high-value keys — Run keys, Services, COM registrations, IFEO, LSA authentication packages, WMI subscriptions — is both practical and high-value. The SwiftOnSecurity Sysmon configuration monitors approximately 50 specific registry paths that cover 95% of registry-based persistence techniques. On a typical endpoint, this generates 50-200 events per day — a manageable volume that can be filtered further by process context. The “too noisy” objection applies to unfiltered registry monitoring. Targeted monitoring of persistence-relevant keys is one of the highest-fidelity detection sources available.
Troubleshooting
“Our Sysmon configuration is generating thousands of registry events for Windows Update.” Windows Update modifies many registry keys during the update process. The SwiftOnSecurity Sysmon baseline includes exclusions for known Windows Update processes (wuauclt.exe, TiWorker.exe, TrustedInstaller.exe). If these exclusions are not in your Sysmon config, add them. The goal is to exclude known-good high-volume processes while retaining visibility on all other processes that modify persistence-relevant keys.
“MDE’s DeviceRegistryEvents table shows modifications but does not include the value data for some events.” MDE selectively captures registry value data based on the key’s security relevance and the data size. For high-value keys (Run, Services), value data is typically included. For some keys, only the key path and action type are recorded. If you need guaranteed value data capture, Sysmon Event ID 13 captures the full value data for all configured keys. Use both sources: MDE for broad coverage and Sysmon for detailed forensic evidence.
You're reading the free modules of this course
The full course continues with advanced topics, production detection rules, worked investigation scenarios, and deployable artifacts. Premium subscribers get access to all courses.