DNS Rebinding Attacks
You'll learn how attackers can manipulate DNS responses to trick your browser into violating the Same-Origin Policy and attacking internal networks.
What Is DNS Rebinding?
DNS rebinding is a clever attack that exploits how browsers enforce the Same-Origin Policy (SOP). Remember, SOP prevents evil.com from accessing resources on internal.local. But what if an attacker could make evil.com become internal.local in your browser's eyes?
Here's how it works:
- Initial Request: You visit
attacker.com. Your browser performs a DNS lookup and gets back the attacker's public IP (e.g.,203.0.113.5) - Short TTL Trick: The DNS response has an extremely short Time-To-Live (TTL), like 0-1 seconds
- JavaScript Payload: The attacker's page loads malicious JavaScript that waits briefly
- DNS Rebind: When the script makes another request to
attacker.com, the TTL has expired, forcing a new DNS lookup - Surprise Answer: This time, the attacker's DNS server returns an internal IP like
192.168.1.1(your router) - SOP Bypass: Your browser thinks it's still talking to
attacker.com(same origin!), but now sends requests to your internal network
Why This Works
The browser checks the domain name for SOP, not the IP address. By rapidly changing which IP the domain resolves to, attackers bridge the public-internal network boundary. Your browser becomes a proxy for attacking services that should be unreachable from the internet—routers, IoT devices, internal APIs.
Real-World Impact
This can access admin panels on internal devices, steal data from localhost services, or exploit vulnerable internal applications—all from a simple website visit.
Key Takeaway: DNS rebinding exploits short DNS TTLs to rapidly change a domain's resolved IP address, tricking browsers into treating internal services as same-origin with an attacker's domain, bypassing network-level security boundaries.