www.example.com
Neutral envelope: the resolver's real query (its ID + port ticket)Pink envelopes: the attacker's forged repliesGreen envelope: the real server's answerPink card in the drawer: the false record now cachedA cache-poisoning attack on one DNS lookup. The resolver asks ns1.example.com with a random 16-bit transaction ID and a random source port; by RFC 5452 it accepts the first reply whose question, ID, source address and port all match, and drops the rest. An off-path attacker who cannot see the query forges replies that fake the real server's address and guess the ID; if one arrives first with the right ID it is cached as a false record (198.51.100.66) for the TTL the attacker chose, and everyone using the resolver is sent to the wrong server. The 2008 technique (CVE-2008-1447) was fixed in a coordinated patch of DNS software that added source port randomisation, later written down in RFC 5452. With a fixed port each guess had a 1 in 65,536 chance; randomising the port makes it about 1 in 4,227,858,432. Forging the sender address only works from networks that do not filter outgoing traffic; BCP 38 (RFC 2827) asks every network to drop packets with source addresses that are not its own. HTTPS still helps: the attacker's server cannot show a valid certificate for www.example.com, so the browser warns instead of loading the page (see the HTTPS lesson). 192.168.1.10 is private RFC 1918 space; 198.51.100.53, 192.0.2.53, 203.0.113.10 and 198.51.100.66 are RFC 5737 documentation addresses. IDs, ports and the attacker's TTL are illustrative.

The race

  1. Your laptop asks its resolver for www.example.com. The resolver's cache drawer is empty, so it must ask example.com's own name server.

The damage

Odds, and the easy case

The messages, step by step

;; step 1/12 · ask-resolver
;; client → resolver
UDP 192.168.1.10:50321 → 198.51.100.53:53
id 0x3a7e  flags RD
question  www.example.com. IN A
cache: no entry for www.example.com

RFC 5452 §3: a resolver accepts a response only if its question, ID, source address and destination port match a query it is still waiting on; the first one that matches wins. The fix is in the next lesson, "Defence: DNSSEC and encrypted DNS": DNSSEC signatures let a resolver reject forged records; DNS over TLS or HTTPS hides and protects the query on the way.