Windows Potential Cloudflared Tunnel Execution

 Original Source: [splunk source]
Name:Windows Potential Cloudflared Tunnel Execution
id:2e29b58e-0f5a-42fc-b435-0fdce8862831
version:3
date:None
author:Raven Tait, Nasreddine Bencherchali, Splunk
status:production
type:Anomaly
Description:This analytic detects Cloudflare Tunnel client execution by its process name or original executable name, including renamed copies, and by command lines that create token-authenticated or Quick Tunnels. Threat actors have used cloudflared for covert command-and-control and persistent remote access, including renamed binaries and tunnels that expose local services through Cloudflare's edge. The command-line signatures focus on token-backed `tunnel run`, Quick Tunnel commands that publish a loopback service with `--url`, and config-backed `tunnel --config ... run` commands.
Data_source:
  • -Sysmon EventID 1
  • -Windows Event Log Security 4688
  • -CrowdStrike ProcessRollup2
search:| tstats `security_content_summariesonly`
count min(_time) as firstTime
max(_time) as lastTime

from datamodel=Endpoint.Processes where

Processes.process_name IN ("cloudflared.exe")
OR
Processes.original_file_name IN ("cloudflared.exe")
OR (
Processes.process="*tunnel*"
Processes.process IN ("*--token*", "*--url*", "*--config*")
)

by Processes.process Processes.vendor_product Processes.user_id Processes.process_hash
Processes.parent_process_name Processes.parent_process_exec Processes.action
Processes.dest Processes.process_current_directory Processes.process_path
Processes.process_integrity_level Processes.original_file_name Processes.parent_process
Processes.parent_process_path Processes.parent_process_guid Processes.parent_process_id
Processes.process_guid Processes.process_id Processes.user Processes.process_name

| `drop_dm_object_name(Processes)`
| `security_content_ctime(firstTime)`
| `security_content_ctime(lastTime)`

| eval has_exe_prefix=if(match(process, "(?i)^\\s*(?:\"[^\"]+\\.exe\"|[^\\s]+\\.exe)(?:\\s|$)"), 1, 0)

| eval is_tunnel_cmd=if(match(process, "(?i)\\btunnel(\\s|$)"), 1, 0)

| eval has_run=if(match(process, "(?i)\\srun(\\s|$)"), 1, 0)

| eval has_token=if(match(process, "(?i)\\s--token(-file)?([=\\s]|$)"), 1, 0)

| eval has_config=if(match(process, "(?i)\\s--config([=\\s]|$)"), 1, 0)

| eval quick_tunnel_loopback=if(match(process, "(?i)--url(?:=|\\s+)(?:\"?)(?:https?://)?(?:localhost|127\\.0\\.0\\.1|0\\.0\\.0\\.0|\\[::1\\])(?:[:/\\s\"]|$)"), 1, 0)

| eval token_tunnel_ordered=if(match(process, "(?i)\\btunnel\\b.*\\brun\\s+--token(-file)?([=\\s]|$)"), 1, 0)

| eval config_tunnel_ordered=if(match(process, "(?i)\\btunnel\\b.*--config(?:=|\\s+)(?:\"[^\"]+\"|[^\\s]+).*\\brun(?:\\s|$)"), 1, 0)

| eval quick_tunnel_ordered=if(match(process, "(?i)\\btunnel\\b.*--url(?:=|\\s+)(?:\"?)(?:https?://)?(?:localhost|127\\.0\\.0\\.1|0\\.0\\.0\\.0|\\[::1\\])(?:[:/\\s\"]|$)"), 1, 0)

| eval cloudflared_token_tunnel=if(has_exe_prefix=1 AND is_tunnel_cmd=1 AND has_run=1 AND has_token=1 AND token_tunnel_ordered=1, 1, 0)

| eval cloudflared_quick_tunnel=if(has_exe_prefix=1 AND is_tunnel_cmd=1 AND quick_tunnel_loopback=1 AND quick_tunnel_ordered=1, 1, 0)

| eval cloudflared_config_tunnel=if(has_exe_prefix=1 AND is_tunnel_cmd=1 AND has_run=1 AND has_config=1 AND config_tunnel_ordered=1, 1, 0)

| where process_name IN ("cloudflared.exe") OR original_file_name IN ("cloudflared.exe") OR cloudflared_token_tunnel=1 OR cloudflared_quick_tunnel=1 OR cloudflared_config_tunnel=1

| `windows_potential_cloudflared_tunnel_execution_filter`


how_to_implement:The detection uses endpoint process telemetry mapped to the Processes node of the Endpoint data model. Ingest full command lines, process names, original file names, parent process, user, and destination fields from Linux or Windows EDR or Sysmon data, and normalize them to the Splunk Common Information Model (CIM).
known_false_positives:Authorized administrators, DevOps teams, and developers may run cloudflared to publish local services or establish config-backed tunnels. Review the executable location, parent process, user, token handling, destination service, and whether the activity is approved before tuning the detection.
References:
  -https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/do-more-with-tunnels/trycloudflare/
  -https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/get-started/create-remote-tunnel/
  -https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/monitor-tunnels/metrics/
  -https://developers.cloudflare.com/tunnel/reference/run-parameters/
  -https://github.com/cloudflare/cloudflared
  -https://web-assets.esetstatic.com/wls/en/papers/white-papers/cyberespionage-gamaredon-way.pdf
  -https://www-bleepingcomputer-com.cdn.ampproject.org/c/s/www.bleepingcomputer.com/news/security/hackers-increasingly-abuse-cloudflare-tunnels-for-stealthy-connections/amp/
  -https://www.guidepointsecurity.com/blog/tunnel-vision-cloudflared-abused-in-the-wild/
  -https://www.reconinfosec.com/articles/emergence-of-akira-ransomware-group/
  -https://www.veracode.com/blog/a-deep-dive-into-powerat-a-newly-discovered-stealer-rat-combo-polluting-pypi/
drilldown_searches:
 earliest_offset:'$info_min_time$'
 latest_offset:'$info_max_time$'
 name:'View the detection results for - "$user$" and "$dest$"'
 search:'%original_detection_search% | search user = "$user$" dest = "$dest$"'
 name:'View risk events for the last 7 days for - "$user$" and "$dest$"'
 search:'| from datamodel Risk.All_Risk | search normalized_risk_object IN ("$user$", "$dest$") | stats count min(_time) as firstTime max(_time) as lastTime values(search_name) as "Search Name" values(risk_message) as "Risk Message" values(analyticstories) as "Analytic Stories" values(annotations._all) as "Annotations" values(annotations.mitre_attack.mitre_tactic) as "ATT&CK Tactics" by normalized_risk_object | `security_content_ctime(firstTime)` | `security_content_ctime(lastTime)`'
 earliest_offset:'7d'
 latest_offset:'0'
analytic_story:['Reverse Network Proxy']

asset_type:Endpoint

mitre_attack_id:['T1572']

product:['Splunk Enterprise', 'Splunk Enterprise Security', 'Splunk Cloud']

category:endpoint

security_domain:endpoint

tags:

tests:
 name:'True Positive Test'
 attack_data:
  data: https://media.githubusercontent.com/media/splunk/attack_data/master/datasets/attack_techniques/T1572/snapattack/snapattack.log
  source: XmlWinEventLog:Security
  sourcetype: XmlWinEventLog
 test_type:'unit'
manual_test:None

Related Analytic Stories


Reverse Network Proxy