DNS tunneling: spotting data hidden in DNS queries
DNS tunneling encodes data in query names to slip past filters that allow DNS. How it shows up in resolver logs or Zeek dns.log as long, high-entropy subdomains to one domain, and how to detect and block it.
Diagram
Tunneling in resolver logs
Step 1 of 4
Normal
Queries for a few well-known names.
www.example.com A login.microsoftonline.com A
The example on the open step is one illustration, or the fix you can paste into an application you own.
What this page is made of
3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.
Long, random labels
- What fails
- Encoded data produces long labels with high entropy.
- Who is affected
- Data on the host doing the queries.
- What you would notice
- Average query length above about 50 characters for one domain.
- What you change
- Alert on length and entropy per base domain.
Unusual record types
- What fails
- TXT and NULL records carry more data per response.
- Who is affected
- The same.
- What you would notice
- Many TXT queries from a workstation.
- What you change
- Baseline record types per host role.
Direct DNS
- What fails
- Hosts that talk to outside resolvers bypass your logs.
- Who is affected
- Visibility.
- What you would notice
- Port 53 traffic to external IPs.
- What you change
- Allow DNS only to your resolvers and log them.
Where to look
Resolver query logs (Windows DNS analytic logs, BIND query logs, Route 53 Resolver logs) and network sensors such as Zeek and Suricata all see the queries. Protective DNS services score domains too. The Suricata lessons in the tool library show DNS-focused rules.
Check yourself
Recognition and the fix. Nothing here is a procedure.
Which pattern suggests DNS tunneling?
Sibling techniques
Pages at the same depth, plus a lab and a glossary card for this one.
This page stands on its own. The lab and the glossary card are the next reading.