LoFP LoFP / 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.

Techniques

Sample rules

Windows Potential Cloudflared Tunnel Execution

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.

Detection logic


| 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`