Detection: Cisco Secure Endpoint - Run Key Registry Payload Executed

Description

This analytic detects a registry-resident PowerShell payload referenced by a long Run value and later by a fileless execution alert, using Cisco Secure Endpoint Behavioral Protection alerts for the same endpoint and registry payload key. A matching task creation command and earlier download command enrich the result when observed; neither is required. The linked persistence setting and observed execution can indicate fileless malware. A Run-key write may be blocked in Protect mode, and neither the Run alert nor a task creation command proves logon execution or task registration. Inspect the stored value, process lineage, and prevention response.

  1`cisco_secure_endpoint`
  2event_type="Threat Detection"
  3
  4
  5| `cisco_secure_endpoint_extract_bp_fields`
  6
  7
  8| where sig_id IN ("20200719101800","20201208164752","20220408163700","20170104055521")
  9
 10
 11| spath path=bp_data.details.matched_activity.events{0}.registry:set.key output=run_key
 12
 13| spath path=bp_data.details.matched_activity.events{0}.registry:set.value output=run_value
 14
 15| spath path=bp_data.details.matched_activity.events{0}.registry:set.data_txt output=run_data
 16
 17| spath path=bp_data.details.matched_activity.events{0}.registry:set.puid output=setter_puid
 18
 19| spath path=bp_data.details.matched_activity.events{0}.process:start.parent_puid output=parent_puid
 20
 21| spath path=bp_data.details.matched_activity.events{0}.process:start.cmd_line output=process_command
 22
 23| spath path=bp_data.details.matched_activity.events{0}.process:start.parent_app.name output=parent_name
 24
 25| spath path=bp_data.details.matched_activity.events{0}.process:start.ts output=process_event_ts
 26
 27| spath path=bp_data.details.matched_activity.events{0}.registry:set.ts output=registry_event_ts
 28
 29
 30| rex field=process_command "(?i)DownloadString\('(?<download_url>https?://[^']+)'\)"
 31
 32| rex field=process_command "(?i)/TN\s+(?<task_name>\S+)"
 33
 34
 35| rex field=run_data "(?i)(?<run_payload_key>HK(?:CU
 36|LM):[^)\s]+)"
 37
 38
 39| rex field=process_command "(?i)(?<execution_payload_key>HK(?:CU
 40|LM):[^)\s]+)"
 41
 42
 43| eval payload_key=lower(coalesce(run_payload_key,execution_payload_key)),
 44       writer_puid=coalesce(setter_puid,parent_puid)
 45
 46
 47| eval stage=case(sig_id="20200719101800","download",
 48           sig_id="20201208164752","persist",
 49               sig_id="20220408163700","task",
 50           sig_id="20170104055521","execute")
 51
 52
 53| eval event_time=coalesce(tonumber(process_event_ts)/1000000000,
 54        tonumber(registry_event_ts)/1000000000,
 55        tonumber(timestamp)+coalesce(tonumber(timestamp_nanoseconds),0)/1000000000)
 56
 57
 58| where isnotnull(endpoint_guid)
 59        AND isnotnull(payload_key)
 60    AND isnotnull(stage)
 61        AND isnotnull(event_time)
 62
 63
 64| sort 0 endpoint_guid payload_key event_time
 65
 66
 67| streamstats max(eval(if(stage="download",event_time,null()))) as download_time
 68          last(eval(if(stage="download",process_command,null()))) as download_command
 69          last(eval(if(stage="download",download_url,null()))) as download_url
 70          max(eval(if(stage="persist",event_time,null()))) as run_time
 71              last(eval(if(stage="persist",run_data,null()))) as run_command
 72              last(eval(if(stage="persist",run_key,null()))) as stored_run_key
 73              last(eval(if(stage="persist",run_value,null()))) as stored_run_value
 74                  last(eval(if(stage="persist",writer_puid,null()))) as run_writer_puid
 75                  last(eval(if(stage="persist",bp_response,null()))) as run_bp_response
 76                  max(eval(if(stage="task",event_time,null()))) as task_time
 77                  last(eval(if(stage="task",process_command,null()))) as task_command
 78                  last(eval(if(stage="task",task_name,null()))) as task_name
 79                  last(eval(if(stage="task",bp_response,null()))) as task_bp_response
 80  by endpoint_guid payload_key
 81
 82
 83| where stage="execute"
 84        AND isnotnull(run_time)
 85        AND event_time>=run_time
 86        AND event_time-run_time<=300
 87
 88
 89| eval execution_command=process_command,
 90       firstTime=run_time,
 91       lastTime=event_time
 92
 93
 94| eval download_command=if(isnotnull(download_time) AND download_time<=run_time AND event_time-download_time<=300,download_command,null()),
 95       download_url=if(isnotnull(download_time) AND download_time<=run_time AND event_time-download_time<=300,download_url,null()),
 96           task_command=if(isnotnull(task_time) AND task_time>=run_time AND task_time<=event_time,task_command,null()),
 97           task_name=if(isnotnull(task_command),task_name,null()),
 98           task_bp_response=if(isnotnull(task_command),task_bp_response,null())
 99
100
101| dedup endpoint_guid payload_key run_time
102
103
104| eval user=coalesce(user,"unknown")
105
106
107| table dest user endpoint_guid run_writer_puid payload_key
108        stored_run_key stored_run_value download_url download_command
109        run_command run_bp_response task_name task_command task_bp_response execution_command bp_response firstTime
110        lastTime
111
112| `security_content_ctime(firstTime)`
113
114| `security_content_ctime(lastTime)`
115
116| `cisco_secure_endpoint___run_key_registry_payload_executed_filter`

Data Source

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

Macros Used

Name Value
cisco_secure_endpoint sourcetype="cisco:se"
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___run_key_registry_payload_executed_filter search *
cisco_secure_endpoint___run_key_registry_payload_executed_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

A managed application may use a long Run command to invoke a script stored in the registry. Review the referenced key, its actual value, child process, account, signer, and deployment change record. The Run key alert alone does not prove later logon execution.

Associated Analytic Story

Finding

Title Entity Field Entity Type Risk Score
Run key and execution of registry stored payload $payload_key$ on $dest$ dest system 50

Threat Objects

Field Type
stored_run_key registry_path
execution_command command
payload_key registry_path

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