TRAP; RESET; POISON; - Taking over a country Kaminsky style
A country-wide DNS resolver used sequential source ports due to a carrier-grade NAT device, making them guessable. An attacker could poison the resolver's cache to redirect or block DNS resolutions for millions of users.
Published on sec-consult.com
A technical deep dive on how to poison the DNS name resolution of an entire country!
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
Root cause
Likely the CGNAPT device allocated source ports sequentially from a small static pool, reducing the randomness needed to protect DNS queries.
Impact
An attacker could redirect or block DNS resolutions for millions of users, enabling denial of service, traffic redirection, e-mail spoofing, and bypassing domain verification, though TLS may limit some attacks.
What the attacker needed
Ability to send spoofed UDP packets; knowledge of the resolver's IP; target uses a vulnerable CGNAPT device
The fix
The vulnerability was fixed; DNS resolvers should also follow best practices and use DNSSEC and DNS cookies.
How it was found
- Trap 10 ports by continuously sending UDP packets to them, leaving around 2990 ports blocked.
- Use the DNS resolver to query a name of the test ADNS, forcing the CGNAPT to use one of the trapped ports and resetting the port block allocation.
- Stop blocking ports, resulting in a sequential port block allocation starting at one of the 10 known ports.
- Send a DNS request for a random subdomain to the resolver, which forwards it to the ADNS.
- Continuously send spoofed DNS responses with varying DNS IDs on the 10 possible ports, containing a malicious NS record.
- If the spoofed response arrives before the legitimate one, the resolver caches the malicious record, redirecting the subdomain to an attacker-controlled nameserver.
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 is like the internet's phone book, turning names like google.com into IP addresses. A DNS resolver stores these answers temporarily (caching). If an attacker can trick the resolver into storing a fake answer, they can redirect or block traffic for everyone using that resolver. This report shows how a flaw in how the resolver picked its outgoing ports made such trickery possible.
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.