Join our Newsletter — 33% off our NHI Course
Home› Guides› DNS Cache Poisoning and Spoofing: How It Works…
Guide Network Security

DNS Cache Poisoning and Spoofing: How It Works and How to Prevent It

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 13 min read
On this page

If a recursive resolver accepts one forged answer, every client that uses it can be sent to the wrong server until the record expires, and nothing on the client looks wrong. DNS cache poisoning (also called DNS spoofing at the resolver) exploits the fact that classic DNS over UDP has no built-in way to prove an answer came from the right authoritative server. The attack class was thought largely solved after 2008, then side-channel research in 2020 showed that randomisation alone could be weakened. This guide explains, at a conceptual level, how resolution and caching work, why forged answers can succeed, which resolver controls stop them (RFC 5452 randomisation, DNSSEC validation, protective DNS) and what encrypted DNS does and does not change. It is written for network and infrastructure engineers who run or depend on recursive resolvers. For the wider DNS threat picture see the DNS Security Guide; for responding to a hijacked domain see the DNS Hijack Playbook.

Key takeaways

  • Poisoning targets the resolver, hijacking targets the zone. Cache poisoning plants a false record in a recursive resolver's cache without touching the real zone, registrar or authoritative server.
  • Randomisation is the baseline, not the answer. RFC 5452 requires unpredictable 16-bit query IDs and source ports; together they raise the guessing effort sharply, but side channels and NAT devices can erode the port entropy.
  • Only validation proves an answer is genuine. CERT/CC's 2008 note concluded that fully countering poisoning needs DNSSEC-signed zones and validating resolvers. Signing your zones protects others; validating on your resolvers protects you.
  • Encrypted DNS protects a different hop. DoT and DoH secure the stub-to-resolver link; they do nothing for the resolver-to-authoritative path where off-path poisoning happens.
  • Watch for mismatches. Floods of responses with wrong transaction IDs, unexpected TTL changes and validation failures for popular names are the clearest signals.

How DNS resolution and caching work

A client's stub resolver sends a query to a recursive resolver. If the answer is not cached, the recursive resolver walks the hierarchy (root, top-level domain, then the zone's authoritative servers) and caches each answer for its time to live (TTL). Later queries for the same name are served from cache until the TTL expires. Classic DNS uses UDP on port 53 and falls back to TCP for large responses.

ComponentRoleRelevance to poisoning
Stub resolverClient library that asks a recursive resolver and trusts the answerUsually does no validation; inherits whatever the resolver caches
Recursive (caching) resolverResolves on behalf of clients and caches answersThe target: one poisoned entry affects every client
Authoritative serverHolds the zone and answers for itUnaffected by poisoning; its DNSSEC signatures are what let resolvers detect forgeries
Forwarders and NAT devicesRelay queries, sometimes rewriting source portsCan reduce randomisation or add their own cache
TTLHow long an answer may be cachedSets how long a forgery persists, and how often a new attempt window opens

See the DNS Protocol Fundamentals for Defenders Guide for message format and record types.

How cache poisoning works

RFC 5452 says a resolver must accept a response only if it matches the outstanding query on source and destination address, source and destination port, query ID, and the question (name, class and type). An off-path attacker cannot see the query, so to be accepted a forged response has to arrive before the genuine one and match all of those values. Conceptually, poisoning is therefore a race against the real authoritative server, won by guessing.

  • The window: RFC 5452 estimates the opportunity as roughly the authoritative server's response time, often around 0.1 seconds, reopening each time the cached record expires. It notes that short TTLs make spoofing far more viable.
  • The entropy: the query ID is 16 bits. CERT/CC explains that a correctly random ID needs about 32,768 guesses on average, and a randomised source port adds roughly another 16 bits of unpredictability.
  • Multiplying chances: if a resolver sends several identical outstanding queries, a forged packet only needs to match one of them, which RFC 5452 describes as a birthday attack.
  • What gets planted: beyond a single false address record, a forged response can carry extra records in its authority or additional sections. Resolvers apply trust ranking and bailiwick checks (RFC 2181) to decide which of those to cache, and weak implementations historically accepted too much.

The consequence is redirection: users and services reach an attacker-controlled host for web, mail or API traffic. TLS certificate validation still blocks many such redirects, which is why poisoning is most dangerous for unencrypted protocols and applications that skip certificate checks. Redirection of this kind sits under ATT&CK T1557 Adversary-in-the-Middle.

Notable techniques and research

