Malware Persistence (analysis)
Persistence is how malware survives reboots and logoffs to keep access. When analyzing a sample, identifying its persistence mechanism is key: it says where it “lives” in the system, provides high-fidelity IOCs, and is the first thing to clean in incident response. This page catalogs Windows mechanisms from the analysis, detection, and cleanup angle. (Linux persistence is covered in Linux persistence; AD in Active Directory persistence.)
Threat model
Section titled “Threat model”Persistence is a trade-off for the adversary: the more reliable and automatic, the more noise it leaves (a Run key is trivial to plant and trivial to find); the stealthier, the more privilege and complexity it demands (a WMI subscription or a bootkit). The defender exploits exactly that: almost every legitimate autostart mechanism is inventoried and enumerable, so a known-good baseline makes persistence one of the most detectable phases of the chain. The golden rule of response: if one mechanism goes undetected, the malware comes back.
flowchart TD U[No privileges / user] --> U1[HKCU Run / RunOnce] U --> U2[Startup folder] U --> U3[User scheduled task] U --> U4[COM hijacking HKCU] A[Privileged / admin-SYSTEM] --> A1[Service] A --> A2[HKLM Run / IFEO] A --> A3[WMI event subscription] A --> A4[LSA / Winlogon / AppInit] K[Kernel / boot] --> K1[Driver / rootkit] K --> K2[UEFI bootkit]
Mechanisms: what each touches and why it matters
Section titled “Mechanisms: what each touches and why it matters”Autostart keys (Run/RunOnce)
Section titled “Autostart keys (Run/RunOnce)”Values in HKCU\...\CurrentVersion\Run (user) or HKLM\...\Run (all). Read by explorer.exe/userinit at logon. The most common and noisiest mechanism: instantly visible in Autoruns. ATT&CK T1547.001. High-fidelity IOC: the exact (value name, command) pair, which usually reveals paths and LOLBins.
Startup folder
Section titled “Startup folder”A shortcut or script in the user’s or system’s startup folder. Equally visible; sometimes chained with a .lnk launching an interpreter.
Scheduled tasks
Section titled “Scheduled tasks”Task Scheduler entries created by schtasks, PowerShell (Register-ScheduledTask), or the COM API ITaskService. Heavily used because they allow flexible triggers (at boot, on connect, every N minutes) and blend in with legitimate tasks. ATT&CK T1053.005. Artifacts: XML in C:\Windows\System32\Tasks\ and the ...\TaskCache\Tree key.
Services
Section titled “Services”A service that starts with the system (CreateService, or an entry in HKLM\SYSTEM\CurrentControlSet\Services). Can point to an EXE or a DLL loaded by svchost. Requires admin/SYSTEM privileges. ATT&CK T1543.003. Clear signal: event 7045 (new service installed).
WMI event subscription (fileless)
Section titled “WMI event subscription (fileless)”An EventFilter + EventConsumer + FilterToConsumerBinding trio that triggers code on a system event (e.g. at boot). Stealthy because it leaves no binary in the classic paths and lives in the WMI repository. ATT&CK T1546.003. Analyzed by reading the root\subscription namespace.
COM hijacking
Section titled “COM hijacking”Hijacking a poorly watched COM key (CLSID) —typically in HKCU, which precedes HKLM— so a legitimate application loads the attacker’s DLL when instantiating that object. Stealthy and without admin privileges. ATT&CK T1546.015.
DLL search order / DLL sideloading
Section titled “DLL search order / DLL sideloading”Placing a DLL with the name a signed application looks for, in a path resolved before the legitimate one. The trusted app loads the attacker’s code — widely used to evade allowlisting. ATT&CK T1574.001/002.
IFEO, AppInit, LSA, Winlogon
Section titled “IFEO, AppInit, LSA, Winlogon”Keys that inject DLLs or launch processes in system contexts: Image File Execution Options (a “debugger” tied to an EXE intercepts it), AppInit_DLLs, LSA authentication packages, Winlogon\Shell/Userinit. Powerful and deep; several require SYSTEM. ATT&CK T1546.012, T1547.002/004.
Kernel and boot (the deepest)
Section titled “Kernel and boot (the deepest)”Malicious drivers, rootkits, and UEFI bootkits persist beneath the OS. They’re the stealthy extreme and the hardest to eradicate: covered in Rootkits and bootkits.
Red Team
Section titled “Red Team”In an authorized exercise, the value isn’t “planting” persistence but checking whether the blue team sees it. The operator picks a mechanism consistent with the emulated adversary, deploys it within scope, and measures how long detection takes and whether response removes it completely. Emulation frameworks like Atomic Red Team cover every TA0003 technique with reproducible tests — also useful for the defender to validate detections. The deliverable is the map of which mechanisms were detected and which slipped through, not “I persisted.”
Blue Team
Section titled “Blue Team”Detection and hunting
Section titled “Detection and hunting”- Autoruns (Sysinternals) enumerates all autostart points at a glance; compare against a known-good baseline and what’s added stands out.
- Pattern hunting: tasks/services with obfuscated commands or invoking interpreters/LOLBins; unsigned DLLs loaded from user paths;
HKCUCLSIDs shadowingHKLM. - WMI subscriptions: periodically enumerate
root\subscriptionand alert on new consumers.
Telemetry
Section titled “Telemetry”- Sysmon: process created (1), file create (11), registry (12/13/14), image load (7), and the WMI-specific events (19/20/21 — WmiEventFilter/Consumer/Binding).
- Windows: 7045 (new service), 4698 (task created), 4697 (service installed, Security), 4657 (registry value change).
Example Sigma rule (defensive)
Section titled “Example Sigma rule (defensive)”title: New Run-key value invoking an interpreterlogsource: product: windows category: registry_setdetection: selection_path: TargetObject|contains: - '\CurrentVersion\Run\' - '\CurrentVersion\RunOnce\' selection_susp: Details|contains: - 'powershell' - 'mshta' - 'rundll32' - 'cmd /c' - '-enc' condition: selection_path and selection_susplevel: highResponse (cleanup)
Section titled “Response (cleanup)”- Identify all mechanisms (usually several/redundant): Autoruns + review of tasks, services, WMI, COM.
- Remove malicious keys/tasks/services/DLLs and the persisted payload.
- Verify by re-running autoruns; on serious compromise or rootkit suspicion, rebuild the host.
CVEs and real-world cases
Section titled “CVEs and real-world cases”- WMI subscriptions are a persistence hallmark of APT29 and many espionage campaigns due to their fileless stealth.
- DLL sideloading against signed applications is a recurring TTP of Chinese groups (e.g. PlugX loaded by legitimate binaries).
- Scheduled tasks with names mimicking Microsoft are a classic of commodity malware (Qakbot, AsyncRAT).
- ATT&CK: tactic TA0003 (Persistence) with the techniques cited above (T1547, T1543, T1053, T1546, T1574).
Testing checklist (analysis)
Section titled “Testing checklist (analysis)”- Autoruns/Regshot before and after running the sample
- Identify all installed mechanisms (don’t stop at the first)
- Imports/strings that reveal the mechanism (static:
CreateService,ITaskService,IWbemServices) - Extract exact IOCs (key/task/service/path/command)
- Any stealthy mechanisms (WMI/COM/IFEO/sideloading)?
- Derive detections (Sigma: 7045/4698/Run keys; Sysmon WMI 19-21)
- Map to MITRE ATT&CK (TA0003)
- Cleanup plan (all mechanisms → payload → verify)