Sysmon · Persistence
Sysmon 13 · RegistryEvent (Value Set)
Sysmon Event ID 13 records registry value writes, including the key path, the new data and the process that wrote it. Because so much Windows persistence and defense evasion lives in the registry (Run keys, Winlogon, IFEO debuggers, Defender policy keys), it is a key source for spotting how malware survives reboots.
Where it is logged
Microsoft-Windows-Sysmon/Operational on endpoints and servers. The config must include RegistryEvent rules for SetValue on the keys you care about (Run/RunOnce, Services, Winlogon, IFEO, Defender policies). Sysmon abbreviates hives as HKLM and HKU\<SID>.Key fields to read
| Field | What it tells you |
|---|---|
| EventType | SetValue for value writes (Sysmon 12 covers key create/delete, 14 covers renames). |
| Image | Process that wrote the value. |
| TargetObject | Full registry path including value name, e.g. HKU\S-1-5-21-...\Software\Microsoft\Windows\CurrentVersion\Run\OneDriveSync. |
| Details | Data written; for Run keys this is the command that will run at logon. |
| User | Account context of the writing process (newer Sysmon versions). |
| ProcessGuid | Pivot to Sysmon 1 for how the writer was launched. |
Sample event
Log Name: Microsoft-Windows-Sysmon/Operational
EventID: 13
EventType: SetValue
UtcTime: 2026-11-19 10:28:01.552
Computer: NW-FIN-WS07.northwind.local
ProcessGuid: {4f1c2b7e-a2b2-6740-4105-000000002200}
Image: C:\Windows\System32\reg.exe
TargetObject: HKU\S-1-5-21-3623811015-3361044348-30300820-2290\Software\Microsoft\Windows\CurrentVersion\Run\OneDriveSync
Details: C:\Users\Public\Libraries\odsync.exe -k netsvc
User: NORTHWIND\l.brandtHow to triage it
- 1Classify
TargetObject: Run/RunOnce,Winlogon\Shell/Userinit,Image File Execution Options\...\Debugger, ServicesImagePath, or Defender policy keys. - 2Read
Details: does it point to a signed binary inProgram Files, or to user-writable paths, scripts,rundll32or encoded PowerShell? - 3Check
Image: installers and the legitimate application are expected;reg.exe,powershell.exeor an unknown binary writing persistence keys is suspicious. - 4Pivot via
ProcessGuidto Sysmon 1 to find the parent chain, then hash and analyze the referenced binary. - 5Remove the persistence only after scoping, and search for the same value name or data across the fleet.
Benign vs suspicious
Usually benign
- Applications registering auto-start entries during install (Teams, OneDrive, VPN clients).
- Group Policy and management agents writing policy keys.
- Windows and app updates modifying service
ImagePathvalues.
Red flags
- Run/RunOnce values pointing to
C:\Users\Public,%APPDATA%,%TEMP%or topowershell -enc/mshtacommands. Image File Execution Options\<binary>\Debuggerset (e.g. forsethc.exeorutilman.exe: accessibility backdoor).Winlogon\ShellorUserinitmodified to include an extra binary.- Defender policy keys such as
DisableAntiSpyware,DisableRealtimeMonitoringor newExclusions\Pathsentries. - Value names imitating legitimate software (
OneDriveSync,WindowsUpdate) with non-matching paths.
Hunt for it: Splunk & KQL
index=sysmon EventCode=13
(TargetObject="*\\CurrentVersion\\Run*" OR TargetObject="*\\Image File Execution Options\\*\\Debugger" OR TargetObject="*\\Winlogon\\Shell" OR TargetObject="*\\Windows Defender\\Exclusions\\*")
| table _time, host, User, Image, TargetObject, Details
| sort - _time// Defender for Endpoint DeviceRegistryEvents: Run key persistence pointing to user-writable paths
DeviceRegistryEvents
| where Timestamp > ago(7d)
| where ActionType == "RegistryValueSet"
| where RegistryKey has @"\CurrentVersion\Run"
| where RegistryValueData has_any (@"\Users\Public\", @"\AppData\", @"\Temp\", "powershell", "mshta", "rundll32")
| project Timestamp, DeviceName, InitiatingProcessFileName, InitiatingProcessCommandLine, RegistryKey, RegistryValueName, RegistryValueDataField names depend on your add-on and table. More translations in the Splunk vs KQL cheat sheet.
Interview question
“Which registry locations would you monitor for persistence, and what event shows changes to them?”
✓ Strong answer sketch
Sysmon Event 13 (SetValue) shows writes, with TargetObject for the path and Details for the data. The classic locations are the Run and RunOnce keys under HKLM and each user's HKU hive, Winlogon Shell/Userinit, Image File Execution Options debugger values, and service ImagePath values. I would also monitor Defender policy and exclusion keys, because attackers often weaken AV before dropping payloads. For triage, the key question is whether Details points to a signed binary in a protected path or to something in a user-writable folder written by reg.exe or PowerShell.
Frequently asked questions
What is the difference between Sysmon Event 12, 13 and 14?
12 logs registry key or value create/delete, 13 logs a value being set (with the data in Details), and 14 logs key or value renames.
Why does TargetObject start with HKU instead of HKCU?
HKCU is a per-session alias. Sysmon records the real hive path, HKU\<user SID>, which also tells you whose profile was modified.