Critical Cache Poisoning Vulnerability in Dnsmasq
Dnsmasq forwards queries containing special characters to upstream resolvers, some of which silently discard them, leaving Dnsmasq waiting without a response. This creates an extended window in which an off-path attacker can brute-force the transaction ID and source port to inject forged DNS records and poison the cache.
lists.thekelleys.org.uk
Published on lists.thekelleys.org.uk
We would like to responsibly disclose a critical cache poisoning vulnerability affecting the Dnsmasq DNS software. The issue allows attackers to inject arbitrary malicious DNS resource records and poison domain names without requiring advanced techniques, only by leveraging a single special character.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Impact
An off-path attacker could poison any cached domain name in Dnsmasq, and the technique may amplify known cache poisoning attacks such as SADDNS and Tudoor.
What the attacker needed
Attacker can send spoofed DNS responses; upstream resolver silently drops malformed queries; target domain uses a special character; extended attack window (~9,469 seconds)
The fix
Dnsmasq should detect upstream resolver silence, apply rate limiting and spoof-detection similar to PowerDNS, and not leave queries pending indefinitely.
How it was found
- Send a DNS query for a domain name containing a special character such as a tilde, exclamation mark, asterisk or underscore.
- Dnsmasq forwards the query to an upstream recursive resolver.
- The upstream resolver silently discards the malformed query without returning NXDomain or ServFail.
- Dnsmasq waits without timing out, leaving the pending query open.
- During that window, brute-force the 16-bit transaction ID and 16-bit source port to inject a forged response.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
DNS resolvers keep a local cache of answers so they don't have to ask the internet every time. If an attacker can slip a fake answer into that cache, everyone using the resolver is sent to the attacker's chosen address. Here, a quirk in how Dnsmasq handles odd characters in domain names gives an attacker much more time to guess the random numbers that protect each DNS query.
What is Cache bugs?
A cache and the origin disagree about a request, so a poisoned response is served to everyone or a private page is stored as public.