DNS tunnelling and exfiltration – how it works and how to detect it – Secured Me

DNS tunnelling and exfiltration – how it works and how to detect it

Why DNS is a favourite covert channel for attackers, how DNS tunnelling actually works, and the detections that catch it without drowning in noise.

DNS is the protocol every network forgets to inspect. It is small, ubiquitous, almost always allowed outbound, and rarely proxied or logged in detail. That makes it the ideal covert channel: command-and-control traffic, data exfiltration, and beaconing can all be hidden inside what looks like ordinary name resolution. Tools like dnscat2, iodine, DNSExfiltrator, and frameworks like Cobalt Strike's DNS transport make this trivial. Understanding how DNS tunnelling works, and what it looks like when it does, is one of the higher-leverage gaps to close in many networks.

How DNS tunnelling works

DNS is a request-response protocol with a flexible payload. The query name itself can be up to 253 characters (split into labels of up to 63), and DNS responses can carry text in TXT, CNAME, NULL, and other record types. An attacker who owns a domain (say attacker.example) can encode arbitrary data as part of DNS messages:

Even with no full tunnel, DNS exfiltration is straightforward: chunk a file into base32 or hex, send each chunk as a subdomain query, and reassemble at the attacker's authoritative server. A few hundred queries per minute can move megabytes per hour out of a network that "blocks outbound traffic".

The protocol has helpful properties for attackers:

Real-world abuse patterns

DNS abuse is not just exotic APT tradecraft.

The common thread: DNS traffic is unusual when you look at it closely, but most networks never do.

Signals that DNS is being abused

DNS tunnelling tends to leave statistical fingerprints that ordinary DNS does not.

Any one of these in isolation has false positives. Combinations rarely do.

Detection strategies that work in practice

The goal is to get high-fidelity alerts without drowning analysts.

Hardening: making DNS less useful to attackers

Detection alone is reactive. A few preventive measures reduce the value of DNS as a channel.

DNS will always be a useful covert channel because it has to work everywhere and at scale. You will not eliminate the risk, but with centralised logging, sensible baselines, control over DoH, and process-level context from endpoint telemetry, DNS tunnelling and exfiltration stop being invisible and start being just another detection — usually one of the higher-fidelity ones you have.