What is DNS cache poisoning, and why does one forged answer accepted by a recursive resolver affect many users?
answer
- shared cache, many clients
- false record stored as genuine
- lasts as long as its TTL
- forgery must match the outstanding query
basics
~20 sDNS cache poisoning is getting a recursive resolver to accept and store a forged answer. Because the resolver serves its cache to every client, one accepted forgery misdirects all of them until the record's TTL runs out.
solid answer
~50 sA recursive resolver answers its clients from one shared cache. **Cache poisoning** means getting a false record into that cache - say an `A` record for `www.example.com` pointing at 192.0.2.66 instead of the real server. The resolver then hands the false record to every client that asks, for as long as the TTL the forger chose, so one success misdirects a whole network rather than one machine. Over classic UDP a resolver accepts a response only when it matches the outstanding query - the addresses, its own source port, the 16-bit query ID and the question name, class and type (RFC 5452 section 9.1) - so an attacker who cannot see the query has to guess those values and arrive before the genuine answer. Plain DNS carries no signature to check, which is why a well-guessed forgery is indistinguishable from the truth; DNSSEC validation is what adds that check.
go deeper
Explain that a recursive resolver shares one cache among all its clients, so a single stored forgery misleads everyone who asks for that name until the TTL expires.
Name the fields a UDP response must match before a resolver accepts it - addresses, source port, query ID and question - and why an off-path attacker has to guess some of them.
Separate poisoning a cache from a compromised registrar or authoritative server, and say which defence addresses each: randomisation raises guessing cost, only DNSSEC validation proves origin.
Weigh how much of your estate still depends on unsigned zones and plain-text protocols, where a poisoned resolver translates directly into redirected traffic rather than a certificate error.
## What a recursive resolver's cache is When a laptop looks up `www.example.com`, it usually asks a **recursive resolver** run by its network, its ISP or a service it chose. The resolver walks the DNS hierarchy on the laptop's behalf, gets the answer from the zone's **authoritative server**, and keeps a copy in its **cache** for the number of seconds the record's **TTL** allows. The next client that asks for the same name within that time gets the cached copy without any new query leaving the resolver. That sharing is the whole point of the cache - it makes DNS fast and keeps load off authoritative servers - and it is also why poisoning it is so valuable. ## What poisoning means **DNS cache poisoning** is causing a resolver to store a record that the zone's owner never published. Typical goals: - point `www.example.com` at an address the attacker controls, such as 192.0.2.66; - point the zone's `MX` target elsewhere, so mail is delivered to the attacker; - replace the zone's `NS` records, so every name under the zone is answered by the attacker's server. The forged record is served exactly like a real one. Nothing in a plain DNS answer tells the client, or the resolver, that it was forged. ## Why the blast radius is large | Property | Effect of one accepted forgery | |---|---| | Shared cache | Every client of that resolver asking for the name receives it | | TTL chosen by the forger | It can stay cached for as long as the forger's TTL and the resolver's own maximum allow | | Downstream caches | Forwarders and stub caches that fetched from the poisoned resolver hold their own copies | | Zone-wide records | A forged `NS` record hijacks every name under the zone, not one host | Compare that with forging an answer to a single laptop on a café network: one victim, one lookup. Poisoning the resolver turns one success into thousands of misdirected connections. There is a limit worth stating precisely. Redirecting a name does not hand the attacker a valid TLS certificate for it, so a client that checks the server's certificate against the name it asked for will see an error rather than a silent takeover. Plain-text protocols, and users who click through warnings, get no such protection. ## How a forged answer gets accepted Over classic DNS on UDP there is no connection, so the resolver decides whether a datagram is the reply it is waiting for by comparing fields. RFC 5452 section 9.1 says a resolver MUST match all of these: 1. the response's source address against the address the query was sent to; 2. the response's destination address against the query's source address; 3. the response's destination port against the query's source port; 4. the 16-bit query ID; 5. the query name; 6. the query class and type. A mismatch on any one of them makes the response invalid. An **on-path** attacker who can see the query copies these values and only has to answer first. An **off-path** attacker cannot see the query, so it must guess the unpredictable parts - the ID and the source port - and land its guess inside the short window before the genuine answer arrives. Making those values unpredictable is the resolver's first line of defence. ## What protects against it | Defence | What it does | What it does not do | |---|---|---| | Random query ID across 0-65535 | Makes a blind forger guess 16 bits | Not enough on its own against a forger who can retry quickly | | Random source port per query (RFC 5452) | Multiplies the guessing space by the number of ports in use | Is undone by a device in front that rewrites ports predictably | | DNSSEC validation | Rejects records whose signatures do not verify | Protects only zones that are signed | | Encrypted stub-to-resolver transport (DoT, DoH, DoQ) | Stops forgery on the client-to-resolver hop | Leaves the resolver's own onward queries as exposed as before | The randomisation defences raise the cost of guessing; only signature validation proves where the data came from. ## How this differs from other ways names go wrong Poisoning corrupts a cache while the real zone stays correct. A hijacked registrar account or a compromised authoritative server publishes the wrong data at the source, and every resolver fetches it faithfully - no cache was poisoned, and no randomisation helps. Keeping the two apart is what lets you pick the right defence.
- Why does an HTTPS site still offer some protection when its name has been poisoned in a resolver?The poisoned record only changes which address the client connects to. The client still checks the server's certificate against the name it asked for, so an attacker without a valid certificate for that name triggers a certificate error instead of a silent takeover. Plain-text protocols get no such check, and users who click through the warning lose it.
- Does a longer TTL on the genuine record make classic cache poisoning harder or easier?Harder, in the classic attack. While the genuine record is cached the resolver sends no query, so a blind forger only gets a new window when the TTL expires - RFC 5452 section 7 models the chance per window and notes a short TTL makes spoofing far more viable. Techniques that query uncached names sidestep this brake entirely.
A receptionist who writes down one caller's claim that the office has moved, then gives the new address to every visitor until the note is thrown away, has been poisoned once and misleads everyone.
saying these in an interview costs you the question
- Poisoning only affects the one client whose query was forged.
- Cache poisoning requires breaking into the zone's authoritative server.
- Encrypting DNS between laptop and resolver makes cache poisoning impossible.
- A resolver accepts any UDP reply that arrives from port 53.
- The DNS TTL limits how many routers a forged record can cross.