Registry as Attack Surface
Every persistence autorun location, how each works mechanically, the detection event it triggers, and the Sigma rules that catch it.
An incident responder runs Autoruns on a compromised endpoint and finds five suspicious entries — but only if they knew where to look. An attacker who knows registry persistence locations better than the defender can hide in plain sight: a value in a rarely-checked key, a COM object hijack under HKCU, an IFEO debugger entry. This chapter is the complete map. After reading it, you should be able to name at least 10 autorun locations from memory — because interviewers will ask exactly that.
Run Keys — The Classic
The most common persistence mechanism. Values under these keys are executed at user logon or system startup.
| Registry Path | Who Runs It | Timing | HKLM requires admin? |
|---|---|---|---|
| HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run | All users at logon | Logon | Yes |
| HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce | All users — runs once then deleted | Logon | Yes |
| HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run | Current user only | Logon | No — user level |
| HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce | Current user — once then deleted | Logon | No |
| HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run | 32-bit processes on 64-bit Windows | Logon | Yes |
Detection: Sysmon Event 13 (RegistryValueSet) with TargetObject containing \CurrentVersion\Run. Filter out known software installers. Autoruns.exe from Sysinternals highlights unsigned or unknown-hash entries in green/red/yellow.
Winlogon Keys
Winlogon handles the logon sequence. Its registry entries control what programs run as part of logon initialization — any modification is high-value persistence.
| Value | Default | Abuse Method |
|---|---|---|
| HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit | C:\Windows\system32\userinit.exe, | Append malware path after the comma: userinit.exe, malware.exe |
| HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell | explorer.exe | Replace with or append malware.exe (runs instead of Explorer) |
| HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Notify | (subkeys for notification DLLs) | Add subkey pointing to malicious DLL (older technique) |
Services Registry Keys
Every Windows service is defined under HKLM\SYSTEM\CurrentControlSet\Services\<ServiceName>. Key values:
| Value | Description | Malware Use |
|---|---|---|
| ImagePath (REG_EXPAND_SZ) | Path to service binary or %SystemRoot%\svchost.exe -k groupname | Point to malicious .exe or inject via svchost (ServiceDll) |
| ServiceDll (under Parameters\) | For svchost services: actual DLL containing service logic | Malicious DLL in system32 or temp, loads inside svchost.exe |
| Start (REG_DWORD) | 0=Boot, 1=System, 2=Automatic, 3=Manual, 4=Disabled | Set to 2 for autostart |
| Type (REG_DWORD) | 1=Kernel, 2=FileSys, 16=Win32Own, 32=Win32Share | Usually 16 for standalone malware service |
Detection: Event 7045 (System channel, new service installed) and Event 4697 (Security channel). Alert on ServiceFileName pointing to unusual paths (not System32, not Program Files).
AppInit_DLLs
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\AppInit_DLLs — DLLs listed here are loaded into every process that loads User32.dll (essentially every GUI process). Disabled by default when Secure Boot is enabled.
AppInit_DLLs is a blunt instrument — it injects your DLL into hundreds of processes. Legitimate software rarely uses it. Any non-empty value is suspicious on a modern system with Secure Boot. The value is LoadAppInit_DLLs = 1 alongside the DLL path. Detection: Sysmon Event 13 on this key path.
Image File Execution Options (IFEO)
IFEO, at HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\<binary.exe>, was designed for attaching a debugger to a process at launch. Attackers abuse the Debugger value to hijack program execution.
IFEO Debugger Abuse
══════════════════════════════════════════════════════════════════
Registry entry:
HKLM\...\Image File Execution Options\sethc.exe
Debugger = "C:\Windows\System32\cmd.exe"
What happens:
User presses Shift 5 times → Windows tries to launch sethc.exe
│
▼
Windows checks IFEO for sethc.exe
Finds Debugger = cmd.exe
│
▼
Executes: cmd.exe sethc.exe
→ cmd.exe opens as SYSTEM
(running before logon, at lock screen)
Real-world abuse:
- sethc.exe → Sticky Keys (triggered at lock screen with Shift×5)
- osk.exe → On-Screen Keyboard
- utilman.exe → Ease of Access (Win+U at lock screen)
- narrator.exe → Narrator
All run as SYSTEM before authentication — perfect backdoor
SilentProcessExit
A variation under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SilentProcessExit\<binary.exe> — triggers a monitor process when the named binary exits. Abuse: set a malicious monitor that relaunches on process exit.
COM Hijacking via HKCU
Windows resolves COM objects first from HKCU\Software\Classes\CLSID, then HKLM\Software\Classes\CLSID. A user (no admin required) can create a HKCU entry that shadows a system COM object.
COM Object Hijacking — Registry Precedence
══════════════════════════════════════════════════════════════════
Application calls CoCreateInstance(CLSID_TaskScheduler, ...)
│
▼
Windows looks up CLSID in registry:
┌─────────────────────────────────────────────────────┐
│ 1st: HKCU\Software\Classes\CLSID\{CLSID} │ ← ATTACKER PLANTS HERE
│ InProcServer32 = C:\Users\victim\AppData\ │
│ Roaming\malware.dll │
└─────────────────────────────────────────────────────┘
│ (if not found ↓)
┌─────────────────────────────────────────────────────┐
│ 2nd: HKLM\Software\Classes\CLSID\{CLSID} │
│ InProcServer32 = C:\Windows\System32\ │
│ taskschd.dll (legitimate) │
└─────────────────────────────────────────────────────┘
Result: malware.dll loaded instead of taskschd.dll
Persistence trigger: any application that uses the COM object
Admin required: NO — HKCU is user-writable
Detection: Sysmon Event 12/13 for HKCU\Software\Classes\CLSID key creation, especially with InProcServer32 pointing to non-system paths. Sysmon Event 7 (ImageLoad) showing a DLL from %APPDATA% or %TEMP% loaded by a legitimate process.
BootExecute
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\BootExecute — programs listed here run during early boot before the Session Manager fully initializes. Default: autocheck autochk *. Any additional entries run with highest possible privilege and before most security software starts.
LSA Authentication Packages and Security Packages
Two registry keys tell the LSA (Local Security Authority) which DLLs to load as authentication providers:
| Key | Value | Default | Abuse |
|---|---|---|---|
| HKLM\SYSTEM\CurrentControlSet\Control\Lsa | Authentication Packages (REG_MULTI_SZ) | msv1_0 | Add malicious DLL; loaded by lsass.exe at boot with SYSTEM rights |
| HKLM\SYSTEM\CurrentControlSet\Control\Lsa | Security Packages (REG_MULTI_SZ) | kerberos, msapsspc, schannel… | Add malicious SSP DLL; loaded by lsass.exe, sees all credentials |
| HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders | SecurityProviders (REG_SZ) | credssp.dll | Append malicious DLL path (space-separated) |
LSA package persistence requires a reboot to activate (lsass.exe loads them at boot). Detection note: Sysmon Event 13 on these key paths, plus Event 7 showing unexpected DLLs loaded by lsass.exe after reboot. The Mimikatz misc::memssp technique installs an in-memory SSP without touching the registry — completely bypasses this detection angle.
Complete Autorun Locations Table
| Location | Trigger | Admin? | Detection Event |
|---|---|---|---|
| HKLM\...\Run | System startup / all user logon | Yes | Sysmon 13, Event 4657 |
| HKCU\...\Run | User logon | No | Sysmon 13 |
| Winlogon\Userinit | User logon | Yes | Sysmon 13 |
| Winlogon\Shell | User logon | Yes | Sysmon 13 |
| Services\ImagePath | Service start (boot/auto) | Yes | Event 7045, 4697, Sysmon 13 |
| Services\Parameters\ServiceDll | svchost service start | Yes | Event 7045, Sysmon 13, Event 7 |
| AppInit_DLLs | Every User32 load | Yes | Sysmon 13, Event 7 |
| IFEO\<binary>\Debugger | Specified binary launch | Yes | Sysmon 13, Event 4688 |
| SilentProcessExit\<binary> | Specified binary exit | Yes | Sysmon 13 |
| HKCU\Software\Classes\CLSID\<CLSID>\InProcServer32 | COM object instantiation | No | Sysmon 12/13, Sysmon 7 |
| BootExecute | Early boot (before logon) | Yes | Sysmon 13 (offline parse) |
| Lsa\Authentication Packages | lsass.exe boot load | Yes | Sysmon 13, Event 7 in lsass |
| Lsa\Security Packages | lsass.exe boot load | Yes | Sysmon 13, Event 7 in lsass |
| Scheduled Tasks (TaskCache) | Configured trigger | Varies | Event 4698, 4702, Sysmon 13 |
| Startup folder (per-user and all-users) | User logon | Varies | Sysmon 11 (file creation), Event 4688 |
| HKCU\Environment\UserInitMprLogonScript | User logon (logon script) | No | Sysmon 13 |
| COM\InprocServer32 (HKLM) | COM instantiation | Yes | Sysmon 13, Event 7 |
| KnownDLLs | DLL load from HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\KnownDLLs | Yes | Sysmon 13, 7 |
The Autoruns Tool
Sysinternals Autoruns (free from Microsoft) checks all autorun locations and color-codes entries:
- Green — known good (Microsoft or widely-recognized publisher)
- White — unknown publisher but found on disk
- Yellow/Orange — file not found (entry exists but binary is missing — suspicious)
- Red — suspicious or unknown (signed but not by known publisher, or unsigned)
Command-line: autorunsc.exe -a * -c -h -s * > autoruns.csv — scan all categories, CSV output, include hash, scan all users. Great for baseline comparison: diff baseline.csv current.csv.
Run Autoruns on a clean VM, export to CSV (File → Save). Then install a suspicious program or add a test Run key. Run again, compare. This is the workflow for detecting persistence changes between snapshots — critical for incident response when you have a pre-compromise baseline.
Q & A
Q: Name 5 Windows registry persistence locations from memory.
Interviewer-expected answer (any 5): (1) HKCU\Software\Microsoft\Windows\CurrentVersion\Run — user-level, no admin needed; (2) HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run — system-wide, needs admin; (3) HKLM\SYSTEM\CurrentControlSet\Services — service-based persistence; (4) HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\<binary>\Debugger — IFEO hijack; (5) HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Userinit — Winlogon persistence; (6) HKCU\Software\Classes\CLSID\{CLSID}\InProcServer32 — COM hijack, no admin; (7) HKLM\SYSTEM\CurrentControlSet\Control\Lsa\Authentication Packages — LSA auth package persistence; (8) HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\BootExecute — pre-boot execution.
Q: An attacker wants to persist without admin privileges. Which registry locations are available to them?
User-writable locations (HKCU only): (1) HKCU\...\Run and RunOnce — classic; (2) HKCU\Software\Classes\CLSID — COM hijacking, no admin, highly effective; (3) HKCU\Environment\UserInitMprLogonScript — runs at logon; (4) HKCU startup folder: %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup — not registry but user-writable; (5) Scheduled tasks as current user — ITaskService allows creating tasks that run as current user. Notably missing from this list: services (require admin), HKLM Run (requires admin), AppInit_DLLs (requires admin and Secure Boot must be off). COM hijacking (option 2) is particularly dangerous because it triggers on legitimate application use and requires zero admin.
Q: How would you write a Sigma rule to detect Run key persistence?
Target Sysmon Event 13 (RegistryValueSet). TargetObject should match *\SOFTWARE\Microsoft\Windows\CurrentVersion\Run*. Exclude known-good: filter by image (trusted software installers) or by known-good value names (antivirus, update agents). Example Sigma: detection: selection: EventID: 13, TargetObject|contains: '\CurrentVersion\Run' filter_legit: Image|startswith: 'C:\Program Files\'. condition: selection and not filter_legit. Add a second filter layer based on the Details field — known-good paths like C:\Windows\system32, C:\Program Files, %SystemRoot% reduce false positives. Alert on Details pointing to %TEMP%, %APPDATA%, or %PUBLIC%.