DNS tunnelling
termKept in this browser · My desk
Carrying data, commands or a whole IP connection inside DNS queries and answers, with the payload encoded in the names asked for and in the records returned.
It works because almost every network must resolve names and its resolvers forward unknown names to whichever server is authoritative, which the attacker controls. Tools such as OzymanDNS (2004) and iodine (2006) were written partly to get past paid wireless captive portals; malware such as DNSMessenger (2017) and SUNBURST (2020) used DNS for command and control.
What it is. A Domain Name System (DNS) tunnel uses name resolution itself as the transport. The client encodes data into the labels of a query name under a domain the attacker controls; the organization's recursive resolver cannot answer such a name from its cache, so it forwards the query to whichever server is authoritative for the domain, which is the attacker's, and that server decodes the labels. Answers carry data the other way: an address (A) record can hold a command code in its four octets, and text (TXT), NULL, canonical name (CNAME) or mail exchange (MX) records can carry encoded files. Unit 42 of Palo Alto Networks names the tunnel's weakness: DNS normally travels over the User Datagram Protocol (UDP), which neither retransmits nor orders, so every tool adds its own sequencing, and a large transfer takes long and draws attention. MITRE ATT&CK (Adversarial Tactics, Techniques, and Common Knowledge) files it under T1071.004 (DNS for command and control) and T1572 (protocol tunnelling).
Where it came from. Greg Farnham's 2013 paper for a GIAC (Global Information Assurance Certification) intrusion-analysis certification dates the first known public discussion to a post by Oskar Pearson on the Bugtraq mailing list in April 1998, and notes that many tools were written to get past the captive portals of paid wireless networks, which block web traffic until payment but let DNS through. Unit 42 traces the tools: OzymanDNS, written in Perl by Dan Kaminsky in 2004, which carried Secure Shell (SSH) sessions with Base32-encoded requests and Base64-encoded TXT responses; DNScat; dns2tcp by Olivier Dembour and Nicolas Collignon; tcp-over-dns (2008); and iodine, first released in 2006 by Bjorn Andersson and Erik Ekman.
How much fits. Request for Comments (RFC) 1035 (November 1987) limits a label to 63 octets and a name to 255, counting every length octet, and compares names without regard to case, so a tunnel that must survive every resolver cannot use letter case to carry bits; hence Base32, which RFC 4648 defines for data that must be case insensitive, at five bits per character. Under t.example.com the fixed labels cost 15 octets in wire format, leaving 240: three labels of 63 characters and one of 47, that is 236 characters or 1,180 bits, about 147 bytes per query before the tool's own sequence numbers, which is why practical figures run at roughly 100 to 150 bytes upstream. One mebibyte needs about 7,134 queries, each for a name never seen before. The incident team (CAIS) of Brazil's national research and education network (RNP) did the same sum for OzymanDNS at GTS-8, the eighth meeting of the network security working group (GTS), in December 2006: three labels of 60 characters, 900 bits, about 112 bytes. iodine's documentation, which prefers NULL and PRIVATE records downstream, reports 43.6 to 74.2 kilobits per second upstream through ordinary resolvers and 131.0 to 585.4 downstream: tens of kilobits per second, enough to move files.
Cases. Edmund Brumaghin and Colin Grady of Cisco Talos described on 2 March 2017 DNSMessenger, a remote access tool delivered by a malicious Word document and run as several stages of PowerShell, some of them fileless, that used DNS TXT queries and responses as a two-way command channel, an approach Talos called extremely uncommon and evasive. MITRE lists BONDUPDATER, OilRig, Denis and Cobalt Strike among the users of DNS for command and control, and Kaspersky reported in 2017 that a few simple intrusion-detection rules for long or oddly formed names, run over the stream of samples it receives, found several previously unknown backdoors using DNS tunnels. SUNBURST, the backdoor inserted into SolarWinds Orion and disclosed in December 2020, resolved subdomains of avsvmcloud[.]com built by a domain generation algorithm (DGA) that joined a victim identifier to a reversible encoding of the victim's internal domain name; CNAME answers pointed it to the real command server, and FireEye assessed that the encoded names let the attackers choose their victims.
Detection. Traffic analysis beats payload signatures: count unique names per registered domain per time window, query lengths, record types and which process sent the query. Farnham separates payload analysis (the length, characters and record type of one request) from traffic analysis (volume, host names per domain, history): counting unique fully qualified names per root domain in ten-minute windows, every domain on his network stayed below about 300, while a DNScat session moving a 122-kilobyte file stood far above; the one legitimate exception was a file-reputation service. Special Publication (SP) 800-81r3 of the National Institute of Standards and Technology (NIST), published in March 2026, lists the same signs: a larger than normal volume of queries from a host, unusual or changing query patterns, odd names detected by measuring their entropy, and names in known malicious domains; it adds that signatures catch well-known tools but customized exfiltration tools must also be considered. MITRE's analytics add the best single clue: queries sent by processes that are neither browsers nor system services. Entropy alone is weak: the label downloadandupdates scores 3.24 bits per character and the Base32 label jbswy3dpeb3w64tmmq 3.73, only half a bit more.
Prevention and pitfalls. Make every client use the organization's resolvers, block direct DNS and unknown encrypted resolvers, and apply response policy there; NIST treats a protective resolver as a policy enforcement point against misuse of the protocol, naming exfiltration over DNS. DNS over HTTPS (the Hypertext Transfer Protocol Secure), or DoH, standardized in RFC 8484 (October 2018) by Hoffman of ICANN (the Internet Corporation for Assigned Names and Numbers) and McManus of Mozilla, maps each query and response into an HTTPS exchange of the media type application/dns-message, so a tunnel through a public DoH resolver looks like web browsing, and NIST notes that passive network tools are blind to encrypted DNS unless they act as a proxy or forwarder. DoH therefore hides tunnels from the network unless the organization runs or inspects the resolver. Before thresholds start alarming, list the legitimate services that also generate unique names, such as content delivery and file reputation.
Brazilian research. At the Brazilian Symposium on Cybersecurity (SBSeg) of 2023, Luz and colleagues, of the Federal University of Pernambuco (UFPE) and Tempest Security Intelligence, proposed a detector for DNS tunnels based on self-organizing maps, with an F1-score of 0.9460 on public datasets; at SBSeg 2026 Borges and Miani of the Federal University of Uberlândia (UFU) published the datasets UFU-Do53-EXF (5,351,064 samples of conventional DNS on port 53) and UFU-DoH-EXF (1,048,575 flows on port 443 of the Transmission Control Protocol, TCP). Its neighbours are ICMP (Internet Control Message Protocol) tunnelling, the wider family of covert channels, beaconing and exfiltration.
Also known as: dns tunneling, dns tunnel, ip over dns, tunelamento dns, tunelamento de dns
Sources
- Greg Farnham, Detecting DNS Tunneling, GIAC Gold paper, SANS Institute, accepted 25 February 2013 (read 2026-11-23): first public discussion by Oskar Pearson on Bugtraq, April 1998; tools written to bypass captive portals; payload and traffic analysis; unique FQDNs per root domain, about 300 per ten minutes as a threshold
- Alex Hinchliffe, Palo Alto Networks Unit 42, DNS Tunneling: how DNS can be (ab)used by malicious actors, 15 March 2019 (read 2026-11-23): data upstream in query names, downstream in A and TXT answers; OzymanDNS (Kaminsky, 2004), DNScat, dns2tcp, iodine (2006); defences
- iodine README (read 2026-11-23): tunnels IPv4 data through a DNS server; Base32 to Base128 upstream; NULL, PRIVATE, TXT, SRV, MX, CNAME and A records; measured 43.6 to 74.2 kbit/s upstream through ordinary resolvers
- P. Mockapetris, RFC 1035, November 1987 (read 2026-11-23): labels of 63 octets or less, names of 255 octets or less counting length octets, case-insensitive comparison
- MITRE ATT&CK, Application Layer Protocol: DNS, T1071.004, version 1.4, last modified 3 September 2026 (read 2026-11-23): DNS tunnelling for command and control; procedure examples; analytics for long or frequent subdomains, volume, encoded patterns and non-browser processes
- Ivo de Carvalho Peixinho, RNP, CAIS, Covert channels: o que são, o que fazem e como se prevenir contra eles, GTS-8, December 2006 (read 2026-11-23): IP over DNS with NSTX, OzymanDNS and DNScat; 180 Base32 characters, about 112 bytes per query; blocking TXT and the SPF problem
- NIST SP 800-81r3, Secure Domain Name System (DNS) Deployment Guide, Scott Rose, Cricket Liu and Ross Gibson, March 2026 (read 2026-11-23): section 4.2.4: controls to detect and block applications tunnelling data in DNS; signs are a larger than normal query volume from a host, unusual or changing query patterns, odd QNAMEs found by entropy measurement and known malicious domains; customized exfiltration tools beyond the well-known ones; passive tools blind to encrypted DNS unless they act as proxy or forwarder; protective DNS as a policy enforcement point against exfiltration over DNS
- P. Hoffman (ICANN) and P. McManus (Mozilla), RFC 8484, DNS Queries over HTTPS (DoH), Standards Track, October 2018 (read 2026-11-23): each DNS query-response pair is mapped into an HTTP exchange; the application/dns-message media type; GET requests carry the query encoded with base64url
- S. Josefsson, RFC 4648, The Base16, Base32, and Base64 Data Encodings, October 2006 (read 2026-11-23): Base32 represents arbitrary octets in a form that needs to be case insensitive, five bits per character from a 32-character alphabet
- Edmund Brumaghin and Colin Grady, Cisco Talos, Covert Channels and Poor Decisions: The Tale of DNSMessenger, 2 March 2017 (read 2026-11-23): a remote access tool using DNS TXT record queries and responses as a bidirectional command-and-control channel; multiple PowerShell stages, some fileless; 'extremely uncommon and evasive'
- Alexey Shulmin and Evgeniya Krylova, Kaspersky, Steganography in contemporary cyberattacks, Securelist, 3 August 2017 (read 2026-11-23): DNS tunnel traffic of Backdoor.Win32.Denis with long encoded names; intrusion-detection rules for long or anomalous names run over Kaspersky's sample stream found several previously unknown backdoors using DNS tunnels
- FireEye (now Mandiant, Google Cloud Threat Intelligence), Highly Evasive Attacker Leverages SolarWinds Supply Chain to Compromise Multiple Global Victims With SUNBURST Backdoor, 13 December 2020 (read 2026-11-23): a DGA builds subdomains of avsvmcloud[.]com from a victim userId and a reversible encoding of the local machine's domain name; CNAME responses point to the C2 domain; the DGA subdomain likely used to control targeting
- MITRE ATT&CK, Protocol Tunneling, T1572, last modified 3 September 2026 (read 2026-11-23): explicitly encapsulating one protocol within another to avoid detection or filtering or to reach otherwise unreachable systems; DNS over HTTPS as a way to hide resolution of C2 infrastructure
- Júlio F. Luz, Paulo Freitas de Araujo-Filho, Henrique F. Arcoverde and Divanilson R. Campelo, Unsupervised SOM-Based Intrusion Detection System for DNS Tunneling Attacks, SBSeg 2023 (read 2026-11-23): an unsupervised detector built on self-organizing maps; F1-score of 0.9460 on public datasets
- Cristiano L. M. Borges and Rodrigo S. Miani, UFU-Do53-EXF e UFU-DoH-EXF: conjuntos de dados para detecção de exfiltração via DNS, SBSeg 2026 (read 2026-11-23): two datasets for DNS exfiltration detection: 5,351,064 samples of conventional DNS on port 53 and 1,048,575 DNS over HTTPS flows on TCP port 443