Windows Run Key Self Registration From User Writable Path
Description
The following analytic detects a binary located in a user-writable directory (C:\Users, C:\ProgramData or C:\PerfLogs) that registers itself for persistence by writing its own path into a CurrentVersion Run registry key. This activity is significant because malware delivered through ClickFix-style remote MSI installations (such as NodeJS based loaders or DeElevate64.exe) commonly drops its payload into the user profile and then adds itself to the Run key to survive reboots. If confirmed malicious, this could allow an attacker to maintain persistent access to the endpoint every time the user logs in.
Query · spl
`sysmon`
EventCode=13
registry_path = "*\\Microsoft\\Windows\\CurrentVersion\\Run*"
process_path IN ("*:\\Users\\*", "*:\\ProgramData\\*", "*:\\PerfLogs\\*")
NOT process_name IN (
"Amazon WorkDocs Companion.exe",
"Balto.exe",
"GoToForTeams.exe",
"IWDesktop.exe",
"JTTray.exe",
"Microsoft.SharePoint.exe",
"OfficeAtHandForTeams.exe",
"OneDrive.Sync.Service.exe",
"opera.exe",
"Print to Fax.exe",
"QSHelper.exe",
"RingCentralForTeams.exe",
"UniKeyNT.exe"
)
| where lower(process_path)=lower(replace(registry_value_data,"[\x22\x27]",""))
| stats count min(_time) as firstTime
max(_time) as lastTime
by dest user process_guid process_id process_name process_path
registry_path registry_value_name registry_value_data
vendor_product
| `security_content_ctime(firstTime)`
| `security_content_ctime(lastTime)`
| `windows_run_key_self_registration_from_user_writable_path_filter`
Implementation guide
This search requires Sysmon logs with a Sysmon configuration that includes EventID 13 (Registry value set) for the CurrentVersion Run keys.
If you are using Sysmon, you must have at least version 2.0 of the official Sysmon TA.
This search uses an input macro named sysmon. We strongly recommend that you specify your environment-specific configurations (index, source, sourcetype, etc.) for Windows Sysmon logs.
Replace the macro definition with configurations for your Splunk environment.
The search also uses a post-filter macro designed to filter out known false positives.
Update the process name exclusion list with software in your environment that legitimately registers itself in the Run key.
Known false positives
- Per-user installed software (for example collaboration clients, browsers, VPN clients and updaters) commonly installs into the user profile and registers itself in the Run key. Such software will be returned by this analytic and should be added to the process name exclusion list after validation.
Analyst notes
Known false positives: Per-user installed software (for example collaboration clients, browsers, VPN clients and updaters) commonly installs into the user profile and registers itself in the Run key. Such software will be returned by this analytic and should be added to the process name exclusion list after validation.