DNS Poisoning (Cache Poisoning), Explained
If you are reading this, you have probably seen "DNS poisoning" or "DNS spoofing" in network courses and in stories where a famous website suddenly sends people to the wrong place, and you want to know how a false answer ends up in the system and what stops it.
By the end you will be able to explain how DNS answers are accepted and cached, describe the classic cache-poisoning attack and why it worked, explain the two big milestones (the Kaminsky flaw of 2008 and the SAD DNS research of 2020), tell DNS poisoning from DNS hijacking, check whether your own resolver validates DNSSEC, and list the defences. It builds on the DNS section of Computer and Networking Basics and on Spoofing.
1. A quick recap: how a DNS lookup is trusted
When you open example.com, your device asks a recursive resolver (usually run by your ISP or a public service). If the resolver does not already know the answer, it asks the DNS servers responsible for the name, ending with the authoritative server for the domain. It then:
- Returns the answer to you, and
- Caches it, for as long as the record's TTL (time to live) allows, so the next person to ask gets the answer instantly.
That cache is why DNS is fast, and it is also why DNS poisoning is dangerous: one false entry in a resolver's cache is served to everyone who uses that resolver until the TTL runs out. Wikipedia describes this: poisoning a single DNS server can affect the users it serves directly and those served indirectly by downstream servers.
DNS normally runs over UDP, where nothing in the transport proves who sent a reply. The only thing a resolver can check is whether the reply looks like the answer to the question it asked.
2. What DNS cache poisoning is
Wikipedia defines DNS spoofing, also called DNS cache poisoning, as "a form of computer security hacking in which corrupt Domain Name System data is introduced into the DNS resolver's cache, causing the name server to return an incorrect result record, e.g. an IP address."
The CERT Coordination Center, which published the notice on the 2008 flaw, spells out the impact: successful cache poisoning lets an attacker redirect web traffic, email and network data to systems the attacker controls (CERT VU#800113).
A picture: a receptionist (the resolver) writes the answers to common questions on a sticky note by the phone. A prankster who can slip a fake note in at the right moment gets every later caller sent to the wrong room.
How a resolver decides a reply is real
RFC 5452 lists what a reply must match to be accepted: the question must match one waiting for an answer, the ID field must match, the reply must come from the same network address the query was sent to, and it must arrive at the same address and port the query came from. "In general, the first response matching these four conditions is accepted."
So the attacker's job is to get a forged reply to the resolver that matches all of those, before the real answer arrives. The attacker is "off-path": they cannot see the traffic, so they must guess what they cannot see.
What the attacker must guess
| Value | Size | Notes |
|---|---|---|
| Query ID | 16 bits | RFC 5452 says that if all bits are used, guessing it takes about 32,768 attempts on average |
| Source port of the query | up to 16 bits | If it never changes, the attacker only has to guess the ID. If it is random, the search space is much larger |
| The window of time | Until the real answer arrives, or the TTL expires | The record's TTL decides how often a new window opens |
CERT's note identifies three weaknesses that made poisoning practical in 2008: the 16-bit ID space was small, multiple identical outstanding requests allowed "birthday attacks" (RFC 5452 explains that the odds go up when many identical queries are waiting at once), and many resolvers used a fixed source port for outgoing queries.
3. Milestone 1: the Kaminsky flaw (2008)
The 2020 paper discussed below describes Kaminsky's work as the very first widely publicized DNS cache poisoning attack: in 2008 he demonstrated that an off-path attacker can inject spoofed DNS responses and have resolvers cache them. The main mitigation in CERT's note was per-query source port randomization. CERT says this adds about 16 extra bits of randomness and makes attacks "impractical" but not impossible, and that without changes to the protocol itself, such as DNSSEC, these mitigations "cannot completely prevent cache poisoning." The note was first published on 8 July 2008.
RFC 5452 turned the response into a standard recommendation: use an unpredictable source port for outgoing queries, drawn from as large a range as possible. It also asks resolvers to accept data only when the sender is known to be authoritative for the name (the "bailiwick" rule), which stops a response from slipping unrelated records into the cache.
4. Milestone 2: SAD DNS (2020)
Source port randomization worked for years. In 2020, researchers at UC Riverside and Tsinghua University showed in "DNS Cache Poisoning Attack Reloaded: Revolutions with Side Channels" (ACM CCS 2020) that it could be weakened. Their abstract explains that to poison a typical cache, an off-path attacker would need an impractical 2<sup>32</sup> spoofed responses to guess both the port (16 bits) and the ID (16 bits). They found a side channel (a shared rate limit on ICMP error replies in some operating systems) that lets the attacker "divide and conquer": guess the source port first and then the ID, which takes about 2<sup>16</sup> + 2<sup>16</sup> spoofed responses. The condition is that the operating system and its network allow ICMP error replies. They measured that over 34% of open resolvers on the internet were vulnerable, including 85% of popular public DNS services.
ISC, which maintains the BIND resolver, gave a measured assessment: the attack "exploits predictable rate limiting in the operating system", it is "fairly difficult to exploit" for typical resolvers, and operators of popular open resolvers should mitigate it. ISC's advice: update the operating system so ICMP rate limiting is unpredictable; use DNS cookies (enabled by default in BIND 9); and, above all, deploy DNSSEC, which ISC says prevents damage from cache poisoning however it is accomplished.
The lesson is that randomness is a speed bump, not a lock. The lasting fix is to add proof to the answers themselves.
5. DNSSEC: proof for DNS answers
RFC 4033 says DNSSEC adds "data origin authentication and data integrity to the Domain Name System." A zone owner signs their records. A validating resolver checks the signatures, following a chain of trust from the DNS root down to the domain (each link "vouching for the next"). A forged reply cannot carry a valid signature, so a validating resolver rejects it.
RFC 3833 (a threat analysis of DNS) walks through the threat classes and DNSSEC's answer to each. On the forged-response classes it says that a resolver that checks DNSSEC signatures "will be able to detect the forged response", and about name chaining (cache poisoning) that DNSSEC "should provide a good defense against most (all?) variations on this class of attack." About denial of service it is blunt: DNSSEC "does not help this, and may in fact make the problem worse."
Limits to know:
- DNSSEC "is not designed to provide confidentiality" (RFC 4033). It signs answers; it does not hide them.
- It only protects domains that are signed, and only users whose resolver validates.
- It does not stop DNS hijacking through stolen account credentials (section 6). DNSSEC authenticates the records the zone's owner publishes; it cannot tell that an attacker with access to the account was the one who published them.
DNS over TLS and DNS over HTTPS are a different thing
DoT (RFC 7858) and DoH (RFC 8484) encrypt the conversation between your device and your resolver, which hides your lookups from people on your network and stops on-path tampering on that stretch. They do not authenticate the data: RFC 8484 says the HTTPS connection "does not provide the response integrity of DNS data provided by DNSSEC", and both RFCs describe DNSSEC and the encrypted transports as independent and fully compatible protocols, each solving a different problem. Poisoning happens in the resolver's conversation with other DNS servers, which DoT and DoH to your resolver do not cover.
6. DNS poisoning, spoofing and hijacking: not the same
| Term | What changes | Where | Typical cause |
|---|---|---|---|
| DNS cache poisoning / DNS spoofing | A resolver's cache gets a forged answer | Recursive resolvers and forwarders | A forged reply wins the race (weak randomness, side channels, software flaws) |
| DNS hijacking (infrastructure tampering) | The real DNS records are changed | The registrar or DNS hosting account | Stolen credentials for an account that can edit records |
| Local redirection | The device or router uses a hostile DNS server | A device, a router or a network | Rogue DHCP server or changed router settings (see Spoofing) |
CISA's alert AA19-024A describes a real hijacking campaign. Attackers "compromis[ed] user credentials ... of an account that can make changes to DNS records", then changed address, mail or name-server records to point at attacker infrastructure. Because they controlled the records, they could also obtain valid encryption certificates for the domain, so victims saw no certificate warnings and the attackers could decrypt traffic. CISA's mitigations: update passwords, use multi-factor authentication on registrar and DNS accounts, audit public DNS records, revoke fraudulent certificates, and watch Certificate Transparency logs for certificates you did not request.
The same risk to certificates appears in the SAD DNS paper: certificates are commonly obtained by proving control of a domain, so compromising DNS integrity "can lead to catastrophic security failures, including fraudulent certificates being issued."
7. What it can lead to
| Result | How |
|---|---|
| A fake site under the real name | The address bar shows the real name but the server is the attacker's. Browsers warn unless the attacker also has a certificate they trust for that name |
| Man-in-the-middle | The attacker proxies to the real site and reads or changes the traffic (see MITM) |
| Mail interception | Poisoned MX records send email to the attacker |
| Malware delivery | Update or download addresses point to attacker servers |
| Fraudulent certificates | If the attacker can answer the checks that a certificate authority uses to confirm domain control (see the SAD DNS paper's warning above) |
Remember TLS: an attacker who redirects your browser still needs a certificate that your browser trusts for that name. That is the main reason poisoned DNS is not an automatic disaster for HTTPS sites, and why attacks that also obtain certificates (AA19-024A) are so serious.
8. Defences
For people who run resolvers
| Control | Why |
|---|---|
| Keep resolver software and the operating system updated | The 2008 and 2020 problems were fixed in software and OS settings |
| Randomize source ports and query IDs | RFC 5452. BIND already does both |
| Reject out-of-zone data (bailiwick checks) | RFC 5452 section 6 |
| Use DNS cookies | ISC: they make spoofing "much more difficult" and are on by default in BIND 9 |
| Make ICMP rate limiting unpredictable | ISC's recommendation against SAD DNS |
| Turn on DNSSEC validation | The control that works however the forged answer arrived |
| If you run a public (open) resolver, apply the SAD DNS mitigations first | ISC says operators of popular open resolvers should mitigate it |
For domain owners
| Control | Why |
|---|---|
| Sign your zone with DNSSEC | Lets validating resolvers reject forged answers for your domain |
| Use MFA on registrar and DNS-provider accounts | The route used in the AA19-024A hijacking campaign |
| Audit your public DNS records | Catches changes you did not make |
| Monitor Certificate Transparency logs | Flags certificates issued for your domain that you did not request |
For users
| Control | Why |
|---|---|
| Do not click through certificate warnings | If DNS was redirected, a certificate mismatch is often the visible sign |
| Prefer a resolver that validates DNSSEC | See the check below |
| Use HTTPS and, ideally, multi-factor authentication that resists phishing | A redirected login page cannot reuse your passkey |
Check your resolver (safe, and read-only)
On a computer with dig (macOS has it; on Debian or Ubuntu install bind9-dnsutils, on Fedora bind-utils; on Windows use WSL):
dig +dnssec cloudflare.com @1.1.1.1
Look at the flags: line in the answer. The letters qr rd ra ad mean the resolver says it validated the DNSSEC signatures (ad stands for "authenticated data"). For a deliberate failure test, query a public test domain whose DNSSEC signatures are intentionally broken:
dig +dnssec dnssec-failed.org @1.1.1.1
A validating resolver answers status: SERVFAIL instead of returning an address, because it refuses data that fails validation. A resolver that does not validate would return the address. (The 1.1.1.1 and 8.8.8.8 public resolvers both returned ad for signed domains when I tested; run the test on your own resolver to see yours.)
9. Common mistakes
| Myth | The facts |
|---|---|
| "DNS poisoning is a 2008 problem and it is solved" | Source port randomization made it impractical, not impossible. SAD DNS (2020) showed a way around it in some configurations. DNSSEC is the lasting fix |
| "DNS over HTTPS stops DNS poisoning" | It encrypts your connection to the resolver. RFC 8484 says it does not provide DNSSEC's response integrity |
| "DNSSEC encrypts DNS" | It signs, it does not encrypt (RFC 4033) |
| "DNSSEC stops all DNS attacks" | It does not help against denial of service (RFC 3833) and it does not prevent hijacking by stolen account credentials |
| "Poisoning and hijacking are the same" | Poisoning fools a cache. Hijacking changes the real records at the source |
| "HTTPS makes me safe whatever DNS says" | Only if the attacker cannot obtain a certificate your browser trusts. Hijacking campaigns have obtained valid ones |
| "A poisoned entry is permanent" | It stays until its TTL expires or the cache is flushed, then the resolver asks again |
| "Only websites are affected" | Mail, updates and any service that uses names can be redirected (CERT) |
Closing
DNS answers are cached and trusted. In classic cache poisoning, an attacker who cannot see the traffic wins a race with a forged reply that guesses the query ID and the source port. In 2008 the small ID space and fixed ports made that practical, and source port randomization made it hard again. In 2020 the SAD DNS research showed that a side channel could shrink the guessing work. The lasting defence is DNSSEC, which gives answers a signature a forged reply cannot carry, together with updated resolvers, DNS cookies and strong protection of the accounts that edit your DNS records.
Keep these points:
- A resolver's cache is shared: one false entry is served to everyone until the TTL ends.
- The attacker must match the query ID, the source port and the source address and beat the real answer.
- Kaminsky (2008): weak randomness; the fix was source port randomization. SAD DNS (2020): a side channel weakened it.
- DNSSEC adds proof; DoT and DoH add privacy on one hop. They are different tools.
- Poisoning (fake cache entry) is not hijacking (real records changed). Hijacking is defended with MFA and monitoring.
- Never click through certificate warnings, because a redirect usually shows up there.