DNS tunneling

This text was analyzed, written and translated by artificial intelligence (AI). It may contain mistakes.How we use AI

A technique that hides other data inside DNS Domain Name System The internet's directory that links domain names to computer addresses. Full definition of DNS queries and answers. Because most networks let DNS traffic pass, malware Harmful software, often spread or controlled using domain names. Full definition of malware can use it to receive commands or to smuggle stolen data out. The traffic goes to a domain and a name server A server that holds a domain's DNS records and answers lookups. Full definition of name server run by the attacker. Blocking that domain does not reliably stop it, because attackers switch domains.

category
Security and abuse

Updated on 4 min read

DNS tunneling hides other data inside the ordinary questions and answers of the DNS, the system that turns domain name A readable internet name made of labels separated by dots. Full definition of domain name into addresses. Malicious software uses it to receive orders or to send stolen data out, because most networks let DNS traffic through. It is a technique, not a kind of domain, and networks can spot and limit it.

What DNS tunneling is

Tunneling means carrying one protocol inside another, so that hidden traffic blends in with traffic the network expects. In DNS tunneling the outer layer is DNS: commands, their results or stolen files travel inside lookups between an infected device and systems the attacker controls.

MITRE ATT&CK, a public knowledge base of attacker techniques, files it in two places as of Enterprise ATT&CK 19.2 (October 2026): under command and control (technique T1071.004) and under exfiltration of data over unencrypted protocols (T1048.003).

Tunneling usually serves malware and botnet A network of infected computers controlled by an attacker. Full definition of botnet, which are DNS abuse Harmful use of domains, defined in ICANN contracts as five specific threats. Full definition of DNS abuse under ICANN Internet Corporation for Assigned Names and Numbers The nonprofit that coordinates the global DNS and gTLD policy. Full definition of ICANN’s contracts with registrar A company that registers domain names for customers with the registry. Full definition of registrar (the RAA Registrar Accreditation Agreement The contract between ICANN and each accredited registrar. Full definition of RAA) and registry The central database and system of a top-level domain, or loosely the organization that runs it. Full definition of registry (the Registry Agreement The contract between ICANN and a gTLD registry operator. Full definition of Registry Agreement), as ICANN’s advisory of 5 February 2024 sets out. As of October 2026, tunneling itself is not one of the five named categories: malware, botnets, phishing Impersonating a trusted party to steal data, often with look-alike domains. Full definition of phishing, pharming Redirecting users to fake sites even when they type the right domain. Full definition of pharming, and spam Unwanted bulk messages, which count as DNS abuse only when used to deliver other abuse. Full definition of spam used to deliver the other four.

How data can hide in DNS queries

Data going out

The malware encodes the data, for example in base64 or base32. DNS names are case insensitive (RFC Request for Comments A numbered document in the series recording the internet's technical standards and practices. Full definition of RFC 4343), and RFC 4648 describes base32 as designed for exactly that situation.

The encoded text becomes the label One dot-separated part of a domain name, up to 63 characters long. Full definition of label of a name under a domain the attacker runs. RFC 1035 limits a label to 63 octets and a whole name to 255, so data travels in many small pieces, one query at a time.

The query reaches the attacker because DNS works as designed. The device asks its usual resolver The DNS server that looks up domain names on behalf of users. Full definition of resolver, which asks the authoritative name server for that domain. RFC 9076 notes that public authoritative server A DNS server that gives the official answers for a domain or zone. Full definition of authoritative server answer queries for their zone without checking who asks. If the attacker runs that server, it receives the labels.

Commands coming in

Orders come back inside the answers. MITRE names TXT and A record A DNS record that points a domain name to an IPv4 address. Full definition of A record as examples; RFC 1035 defines TXT record Text record A DNS record holding text, often for domain verification and email security. Full definition of TXT record to hold descriptive text.

A worked example

Malware on an office laptop sends a file to whoever operates example.net:

  1. It encodes a piece of the file as a label of at most 63 characters.
  2. It looks up that label under t.example.net.
  3. The office resolver forwards the question to the name server for example.net, run by the operator.
  4. That server records the label and replies with a TXT record containing the next command.
  5. The malware repeats this for each piece.

Why attackers use it

MITRE gives several reasons:

  • DNS is present in almost every network and may be allowed even before a device has logged in to it.
  • The traffic looks like normal lookups, and DNS packets have many fields where data can hide.
  • It can carry traffic that network devices would otherwise filter.
  • Beacons that check in only now and then are hard to detect among normal queries.
  • Queries can be wrapped in encrypted HTTPS Hypertext Transfer Protocol Secure The encrypted version of the protocol web browsers use to load pages. Full definition of HTTPS as DoH DNS over HTTPS DNS lookups carried inside encrypted HTTPS connections. Full definition of DoH (DoH).

DoH itself is a privacy protection: RFC 8484 designed it to stop devices on the network path from interfering with DNS. A side effect is that a local network may not see those queries.

How it is detected and blocked

MITRE’s detection strategy DET0400 looks for:

  • a high volume of DNS queries from one client;
  • unusually long subdomain A name created under a registered domain, like shop.example.com. Full definition of subdomain, and labels that look encoded rather than readable;
  • queries to infrastructure known to be malicious;
  • DNS queries from programs that do not normally make them, such as scripting tools.

The controls MITRE describes include:

  • making every device use the organization’s own resolvers, and letting only those servers send DNS traffic out; a recursive resolver sees all queries passing through it (RFC 9076);
  • filtering queries to unknown or known bad domains, which is what protective DNS A DNS resolver service that blocks lookups of domains known to be harmful. Full definition of protective DNS does;
  • intrusion detection and prevention systems with signatures for specific malware;
  • data loss prevention tools that spot sensitive data leaving over unencrypted protocols.

These controls have limits. Blocking a known domain helps, but attackers can switch domains, and malware using a domain generation algorithm (DGA domain generation algorithm Malware code that generates many domain names so infected machines can find their controller. Full definition of DGA) may try thousands. MITRE notes that a local sinkhole A safe server that a malicious domain is redirected to, cutting off the attackers. Full definition of sinkhole can help against such malware at a reduced cost. Encrypted DNS sent to an outside resolver can bypass local inspection. Which controls suit a network is a question for its operators and security advisers.

Legitimate uses of the technique

Putting data into a query name and getting data back in the answer is not malicious in itself. DNS-based blocklist A published list of domains or IP addresses to block for spam, phishing or malware. Full definition of blocklist (DNSBLs) work this way, and RFC 5782 of February 2010 calls DNS the de facto standard method of distributing them.

In the RFC’s example, to check whether the IP Internet Protocol The internet's basic rules for sending data, using numeric addresses for every connected device. Full definition of IP 192.0.2.99 is on a list at bad.example.com, a mail server looks up 99.2.0.192.bad.example.com. A listed address has an A record there, and should have a TXT record giving the reason.

Since April 2024, RFC 9567 has also standardized DNS error reporting: a resolver that fails to resolve or validate a name can report it by encoding the error in the name of a TXT query sent to a monitoring agent named by the domain’s authoritative server. As the RFC puts it, the very act of sending the query is to report the error.

Tunneling tools are publicly available; MITRE’s detection guidance names iodine and dnscat2. What makes a tunnel abusive is its purpose: hiding commands or stolen data from the network’s owner.

Sources