DNS Query with Padded Encoded Label
Identifies a DNS lookup on host or a DNS query tool such as dig or nslookup, for a name that contains a label ending in Base64 or Base32 padding. The equals sign is not valid in a hostname, so a padded label indicates that a program placed encoded data in the query name. Adversaries encode data into DNS labels to exfiltrate it or to communicate with a command and control server through the resolver.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2026/11/18"
3integration = ["endpoint"]
4maturity = "production"
5updated_date = "2026/11/18"
6min_stack_comments = "DNS for Linux support was introduced in 9.3.0"
7min_stack_version = "9.4.0"
8
9[rule]
10author = ["Elastic"]
11description = """
12Identifies a DNS lookup on host or a DNS query tool such as dig or nslookup, for a name that
13contains a label ending in Base64 or Base32 padding. The equals sign is not valid in a hostname, so a padded label
14indicates that a program placed encoded data in the query name. Adversaries encode data into DNS labels to
15exfiltrate it or to communicate with a command and control server through the resolver.
16"""
17from = "now-9m"
18index = ["logs-endpoint.events.network-*", "logs-endpoint.events.process-*"]
19language = "eql"
20license = "Elastic License v2"
21name = "DNS Query with Padded Encoded Label"
22note = """## Triage and analysis
23
24### Investigating DNS Query with Padded Encoded Label
25
26Base64 and Base32 output is padded with one or more `=` characters when the input length is not a multiple of the encoding block size. Hostnames cannot legitimately contain `=`, so a query such as `dGhpcyBpcyBhIHNlY3JldAo=.example.com` shows that a process built the name from encoded data. This is the simplest form of DNS exfiltration: the data leaves the host in the query name and reaches the authoritative server of the attacker-controlled domain even when the lookup fails. The rule matches any process, so it also covers programs that resolve the name themselves instead of calling `dig`, `nslookup` or `host`.
27
28### Possible investigation steps
29
30- Decode the padded label in `dns.question.name` to see what data was placed in the query, and note the parent domain that received it.
31- Review `process.executable`, `process.command_line` and the parent process to identify what issued the lookup. A system resolver such as `mDNSResponder` or `systemd-resolved` may appear when it forwards the query for another program.
32- Search process events on the host around the alert time for `dig`, `nslookup`, `host`, `curl` or a shell that pipes data through `base64`, `base32` or `xxd` into a hostname.
33- Check the reputation and registration date of the parent domain and whether other hosts queried it.
34- Look for further lookups from the same process with different encoded labels, which indicates that a larger payload was sent in chunks.
35
36### False positive analysis
37
38- No legitimate hostname contains `=`. Matches normally come from security testing, from scripts that build a URL from encoded data, or from a user who pastes an encoded string into a tool that resolves it.
39- If an internal tool is confirmed to generate such names, add an exception for its `process.executable` together with the parent domain.
40
41### Response and remediation
42
43- If the activity is not authorized, isolate the host and identify the data that was encoded into the query names.
44- Block the destination domain at the resolver and search DNS logs for other hosts that queried it.
45- Terminate the process that issued the lookups and remove the script or binary that started it.
46- Rotate any credentials or secrets found in the decoded labels and review the host for the access that preceded the exfiltration.
47"""
48references = [
49]
50risk_score = 47
51rule_id = "e44a185d-b6ed-4347-94f2-8756acfaa38f"
52setup = """## Setup
53
54This rule is designed for data generated by [Elastic Defend](https://www.elastic.co/security/endpoint-security), which provides native endpoint detection and response, along with event enrichments designed to work with our detection rules.
55
56Setup instructions: https://ela.st/install-elastic-defend
57"""
58severity = "medium"
59tags = [
60 "Domain: Endpoint",
61 "OS: Linux",
62 "OS: macOS",
63 "OS: Windows",
64 "Use Case: Threat Detection",
65 "Tactic: Exfiltration",
66 "Tactic: Command and Control",
67 "Data Source: Elastic Defend",
68 "Resources: Investigation Guide",
69 "Rule Type: Event Correlation (EQL)",
70 "Platform: Linux",
71 "Platform: Windows",
72 "Platform: macOS",
73]
74timestamp_override = "event.ingested"
75type = "eql"
76
77query = '''
78any where host.os.type in ("linux", "macos", "windows") and
79(
80 (
81 event.action in ("lookup_requested", "lookup_result") and
82 dns.question.name regex """.*[A-Za-z0-9+/]{2,}={1,6}\.[A-Za-z0-9\-]+.*""" and
83 not dns.question.name : "*.local"
84 ) or
85 (
86 event.category == "process" and event.type == "start" and event.action in ("exec", "start") and
87 process.name : ("dig", "nslookup", "nslookup.exe", "host", "drill") and
88 process.args regex """.*[A-Za-z0-9+/]{2,}={1,6}\.[A-Za-z0-9\-]+.*"""
89 )
90)
91'''
92
93
94[[rule.threat]]
95framework = "MITRE ATT&CK"
96[[rule.threat.technique]]
97id = "T1048"
98name = "Exfiltration Over Alternative Protocol"
99reference = "https://attack.mitre.org/techniques/T1048/"
100[[rule.threat.technique.subtechnique]]
101id = "T1048.003"
102name = "Exfiltration Over Unencrypted Non-C2 Protocol"
103reference = "https://attack.mitre.org/techniques/T1048/003/"
104
105
106
107[rule.threat.tactic]
108id = "TA0010"
109name = "Exfiltration"
110reference = "https://attack.mitre.org/tactics/TA0010/"
111[[rule.threat]]
112framework = "MITRE ATT&CK"
113[[rule.threat.technique]]
114id = "T1071"
115name = "Application Layer Protocol"
116reference = "https://attack.mitre.org/techniques/T1071/"
117[[rule.threat.technique.subtechnique]]
118id = "T1071.004"
119name = "DNS"
120reference = "https://attack.mitre.org/techniques/T1071/004/"
121
122
123[[rule.threat.technique]]
124id = "T1132"
125name = "Data Encoding"
126reference = "https://attack.mitre.org/techniques/T1132/"
127[[rule.threat.technique.subtechnique]]
128id = "T1132.001"
129name = "Standard Encoding"
130reference = "https://attack.mitre.org/techniques/T1132/001/"
131
132
133
134[rule.threat.tactic]
135id = "TA0011"
136name = "Command and Control"
137reference = "https://attack.mitre.org/tactics/TA0011/"
138
139[rule.alert_suppression]
140group_by = ["host.id", "process.executable"]
141missing_fields_strategy = "doNotSuppress"
142
143[rule.alert_suppression.duration]
144unit = "m"
145value = 15
Triage and analysis
Investigating DNS Query with Padded Encoded Label
Base64 and Base32 output is padded with one or more = characters when the input length is not a multiple of the encoding block size. Hostnames cannot legitimately contain =, so a query such as dGhpcyBpcyBhIHNlY3JldAo=.example.com shows that a process built the name from encoded data. This is the simplest form of DNS exfiltration: the data leaves the host in the query name and reaches the authoritative server of the attacker-controlled domain even when the lookup fails. The rule matches any process, so it also covers programs that resolve the name themselves instead of calling dig, nslookup or host.
Possible investigation steps
- Decode the padded label in
dns.question.nameto see what data was placed in the query, and note the parent domain that received it. - Review
process.executable,process.command_lineand the parent process to identify what issued the lookup. A system resolver such asmDNSResponderorsystemd-resolvedmay appear when it forwards the query for another program. - Search process events on the host around the alert time for
dig,nslookup,host,curlor a shell that pipes data throughbase64,base32orxxdinto a hostname. - Check the reputation and registration date of the parent domain and whether other hosts queried it.
- Look for further lookups from the same process with different encoded labels, which indicates that a larger payload was sent in chunks.
False positive analysis
- No legitimate hostname contains
=. Matches normally come from security testing, from scripts that build a URL from encoded data, or from a user who pastes an encoded string into a tool that resolves it. - If an internal tool is confirmed to generate such names, add an exception for its
process.executabletogether with the parent domain.
Response and remediation
- If the activity is not authorized, isolate the host and identify the data that was encoded into the query names.
- Block the destination domain at the resolver and search DNS logs for other hosts that queried it.
- Terminate the process that issued the lookups and remove the script or binary that started it.
- Rotate any credentials or secrets found in the decoded labels and review the host for the access that preceded the exfiltration.
Related rules
- Attempt to Establish Microsoft Dev Tunnel
- LLM-Based Curl Activity Triage
- LLM-Based Wget Activity Triage
- Network Connection to OAST Domain via Script Interpreter
- Potential Tunneling via AWS IoT Secure Tunneling Localproxy