Detection: 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.

 1`sysmon`
 2EventCode=13
 3registry_path = "*\\Microsoft\\Windows\\CurrentVersion\\Run*"
 4process_path IN ("*:\\Users\\*", "*:\\ProgramData\\*", "*:\\PerfLogs\\*")
 5NOT process_name IN (
 6        "Amazon WorkDocs Companion.exe",
 7        "Balto.exe",
 8        "GoToForTeams.exe",
 9        "IWDesktop.exe",
10        "JTTray.exe",
11        "Microsoft.SharePoint.exe",
12        "OfficeAtHandForTeams.exe",
13        "OneDrive.Sync.Service.exe",
14        "opera.exe",
15        "Print to Fax.exe",
16        "QSHelper.exe",
17        "RingCentralForTeams.exe",
18        "UniKeyNT.exe"
19    )
20
21
22| where lower(process_path)=lower(replace(registry_value_data,"[\x22\x27]",""))
23
24
25| stats count min(_time) as firstTime
26              max(_time) as lastTime
27  by dest user process_guid process_id process_name process_path
28     registry_path registry_value_name registry_value_data
29     vendor_product
30
31
32| `security_content_ctime(firstTime)`
33
34| `security_content_ctime(lastTime)`
35
36| `windows_run_key_self_registration_from_user_writable_path_filter`

Data Source

Name Platform Sourcetype Source
Sysmon EventID 13 Windows icon Windows 'XmlWinEventLog' 'XmlWinEventLog:Microsoft-Windows-Sysmon/Operational'

Macros Used

Name Value
security_content_ctime convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$)
windows_run_key_self_registration_from_user_writable_path_filter search *
windows_run_key_self_registration_from_user_writable_path_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.

Annotations

Default Configuration

This detection is configured by default in Splunk Enterprise Security to run with the following settings:

Setting Value
Disabled true
Cron Schedule 0 * * * *
Earliest Time -70m@m
Latest Time -10m@m
Schedule Window auto
Creates Finding (Notable) Yes
Rule Title %name%
Rule Description %description%
Notable Event Fields user, dest
Creates Intermediate Finding (Risk Event) No
TTP detections generate a Finding (Notable) and may generate Intermediate Findings (Risk Events) for associated entities.

Implementation

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.

Associated Analytic Story

Finding

Title Entity Field Entity Type Risk Score
[$process_name$] on endpoint [$dest$] registered itself in the Run key [$registry_path$] for persistence. dest system 50

Threat Objects

Field Type
registry_value_name registry_value_name
process_path file_path

References

Detection Testing

Test Type Status Dataset Source Sourcetype
Validation ✅ Passing N/A N/A N/A
Unit ✅ Passing Dataset XmlWinEventLog:Microsoft-Windows-Sysmon/Operational XmlWinEventLog
Integration ✅ Passing Dataset XmlWinEventLog:Microsoft-Windows-Sysmon/Operational XmlWinEventLog

Replay any dataset to Splunk Enterprise by using our replay.py tool or the UI. Alternatively you can replay a dataset into a Splunk Attack Range


Source: GitHub |

Version: 1