DNS Tunneling
A machine learning job detected unusually large numbers of DNS queries for a single top-level DNS domain, which is often used for DNS tunneling. DNS tunneling can be used for command-and-control, persistence, or data exfiltration activity. For example, dnscat tends to generate many DNS questions for a top-level domain as it uses the DNS protocol to tunnel data.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2020/03/25"
3integration = ["endpoint", "network_traffic"]
4maturity = "production"
5updated_date = "2025/01/15"
6
7[rule]
8anomaly_threshold = 50
9author = ["Elastic"]
10description = """
11A machine learning job detected unusually large numbers of DNS queries for a single top-level DNS domain, which is often
12used for DNS tunneling. DNS tunneling can be used for command-and-control, persistence, or data exfiltration activity.
13For example, dnscat tends to generate many DNS questions for a top-level domain as it uses the DNS protocol to tunnel
14data.
15"""
16false_positives = [
17 """
18 DNS domains that use large numbers of child domains, such as software or content distribution networks, can trigger
19 this alert and such parent domains can be excluded.
20 """,
21]
22from = "now-45m"
23interval = "15m"
24license = "Elastic License v2"
25machine_learning_job_id = "packetbeat_dns_tunneling"
26name = "DNS Tunneling"
27setup = """## Setup
28
29This rule requires the installation of associated Machine Learning jobs, as well as data coming in from one of the following integrations:
30- Elastic Defend
31- Network Packet Capture
32
33### Anomaly Detection Setup
34
35Once the rule is enabled, the associated Machine Learning job will start automatically. You can view the Machine Learning job linked under the "Definition" panel of the detection rule. If the job does not start due to an error, the issue must be resolved for the job to commence successfully. For more details on setting up anomaly detection jobs, refer to the [helper guide](https://www.elastic.co/guide/en/kibana/current/xpack-ml-anomalies.html).
36
37### Elastic Defend Integration Setup
38Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
39
40#### Prerequisite Requirements:
41- Fleet is required for Elastic Defend.
42- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
43
44#### The following steps should be executed in order to add the Elastic Defend integration to your system:
45- Go to the Kibana home page and click "Add integrations".
46- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
47- Click "Add Elastic Defend".
48- Configure the integration name and optionally add a description.
49- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
50- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
51- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
52- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
53For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/current/agent-policy.html).
54- Click "Save and Continue".
55- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
56For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
57
58### Network Packet Capture Integration Setup
59The Network Packet Capture integration sniffs network packets on a host and dissects known protocols. Monitoring the network traffic is critical to gaining observability and securing your environment — ensuring high levels of performance and security. The Network Packet Capture integration captures the network traffic between your application servers, decodes common application layer protocols and records the interesting fields for each transaction.
60
61#### The following steps should be executed in order to add the Elastic Agent System integration "network_traffic" to your system:
62- Go to the Kibana home page and click “Add integrations”.
63- In the query bar, search for “Network Packet Capture” and select the integration to see more details about it.
64- Click “Add Network Packet Capture”.
65- Configure the integration name and optionally add a description.
66- Review optional and advanced settings accordingly.
67- Add the newly installed “network_traffic” to an existing or a new agent policy, and deploy the agent on your system from which network log files are desirable.
68- Click “Save and Continue”.
69- For more details on the integration refer to the [helper guide](https://docs.elastic.co/integrations/network_traffic).
70"""
71references = ["https://www.elastic.co/guide/en/security/current/prebuilt-ml-jobs.html"]
72risk_score = 21
73rule_id = "91f02f01-969f-4167-8f66-07827ac3bdd9"
74severity = "low"
75tags = [
76 "Use Case: Threat Detection",
77 "Rule Type: ML",
78 "Rule Type: Machine Learning",
79 "Tactic: Command and Control",
80 "Resources: Investigation Guide",
81]
82type = "machine_learning"
83note = """## Triage and analysis
84
85> **Disclaimer**:
86> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
87
88### Investigating DNS Tunneling
89
90DNS tunneling exploits the DNS protocol to covertly transmit data between a compromised system and an attacker-controlled server. Adversaries use it for stealthy command-and-control, persistence, or data exfiltration by embedding data within DNS queries. The detection rule leverages machine learning to identify anomalies, such as an unusually high volume of DNS queries to a single domain, indicating potential tunneling activity.
91
92### Possible investigation steps
93
94- Review the DNS query logs to identify the specific top-level domain generating the unusually high volume of queries. This can help pinpoint the potential source of tunneling activity.
95- Analyze the source IP addresses associated with the DNS queries to determine if they originate from known or suspicious hosts within the network.
96- Check for any recent changes or anomalies in the network traffic patterns related to the identified domain, which might indicate tunneling or exfiltration attempts.
97- Investigate the history of the identified domain to assess its reputation and any known associations with malicious activities or threat actors.
98- Correlate the DNS query activity with other security events or alerts in the network to identify any related suspicious behavior or indicators of compromise.
99
100### False positive analysis
101
102- High volume of DNS queries from legitimate software updates or patch management systems can trigger false positives. Users should identify and whitelist domains associated with trusted update services.
103- Content delivery networks (CDNs) often generate numerous DNS queries due to their distributed nature. Exclude known CDN domains from the analysis to reduce false positives.
104- Internal network monitoring tools that rely on DNS for service discovery may cause an increase in DNS queries. Consider excluding these internal domains if they are verified as non-threatening.
105- Some cloud services use DNS for load balancing and may result in high query volumes. Users should review and whitelist these domains if they are confirmed to be safe.
106- Automated scripts or applications that frequently query DNS for legitimate purposes can be excluded by identifying their specific patterns and adding them to an exception list.
107
108### Response and remediation
109
110- Isolate the affected system from the network to prevent further data exfiltration or command-and-control communication.
111- Conduct a thorough analysis of DNS logs to identify the specific domain involved in the tunneling activity and block it at the network perimeter.
112- Review and terminate any suspicious processes or services running on the compromised system that may be associated with the tunneling activity.
113- Reset credentials and review access permissions for accounts that were active on the compromised system to prevent unauthorized access.
114- Escalate the incident to the security operations center (SOC) for further investigation and to determine if additional systems are affected.
115- Implement enhanced monitoring for DNS traffic to detect similar tunneling activities in the future, focusing on high-frequency queries to single domains.
116- Coordinate with IT and security teams to apply necessary patches and updates to the affected system to close any vulnerabilities exploited by the attacker."""
117[[rule.threat]]
118framework = "MITRE ATT&CK"
119[[rule.threat.technique]]
120id = "T1572"
121name = "Protocol Tunneling"
122reference = "https://attack.mitre.org/techniques/T1572/"
123
124
125[rule.threat.tactic]
126id = "TA0011"
127name = "Command and Control"
128reference = "https://attack.mitre.org/tactics/TA0011/"
Triage and analysis
Disclaimer: This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
Investigating DNS Tunneling
DNS tunneling exploits the DNS protocol to covertly transmit data between a compromised system and an attacker-controlled server. Adversaries use it for stealthy command-and-control, persistence, or data exfiltration by embedding data within DNS queries. The detection rule leverages machine learning to identify anomalies, such as an unusually high volume of DNS queries to a single domain, indicating potential tunneling activity.
Possible investigation steps
- Review the DNS query logs to identify the specific top-level domain generating the unusually high volume of queries. This can help pinpoint the potential source of tunneling activity.
- Analyze the source IP addresses associated with the DNS queries to determine if they originate from known or suspicious hosts within the network.
- Check for any recent changes or anomalies in the network traffic patterns related to the identified domain, which might indicate tunneling or exfiltration attempts.
- Investigate the history of the identified domain to assess its reputation and any known associations with malicious activities or threat actors.
- Correlate the DNS query activity with other security events or alerts in the network to identify any related suspicious behavior or indicators of compromise.
False positive analysis
- High volume of DNS queries from legitimate software updates or patch management systems can trigger false positives. Users should identify and whitelist domains associated with trusted update services.
- Content delivery networks (CDNs) often generate numerous DNS queries due to their distributed nature. Exclude known CDN domains from the analysis to reduce false positives.
- Internal network monitoring tools that rely on DNS for service discovery may cause an increase in DNS queries. Consider excluding these internal domains if they are verified as non-threatening.
- Some cloud services use DNS for load balancing and may result in high query volumes. Users should review and whitelist these domains if they are confirmed to be safe.
- Automated scripts or applications that frequently query DNS for legitimate purposes can be excluded by identifying their specific patterns and adding them to an exception list.
Response and remediation
- Isolate the affected system from the network to prevent further data exfiltration or command-and-control communication.
- Conduct a thorough analysis of DNS logs to identify the specific domain involved in the tunneling activity and block it at the network perimeter.
- Review and terminate any suspicious processes or services running on the compromised system that may be associated with the tunneling activity.
- Reset credentials and review access permissions for accounts that were active on the compromised system to prevent unauthorized access.
- Escalate the incident to the security operations center (SOC) for further investigation and to determine if additional systems are affected.
- Implement enhanced monitoring for DNS traffic to detect similar tunneling activities in the future, focusing on high-frequency queries to single domains.
- Coordinate with IT and security teams to apply necessary patches and updates to the affected system to close any vulnerabilities exploited by the attacker.
References
Related rules
- Unusual DNS Activity
- Unusual Web Request
- Unusual Web User Agent
- Anomalous Linux Compiler Activity
- Anomalous Process For a Windows Population