| ID | Technique | Tactic |
|---|---|---|
| T1090 | Proxy | Command and Control |
| T1102 | Web Service | Command and Control |
| T1572 | Protocol Tunneling | Command and Control |
Detection: Ngrok Reverse Proxy on Network
Description
This analytic detects DNS lookups to ngrok-managed endpoint domains, agent gateway domains, and CNAME targets, plus a CISA-reported ngrok-themed domain. Results classify TCP tunnel hostnames, tunnel.us-style agent gateway lookups, and generated-looking endpoint labels, and summarize repeated queries and distinct DNS answers by source and 15-minute interval. Threat actors have used ngrok to expose internal services, including RDP and SMB, maintain persistence, move laterally, and proxy command-and-control traffic. Ngrok is also a legitimate developer and remote-access service, so use the query classification, frequency, endpoint context, and approved usage baseline to prioritize investigation.
Search
1
2| tstats `security_content_summariesonly`
3 count min(_time) as firstTime
4 max(_time) as lastTime
5 values(DNS.answer) as answer
6 distinct_count(DNS.answer) as distinct_answers
7 values(DNS.answer_count) as answer_count
8 values(DNS.query_count) as query_count
9
10FROM datamodel=Network_Resolution WHERE
11
12DNS.query IN (
13 "*.ngrok-agent.com.",
14 "*.ngrok-agent.com",
15 "*.ngrok-cname.com.",
16 "*.ngrok-cname.com",
17 "*.ngrok-free.app.",
18 "*.ngrok-free.app",
19 "*.ngrok-free.dev.",
20 "*.ngrok-free.dev",
21 "*.ngrok-free.pizza.",
22 "*.ngrok-free.pizza",
23 "*.ngrok.app.",
24 "*.ngrok.app",
25 "*.ngrok.com.",
26 "*.ngrok.com",
27 "*.ngrok.dev.",
28 "*.ngrok.dev",
29 "*.ngrok.io.",
30 "*.ngrok.io",
31 "*.ngrok.pizza.",
32 "*.ngrok.pizza",
33 "*.ngrok.pro.",
34 "*.ngrok.pro",
35 "*.tcp.ngrok.io.",
36 "*.tcp.ngrok.io",
37 "korgn.su.lennut.com.",
38 "korgn.su.lennut.com",
39 "tunnel.*.ngrok.com.",
40 "tunnel.*.ngrok.com"
41)
42
43BY DNS.src DNS.query DNS.reply_code_id DNS.vendor_product _time span=15m
44
45
46| `drop_dm_object_name("DNS")`
47
48
49| eval query = lower(rtrim(query, "."))
50
51
52| eval endpoint_label = mvindex(split(query, "."), 0)
53
54
55| eval query_type = case(
56 query = "korgn.su.lennut.com", "CISA-reported ngrok-themed domain",
57 match(query, "(?i)^[^.]+\\.tcp\\.ngrok\\.io$"), "TCP tunnel endpoint",
58 match(query, "(?i)^tunnel\\.[^.]+\\.ngrok\\.com$"), "Ngrok agent gateway",
59 match(endpoint_label, "(?i)^(?:[0-9]{8,}
60|[a-f0-9]{10,})$"), "Generated-looking endpoint label",
61 true(), "Ngrok-managed domain lookup"
62 )
63
64| `security_content_ctime(firstTime)`
65
66| `security_content_ctime(lastTime)`
67
68| `ngrok_reverse_proxy_on_network_filter`
Data Source
| Name | Platform | Sourcetype | Source |
|---|---|---|---|
| Sysmon EventID 22 | 'XmlWinEventLog' |
'XmlWinEventLog:Microsoft-Windows-Sysmon/Operational' |
Macros Used
| Name | Value |
|---|---|
| security_content_summariesonly | summariesonly=summariesonly_config allow_old_summaries=oldsummaries_config fillnull_value=fillnull_config`` |
| ngrok_reverse_proxy_on_network_filter | search * |
ngrok_reverse_proxy_on_network_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 |
Implementation
This detection requires DNS query logs. Map your DNS telemetry (for example, from your DNS server, resolver, or network sensor) to the Network Resolution data model so the search can find the events it needs. The search groups matching DNS lookups by source, query, response code, vendor, and 15-minute interval. Ensure the Network Resolution data model includes DNS query names and answers to populate query classification and distinct-answer counts. Modify the query as needed to use another source.
Known False Positives
Ngrok-managed domains and the tunnel gateway are used for legitimate development, testing, and remote-access workflows. Static dev domains and repeated agent gateway lookups can be expected in approved environments. Baseline authorized sources and use, and prioritize TCP tunnel endpoints, generated-looking labels, and the CISA-reported domain.
Associated Analytic Story
Intermediate Findings
| Message | Entity Field | Entity Type | Risk Score |
|---|---|---|---|
| The endpoint [$src$] queried Ngrok-related domain [$query$] ($query_type$) $count$ time(s) and received $distinct_answers$ distinct DNS answer(s). | src | system | 20 |
References
-
https://www.sophos.com/en-us/blog/rapid-response-the-ngrok-incident-guide
-
https://thedfirreport.com/2024/08/12/threat-actors-toolkit-leveraging-sliver-poshc2-batch-scripts/
-
https://www.trendmicro.com/en_us/research/24/j/earth-simnavaz-cyberattacks.html
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: 11