YearResearch or eventWhat it showedDefensive lesson
2008CERT/CC VU#800113 (CVE-2008-1447), multiple DNS implementations vulnerable to cache poisoningFixed source ports, weak ID randomness and duplicate outstanding queries made forging practicalPer-query source port randomisation was patched into resolvers and stub resolvers; DNSSEC named as the complete fix
2009IETF RFC 5452, Measures for Making DNS More Resilient against Forged Answers (Proposed Standard)Codified strict response matching, random IDs and ports, and TCP fallback when forgeries are detectedThe resolver hardening baseline
2020SAD DNS, "DNS Cache Poisoning Attack Reloaded: Revolutions With Side Channels" (ACM CCS 2020, UC Riverside and Tsinghua University)Operating system network side channels could reveal which source port a resolver was using, removing most of the port entropyPatch operating systems (the Linux fix randomises the ICMP rate limit), patch NAT gateways, validate DNSSEC

The SAD DNS researchers reported affected components including Linux kernels 3.18 to 5.10, Windows Server 2019 and later, macOS 10.15 and later, FreeBSD 12.1.0 and later, and resolvers such as BIND, Unbound and dnsmasq, with later variants tracked under further CVEs. Check vendor advisories for patch status in your own stack.

Resolver hardening

These controls reduce the chance of a forgery being accepted. None of them proves authenticity on its own.

  • Randomise IDs and ports (RFC 5452): confirm the resolver uses the full 16-bit ID space and random source ports from a large range (RFC 5452 treats 1024 to 49152 as generally safe). Do not pin the query source port in configuration, which some older configurations did to suit firewalls.
  • Check NAT and firewalls: CERT/CC and the SAD DNS authors both warn that port translation can strip the randomness a patched resolver provides. Place resolvers where outbound queries are not port-rewritten, or confirm the device preserves randomness.
  • Restrict recursion: answer recursive queries only for your own clients; never run an open resolver. Separate authoritative and recursive roles on different servers.
  • Add message entropy: DNS cookies (RFC 7873) add a shared secret to resolver and server exchanges, and 0x20 case randomisation adds a few bits per query where the resolver supports it.
  • Shorten the window: keep outstanding query timeouts short and avoid sending duplicate identical queries in parallel.
  • Fall back to TCP on suspicion: RFC 5452 allows a resolver that sees many mismatched answers to retry over TCP, which is much harder to forge.
  • Patch the operating system as well as the DNS software: the SAD DNS side channel lived in the kernel network stack, not the resolver.
  • Filter spoofed traffic: ingress filtering per BCP 38 at network edges limits who can send forged packets in the first place.

Product-specific settings are covered in the BIND DNS Server Hardening and CoreDNS Security guides.

Protective DNS

Protective DNS resolvers apply threat intelligence and block resolution of known malicious domains. CISA's Protective DNS service, for example, is a policy-enforcing recursive resolver that blocks known malicious domains and IP addresses and supports DoH and DoT. Protective DNS is valuable against phishing and command-and-control lookups, and a well-run service also implements the hardening above, but blocking lists do not detect a forged answer for a legitimate name. Treat it as a complement to validation. See the DNS Response Policy Zones guide for running your own policy layer.

DNSSEC signing and validation

RFC 4033 describes DNSSEC as adding data origin authentication and data integrity to DNS, with signatures in RRSIG records and authenticated denial of existence through NSEC records. It does not provide confidentiality. A validating resolver checks the chain from a configured trust anchor (the root key) down to the answer and rejects anything that does not verify, so a forged answer for a signed zone fails even if the attacker guesses every ID and port.

QuestionSigning your zonesValidating on your resolvers
Who is protectedEveryone who validates when they look up your namesYour users, for every signed zone they look up
Who does the workZone owner and DNS host: keys, signing, DS record at the registrarResolver operator: turn on validation, keep the root trust anchor current
What it stopsForged answers for your zone at validating resolvers anywhereForged answers for any signed zone reaching your clients
Main operational riskExpired signatures or key rollover mistakes make your zone unresolvable for validatorsOutages when a remote zone breaks DNSSEC; pressure to disable validation
LimitsNo effect on resolvers that do not validateNo protection for unsigned zones; the AD bit is only meaningful over a trusted channel to the stub

The SAD DNS authors note that DNSSEC-aware but non-validating configurations give no protection: validation must be switched on and enforced. RFC 4033 adds that a non-validating stub relying on its resolver's AD bit needs a channel with integrity to that resolver. Use negative trust anchors for a remote zone that is broken, rather than turning validation off globally. See the DNSSEC Deployment Guide and DNSSEC Validation Failures.

What encrypted DNS changes

