Detection: Cisco Secure Endpoint - WMI MSHTA and Run Key

Description

This analytic detects a WMI process-creation command naming an MSHTA URL, a later MSHTA process alert for the same URL, and a Run value referencing that URL, by correlating Cisco Secure Endpoint Behavioral Protection alerts. This links a remote execution attempt to persistence on the same endpoint. URL equality alone does not prove WMI launched the observed process, and a blocked Run write may not persist; verify lineage and response actions.

 1`cisco_secure_endpoint`
 2event_type="Threat Detection"
 3
 4
 5| `cisco_secure_endpoint_extract_bp_fields`
 6
 7
 8| where sig_id IN ("20190409192004","20210616150648","20220810091525")
 9
10
11| spath path=bp_data.details.matched_activity.events{0}.process:start.cmd_line output=process_command
12
13| spath path=bp_data.details.matched_activity.events{0}.registry:set.data_txt output=run_data
14
15| spath path=bp_data.details.matched_activity.events{0}.registry:set.key output=run_key
16
17| spath path=bp_data.details.matched_activity.events{0}.registry:set.value output=run_value
18
19| spath path=bp_data.details.matched_activity.events{0}.process:start.ts output=process_event_ts
20
21| spath path=bp_data.details.matched_activity.events{0}.registry:set.ts output=registry_event_ts
22
23
24| eval stage=case(sig_id="20190409192004","wmi",
25           sig_id="20210616150648","mshta",
26           sig_id="20220810091525","persist")
27
28
29| rex field=process_command "(?i)mshta(?:\.exe)?\s+['\"]?(?<process_url>https?://[^\s'\"]+)"
30
31
32| rex field=run_data "(?i)mshta(?:\.exe)?\s+['\"]?(?<run_url>https?://[^\s'\"]+)"
33
34
35| eval remote_url=coalesce(process_url,run_url),
36       event_time=coalesce(tonumber(process_event_ts)/1000000000,
37           tonumber(registry_event_ts)/1000000000,
38           tonumber(timestamp)+coalesce(tonumber(timestamp_nanoseconds),0)/1000000000)
39
40
41| where isnotnull(endpoint_guid)
42        AND isnotnull(remote_url)
43        AND isnotnull(event_time)
44
45
46| sort 0 endpoint_guid remote_url event_time
47
48| streamstats last(eval(if(stage="wmi",event_time,null()))) as wmi_time
49              last(eval(if(stage="wmi",process_command,null()))) as wmi_command
50  by endpoint_guid remote_url
51
52| eval valid_mshta=if(stage="mshta" AND isnotnull(wmi_time)
53        AND event_time>=wmi_time AND event_time-wmi_time<=300,1,0)
54
55| streamstats last(eval(if(valid_mshta=1,event_time,null()))) as mshta_time
56              last(eval(if(valid_mshta=1,wmi_time,null()))) as first_event_time
57              last(eval(if(valid_mshta=1,process_command,null()))) as mshta_command
58              last(eval(if(valid_mshta=1,wmi_command,null()))) as prior_wmi_command
59  by endpoint_guid remote_url
60
61| where stage="persist" AND isnotnull(mshta_time)
62        AND event_time>=mshta_time AND event_time-first_event_time<=300
63
64| eval wmi_command=prior_wmi_command, firstTime=first_event_time,
65       lastTime=event_time, user=coalesce(user,"unknown")
66
67| dedup endpoint_guid remote_url mshta_time
68
69
70| table dest user endpoint_guid remote_url run_key
71        run_value wmi_command mshta_command firstTime lastTime
72
73| `security_content_ctime(firstTime)`
74
75| `security_content_ctime(lastTime)`
76
77| `cisco_secure_endpoint___wmi_mshta_and_run_key_filter`

Data Source

Name Platform Sourcetype Source
Cisco Secure Endpoint Behavioral Protection Threat Detection Other 'cisco:se' 'not_applicable'

Macros Used

Name Value
security_content_ctime convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$)
search bp_engine=apde
spath path=bp_data.details.sig_id output=sig_id
spath path=computer.connector_guid output=endpoint_guid
spath path=computer.hostname output=dest
spath path=bp_data.details.matched_activity.events{0}.process:start.user.name output=user
spath path=bp_data.details.matched_activity.events{0}.registry:set.user.name output=registry_user
spath path=bp_data.details.matched_activity.events{0}.file:create.user.name output=file_user
eval user=coalesce(user,registry_user,file_user)
spath path=bp_data.audit output=bp_audit
spath path=bp_data.details.actions{}.action output=bp_action
spath path=bp_data.details.actions{}.status output=bp_action_status
eval bp_response=case(bp_audit="true","audit mode",isnotnull(bp_action_status),mvjoin(bp_action,", "),true(),"no action reported")`
cisco_secure_endpoint___wmi_mshta_and_run_key_filter search *
cisco_secure_endpoint___wmi_mshta_and_run_key_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 Cisco Secure Endpoint Behavioral Protection Threat Detection alerts, which include event_type="Threat Detection". This search uses an input macro named cisco_secure_endpoint. We strongly recommend that you specify your environment-specific configurations (index, source, sourcetype, etc.) for Cisco Secure Endpoint Behavioral Protection Threat Detection alerts. Replace the macro definition with configurations for your Splunk environment. The cisco_secure_endpoint_extract_bp_fields macro extracts the common signature, endpoint, actor, and prevention-response fields used by this search. The search also uses a post-filter macro designed to filter out known false positives. The logs are to be ingested using the Cisco Security Cloud App for Splunk (https://splunkbase.splunk.com/app/7404). In Protect mode, a Behavioral Protection response can kill or quarantine an earlier stage, so this search requires each later alert to have actually appeared. Review bp_data.audit and bp_data.details.actions in the source events before concluding that a task registered, a process completed, or a transfer succeeded. The included audit-mode fixtures verify alert correlation, not survival of an enforced prevention action.

Known False Positives

An approved application may launch remote content through mshta and WMI and register it for logon. Inspect the content and URL, WMI process result, Run key scope, account, and change record.

Associated Analytic Story

Finding

Title Entity Field Entity Type Risk Score
WMI command, MSHTA launch and Run key sharing remote URL $remote_url$ on $dest$ dest system 50

Threat Objects

Field Type
run_key registry_path
run_value registry_value_name
remote_url url

References

Detection Testing

Test Type Status Dataset Source Sourcetype
Validation ✅ Passing N/A N/A N/A
Unit ✅ Passing Dataset not_applicable cisco:se
Integration ✅ Passing Dataset not_applicable cisco:se

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