Detection: Ngrok Reverse Proxy Usage

Description

This analytic detects ngrok execution on Linux and Windows by process name, regardless of command line, and detects renamed ngrok binaries through combinations of ngrok-specific command-line behavior. The command-line logic correlates authentication setup with TCP tunneling to RDP or SMB ports, identifies configured all-tunnel startup patterns, and recognizes the Invoke-Ngrok wrapper. Threat actors have used ngrok to expose internal services, maintain persistence, move laterally, and proxy command-and-control traffic. Review the collected commands, parent process, user, endpoint, and approved tunnel configuration to determine whether the use is authorized.

  1
  2| tstats `security_content_summariesonly`
  3  count min(_time) as firstTime
  4        max(_time) as lastTime
  5        values(Processes.action) as action
  6        values(Processes.original_file_name) as original_file_name
  7        values(Processes.parent_process) as parent_process
  8        values(Processes.parent_process_exec) as parent_process_exec
  9        values(Processes.parent_process_guid) as parent_process_guid
 10        values(Processes.parent_process_id) as parent_process_id
 11        values(Processes.parent_process_name) as parent_process_name
 12        values(Processes.parent_process_path) as parent_process_path
 13        values(Processes.process) as process
 14        values(Processes.process_exec) as process_exec
 15        values(Processes.process_guid) as process_guid
 16        values(Processes.process_hash) as process_hash
 17        values(Processes.process_id) as process_id
 18        values(Processes.process_integrity_level) as process_integrity_level
 19        values(Processes.process_name) as process_name
 20        values(Processes.process_path) as process_path
 21        values(Processes.user_id) as user_id
 22        values(Processes.vendor_product) as vendor_product
 23FROM datamodel=Endpoint.Processes WHERE
 24(
 25    Processes.process_name IN ("ngrok", "ngrok.exe")
 26    OR
 27    Processes.original_file_name IN ("ngrok", "ngrok.exe")
 28    OR
 29    Processes.process IN (
 30        "*-authtoken*",
 31        "*-config*-region*",
 32        "*-hostname*-region*",
 33        "*-protocol*tcp*",
 34        "*-region*-config*",
 35        "*-region*-hostname*",
 36        "*-region*-subdomain*",
 37        "*-subdomain*-region*",
 38        "*config add-authtoken*",
 39        "*fileserver*",
 40        "*Invoke-Ngrok*",
 41        "*start*--all*",
 42        "*tcp *"
 43    )
 44)
 45
 46BY Processes.dest Processes.user _time span=15m
 47
 48
 49| `drop_dm_object_name(Processes)`
 50
 51
 52| eval has_ngrok_process_name = if(
 53    mvfind(process_name, "(?i)^ngrok(\\.exe)?$") >= 0,
 54    1,
 55    0
 56  )
 57
 58
 59| eval has_ngrok_original_file_name = if(
 60    mvfind(original_file_name, "(?i)^ngrok(\\.exe)?$") >= 0,
 61    1,
 62    0
 63  )
 64
 65
 66| eval has_auth_setup = if(
 67    mvfind(process, "(?i)config\\s+add-authtoken") >= 0
 68    OR mvfind(process, "(?i)--authtoken(?:\\s
 69|=)
 70|-auth(?:\\s
 71|=)") >= 0,
 72    1,
 73    0
 74  )
 75
 76
 77| eval has_tcp_tunnel = if(
 78    mvfind(process, "(?i)\\btcp\\s+(?:3389
 79|445)\\b") >= 0
 80    OR mvfind(process, "(?i)-protocol\\s+tcp\\b") >= 0,
 81    1,
 82    0
 83  )
 84
 85
 86| eval has_sensitive_port = if(
 87    mvfind(process, "(?i)\\btcp\\s+(?:3389
 88|445)\\b") >= 0
 89    OR mvfind(process, "(?i)-port\\s+(?:3389
 90|445)\\b") >= 0,
 91    1,
 92    0
 93  )
 94
 95
 96| eval has_start_all = if(
 97    mvfind(process, "(?i)\\bstart\\b.*--all\\b") >= 0,
 98    1,
 99    0
100  )
101
102
103| eval has_config = if(
104    mvfind(process, "(?i)--?config(?:\\s
105|=)") >= 0,
106    1,
107    0
108  )
109
110
111| eval has_region = if(
112    mvfind(process, "(?i)--?region(?:\\s
113|=)") >= 0,
114    1,
115    0
116  )
117
118
119| eval has_tunnel_command = if(
120    mvfind(process, "(?i)\\b(?:http
121|tcp
122|tls
123|start)\\b") >= 0,
124    1,
125    0
126  )
127
128
129| eval has_endpoint_option = if(
130    mvfind(process, "(?i)--?(?:hostname
131|subdomain
132|url)(?:\\s
133|=)") >= 0,
134    1,
135    0
136  )
137
138
139| eval has_invoke_ngrok = if(
140    mvfind(process, "(?i)Invoke-Ngrok") >= 0,
141    1,
142    0
143  )
144
145
146| eval has_fileserver = if(
147    mvfind(process, "(?i)-fileserver(?:\\s
148|=)") >= 0,
149    1,
150    0
151  )
152
153
154| where
155    has_ngrok_process_name = 1
156    OR has_ngrok_original_file_name = 1
157    OR has_start_all = 1
158    OR (has_auth_setup = 1 AND has_tcp_tunnel = 1 AND has_sensitive_port = 1)
159    OR (has_config = 1 AND has_region = 1 AND has_tunnel_command = 1)
160    OR (has_region = 1 AND has_tunnel_command = 1 AND has_endpoint_option = 1)
161    OR (has_invoke_ngrok = 1 AND has_fileserver = 1)
162    OR (has_fileserver = 1 AND has_auth_setup = 1)
163
164
165| `security_content_ctime(firstTime)`
166
167| `security_content_ctime(lastTime)`
168
169| `ngrok_reverse_proxy_usage_filter`

Data Source

Name Platform Sourcetype Source
CrowdStrike ProcessRollup2 Other 'crowdstrike:events:sensor' 'crowdstrike'
Windows Event Log Security 4688 Windows icon Windows 'XmlWinEventLog' 'XmlWinEventLog:Security'
Sysmon for Linux EventID 1 Linux icon Linux 'sysmon:linux' 'Syslog:Linux-Sysmon/Operational'
Sysmon EventID 1 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$)
ngrok_reverse_proxy_usage_filter search *
ngrok_reverse_proxy_usage_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) No
Creates Intermediate Finding (Risk Event) Yes
Anomaly detections generate Intermediate Findings (Risk Events). They do not generate a Finding (Notable) directly.

Implementation

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

Ngrok is a legitimate development and remote-access utility. Approved developers, IT administrators, and endpoint-management workflows may run ngrok or use similar command-line parameters. Review the process values and documented tunnel use, and tune approved users, hosts, and parent processes as needed.

Associated Analytic Story

Intermediate Findings

Message Entity Field Entity Type Risk Score
Ngrok tunnel or service installation activity was observed on [$dest$] by [$user$] running [$process$]. user user 20
Ngrok tunnel or service installation activity was observed on [$dest$] by [$user$] running [$process$]. dest system 20

Threat Objects

Field Type
process_name process_name
parent_process_name parent_process_name

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