DNS over TLS (RFC 7858, TCP port 853) and DNS over HTTPS (RFC 8484, port 443) encrypt and integrity-protect the stub-to-recursive hop, which stops on-path tampering on the local network. RFC 7858 states that recursive-to-authoritative use is out of its scope, and RFC 8484 states that HTTPS does not provide DNSSEC-style response integrity: a DoH server can still return bad data. So encrypted DNS does not stop off-path poisoning of the resolver's cache; validation does. The DNSSEC vs DNS over HTTPS guide compares the two, and the Encrypted DNS Enterprise Guide covers enterprise control.

Rollout order

  1. Inventory resolvers: every recursive resolver, forwarder and embedded resolver (routers, firewalls, Kubernetes cluster DNS), with software version and operating system.
  2. Patch: DNS software and kernels, then NAT gateways in the query path.
  3. Verify randomisation: sample outbound queries and confirm source ports and IDs vary widely after any NAT.
  4. Enable validation in a pilot: turn on DNSSEC validation for one site or resolver pool, monitor SERVFAIL rates for a week, and keep a documented rollback (disable validation on that pool only) and a negative trust anchor procedure.
  5. Enforce everywhere: extend validation to all pools; block clients from bypassing to external resolvers so they inherit it.
  6. Sign your own zones: starting with low-risk zones, then production, with automated signing and monitored key rollovers.

Detection and monitoring

  • Mismatched responses: bursts of inbound DNS responses with wrong transaction IDs or arriving on unexpected ports. The SAD DNS authors suggest IDS rules for this and for unusual UDP port probing.
  • Cache anomalies: a popular name whose cached answer changes to an unfamiliar address or network, or whose TTL is far higher than the authoritative value.
  • Validation failures: spikes in DNSSEC bogus results for a zone that normally validates.
  • Resolver bypass: clients sending port 53 or DoH traffic to external resolvers, which escapes your validation and logging.
  • Downstream signals: TLS certificate errors for internal or well-known services clustered by resolver.
MetricTarget
Recursive resolvers with DNSSEC validation enforced100%
Resolvers and NAT devices on patched versions for SAD DNS class issues100%
Share of your public zones signed with a valid DS chainRising to 100%
Client DNS traffic bypassing approved resolversNear zero
Mismatched-response alerts investigated within one business day100%

Log design and queries are covered in the DNS Logging and Detection Guide.

Common failure patterns

  • Validation disabled after one outage. A remote zone breaks its signatures, users complain, and validation is turned off globally and never re-enabled. Use a negative trust anchor instead.
  • Randomisation lost at the edge. A patched resolver sits behind a NAT or firewall that rewrites source ports sequentially.
  • Forgotten embedded resolvers. Branch routers, firewalls and appliance forwarders run old DNS code and cache answers for whole sites.
  • Treating DoH as the fix. Encrypting client queries to a resolver that does not validate leaves the poisoning path open.
  • Open or shared recursion. Resolvers that also serve authoritative data, or answer the internet, widen exposure and complicate monitoring.

Framework mapping

FrameworkReferenceHow it applies
NIST SP 800-53 Rev. 5SC-21 Secure Name/Address Resolution Service (Recursive or Caching Resolver)Validation of origin and integrity on resolvers
NIST SP 800-53 Rev. 5SC-20 Secure Name/Address Resolution Service (Authoritative Source)Signing your own zones
NIST SP 800-53 Rev. 5SC-22 Architecture and Provisioning for Name/Address Resolution ServiceSeparating authoritative and recursive roles
NIST SP 800-53 Rev. 5SI-4 System MonitoringMismatch, cache and validation monitoring
NIST CSF 2.0PR.IR-01, DE.CM-01Protecting and monitoring network services
CIS Controls v8.1Safeguard 9.2 Use DNS Filtering ServicesProtective DNS layer
MITRE ATT&CKT1557 Adversary-in-the-MiddleRedirection outcome of a poisoned cache

NIST SP 800-81 Rev. 3, Secure Domain Name System (DNS) Deployment Guide, was published as final on 19 March 2026 and covers DNSSEC, protective DNS and encrypted DNS deployment in depth.

Practitioner checklist

  • Inventory every recursive resolver and forwarder, including embedded and cluster DNS.
  • Patch DNS software, operating system kernels and NAT gateways in the query path.
  • Confirm random query IDs and source ports survive NAT, by sampling outbound traffic.
  • Enable and enforce DNSSEC validation on all resolvers, with a negative trust anchor procedure.
  • Sign your public zones and monitor signature expiry and key rollovers.
  • Restrict recursion to your own clients and separate authoritative from recursive servers.
  • Block client bypass to external resolvers, including unapproved DoH.
  • Alert on mismatched-response floods, cache anomalies and validation failure spikes.

Standards and references

Related NHI Mgmt Group resources: DNS Security Guide, DNSSEC Deployment Guide, Encrypted DNS Enterprise Guide, DNS Hijack Playbook, DNS Security Checklist.

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.