This is a single example, followed from beginning to end, conceptually. No tools, no commands. The aim is to understand why DNS is such a popular side door and what the defender sees at each step.
The setting
An invented architecture firm in Guwahati has a tight network. Staff laptops cannot connect to arbitrary websites; web traffic goes through a proxy with category filtering, and the firewall denies almost everything else outbound. One thing is allowed from every machine: DNS. Laptops must be able to resolve names, so they send queries to the internal resolver, and the resolver forwards what it cannot answer to the internet.
An intruder has landed on one laptop through a phishing email and found a folder of client drawings. A 2 MB archive is the prize. Direct upload is blocked. So the intruder looks at what is not blocked.
Step 1: the attacker owns a name
Before the intrusion, the attacker registers an ordinary domain, say one that looks harmless, and sets their own server as its authoritative name server. This is the quiet requirement of the whole technique. Whenever anyone in the world queries a name that ends in that domain, the question is eventually routed, via the normal DNS hierarchy, to the attacker’s server. The attacker does not need to reach the laptop, and the laptop does not need to reach the attacker. The resolver does the carrying.
Step 2: data becomes a hostname
The malware on the laptop splits the archive into chunks and encodes each chunk as text that is legal in a hostname, using something like base32 or hex, because DNS names allow only letters, digits and hyphens. It then asks for names such as a long encoded string followed by the attacker’s domain. The data is in the question itself.
The protocol limits shape the rest. Each label (the part between dots) can be at most 63 characters, and a complete name at most 253. Base32 carries 5 bits per character, so one maximum-length label holds about 39 bytes of real data. With a couple of labels, perhaps 100 bytes per query is a realistic ceiling once you leave room for sequence markers and the domain suffix. Then 2,000,000 bytes divided by 100 is about 20,000 queries.
Step 3: the journey
Each query goes laptop, internal resolver, root or TLD servers, and finally the attacker’s server, which simply records the name it was asked and stitches the chunks back together. Because every name is unique, caching never helps; every query travels all the way. The attacker’s server can reply with a tiny answer, perhaps a confirmation or even a short instruction for the malware, which turns this into a slow two-way channel. If the attacker sends 10 queries per second, 20,000 queries take roughly 2,000 seconds, a little over half an hour. Slower trickles would take longer but hide better.
This is also the basis of DNS tunnelling for command and control, where the same channel carries instructions inward. The firewall saw only allowed DNS traffic to the internal resolver. The proxy saw nothing. Neither control was bypassed; both were simply asked the wrong question.
Step 4: what the defender can see
The resolver logs show the evidence if someone looks. Signs that separate this from normal browsing:
- Volume against one parent domain. Tens of thousands of lookups to a single, previously unseen domain from one host, where normal usage touches each domain a handful of times.
- Unusual name shape. Very long labels, high randomness (entropy), no dictionary words, and a huge number of unique subdomains.
- Strange record types. A client that asks mostly for TXT or NULL records, which carry more data in the reply, rather than ordinary address records.
- Poor reputation. A newly registered domain, or one flagged by threat intelligence feeds.
- Regularity. Queries at near-constant intervals, which people do not produce.
Be aware of false positives. Some legitimate services also generate long, random-looking names: content delivery networks, certain antivirus cloud lookups, and some email security checks. A detection that fires on entropy alone will annoy analysts. Combining signals, such as high unique-subdomain count plus a young domain plus one noisy host, is far more reliable.
Step 5: closing the side door
The structural fix is to stop letting laptops use arbitrary resolvers, and to funnel all DNS through resolvers you operate, where you can log and filter. Block outbound DNS (port 53, and encrypted variants such as DNS over HTTPS to external providers) from everything except those resolvers, so the malware cannot go straight to the internet. Then add protective DNS filtering that blocks newly registered or known-bad domains, and send resolver logs to your SIEM with alerts on the patterns above. Rate limits per client help too.
There is a trade-off worth admitting. Encrypted DNS in browsers can move queries out of your visibility unless you manage it by policy. Organisations that rely on DNS monitoring need to decide deliberately whether to disable or redirect it.
Back to the 2 MB archive: with no controls it leaves in half an hour unnoticed. With resolver logging, a single noisy host and a new domain trigger an alert in minutes, and the leak is capped at a few hundred kilobytes. Exfiltration is rarely stopped by one wall. It is slowed, observed and then cut.
Figures and names in the examples are illustrative.
Leave a Reply