Notes
DNS in one picture
A quick picture of DNS. Your browser asks a resolver, usually run by your network or a public provider. The resolver walks down from the root servers to the top-level domain to the domain's own authoritative server, gets the answer, and caches it for a time set by the record. In classic DNS all of this travels as plain text, mostly over UDP, with no signature. An answer is accepted if it looks like it matches the question.
- browser asks a resolver
- the resolver asks the root, the TLD, then the domain's authoritative server
- the answer is cached for its TTL
- classic DNS: plain text, UDP, no signature on the answer
Attack 1 · Spoofing
The first attack is local spoofing. An attacker who is already in the middle, through ARP spoofing or a fake access point, sees your DNS question and simply answers it first, with their own server's address. Your browser connects there. The name in the address bar is still the right one, which is what makes this dangerous. Only the certificate check stands between the user and a perfect copy of the real site.
- the attacker is already in the middle (last episode)
- they see the question and reply before the real server
- the browser gets the attacker's address
- the name in the address bar is still correct
Attack 2 · Poisoning
The second attack scales that up. In cache poisoning the attacker targets the resolver itself, racing to answer the resolver's question before the real authoritative server does. If a forged answer is accepted, the resolver caches it, and every user of that resolver is sent to the wrong address until the record expires. A famous flaw found in two thousand eight made this practical; randomised source ports and query identifiers made the race far harder, but not impossible.
- the attacker races to answer the resolver's own question
- if a forged answer is accepted it is cached
- every user of that resolver gets the bad address until the TTL expires
- randomised ports and IDs made the race much harder
Attack 3 · Hijack
The third attack skips protocol tricks entirely. The attacker takes over the company's account at its registrar or DNS provider, with a phished or reused password, and changes the real records. Now the genuine, authoritative answer points to the attacker, for everyone in the world. With control of the domain they can even obtain a valid certificate, so there is no browser warning at all. This has happened to banks and to cryptocurrency sites.
- the attacker phishes or guesses the registrar or DNS account
- changes the name servers or the records themselves
- now the *real* answer points to them, worldwide
- they can even get a valid certificate for the domain
Attack 4 · Takeover
The fourth attack is the one teams cause themselves. A subdomain is pointed at a cloud service, such as a storage bucket or a hosted app. Later the team deletes the cloud resource and forgets the DNS record. That record is now dangling. An attacker claims the same resource name at the cloud provider, and is suddenly serving their content on your subdomain, with your cookies in reach. The fix is process: delete the record with the resource, and audit your DNS regularly.
- promo.shop.example CNAME points to a cloud service
- the team deletes the cloud resource, forgets the record
- an attacker registers the same resource name
- they now serve content on your subdomain
- fix: delete DNS with the resource; audit records
DNS as a tunnel
DNS is also abused as a carrier. Almost every network lets DNS out, so malware encodes stolen data inside the names of DNS queries and sends them to a server the attacker controls. That is DNS tunneling, used for command and control and for theft. The signs are long, random-looking subdomains and unusual query volume. Attackers also register look-alike domains, one letter off, for phishing. Both are found by watching DNS logs, which most companies never read.
- DNS tunneling: data encoded in query names, sent to the attacker's DNS server
- used for command and control and data theft
- typosquatting: shopexample.co look-alike domains
- signs: long random subdomains, huge query volume
Defense · DNSSEC
Now the defenses. DNSSEC adds signatures. The domain signs its records with a private key, and resolvers verify each signature up a chain of trust that ends at the root. A forged answer has no valid signature and is rejected, which defeats spoofing and cache poisoning. Know its limits, because interviews ask. DNSSEC proves an answer is authentic. It does not encrypt the lookup, and it does not help if the attacker controls your registrar account.
- the zone signs its records with a private key
- resolvers verify the signature up a chain of trust to the root
- a forged answer has no valid signature: rejected
- proves authenticity, does not encrypt, does not stop a registrar hijack
More defenses
The rest of the kit. DNS over HTTPS or DNS over TLS encrypts the lookup, so nobody on the path can read or change it. Protect the registrar and DNS provider accounts like crown jewels: multi-factor login, a registry lock, very few administrators, and alerts on every change. Publish CAA records to limit which certificate authorities may issue for your domain, and watch certificate transparency logs for certificates you did not request. And log DNS queries, then actually review them.
- DNS over HTTPS or TLS: nobody on the path can read or change the lookup
- registrar: MFA, registry lock, few admins, alerts on change
- CAA records: which CAs may issue for your domain
- monitor certificate logs
- log and review DNS queries
Common mistakes
Mistakes. A registrar account with a shared password and no multi-factor login, when it controls the whole company's traffic. Dangling records left behind when cloud resources are deleted. A DNS zone that no team owns, full of entries nobody can explain. No DNS logs and no review. Believing DNSSEC encrypts anything. And never looking at certificate transparency logs, where a hijack often shows up first.
- registrar login with a shared password and no MFA
- dangling records after deleting cloud resources
- nobody owns the DNS zone
- no DNS logs, no review
- thinking DNSSEC encrypts
- ignoring certificate logs
Say it like this
In the interview: DNS can be attacked with spoofed answers on the local network, cache poisoning at the resolver, hijacking the registrar account, subdomain takeover through dangling records, and tunneling for data theft. I defend it with DNSSEC and encrypted DNS, a locked registrar account with multi-factor login and change alerts, removing DNS records together with the resources they point to, CAA records, and monitoring of DNS queries and certificate transparency logs.
- "Spoofed answers on the LAN, cache poisoning at resolvers, registrar hijack, subdomain
- takeover, and tunneling. I use
- DNSSEC and encrypted DNS, lock
- the registrar with MFA, remove
- dangling records, add CAA, and monitor DNS and cert logs."