DNS rebinding is a technique used by attackers to gain unauthorized access to a target device or network by manipulating Domain Name System (DNS) resolution. The attacker tricks the target device into connecting to a malicious website by redirecting the DNS resolution to a different IP address than the intended one. Once the target device connects to the malicious website, the attacker can use it to exploit vulnerabilities and gain access to the device or network. To prevent DNS rebinding attacks, it is recommended to use a firewall or other security measures to block incoming traffic from untrusted sources and to keep software and operating systems up to date.
Tools for DNS Rebinding
There are a few tools that can be used to test for and prevent DNS rebinding attacks. These include:
- dnsrebind.py: This is a python script that can be used to test whether a device or network is vulnerable to DNS rebinding attacks.
- mitmproxy: This is a free and open-source tool that can be used to intercept and modify network traffic, making it a useful tool for testing and mitigating DNS rebinding attacks.
- Fiddler: This is a web debugging tool that can be used to intercept and modify network traffic. It is useful for testing and mitigating DNS rebinding attacks, as well as for other types of security testing.
- OWASP-ZAP: This is a free and open-source web application security scanner that can be used to find vulnerabilities in web applications, including those that could be exploited through DNS rebinding.
- Browser extension: Some browser extension can be used to protect the user from DNS rebinding attacks by blocking the malicious requests.
It’s worth noting that DNS rebinding is a complex attack, and that no single tool is a complete solution. It’s important to use a combination of tools and techniques to protect against these attacks.
Exploit for DNS Rebinding
There are several ways to exploit DNS rebinding vulnerabilities, but the basic steps of an attack typically involve the following:
- The attacker registers a domain name that they control and configures it to resolve to a specific IP address.
- The attacker then sends a link or a malicious advertisement to the target, tricking them into visiting the attacker-controlled domain.
- The target’s device or network sends a DNS request to resolve the attacker-controlled domain to an IP address. The attacker-controlled DNS server responds with the IP address of the attacker’s server.
It’s important to note that DNS rebinding attacks can be difficult to detect, since they appear as legitimate network traffic. To protect against these attacks, it is recommended to use a firewall or other security measures to block incoming traffic from untrusted sources, and to keep software and operating systems up to date.
- Singularity of Origin – is a tool to perform DNS rebinding attacks.
- Singularity of Origin Web Client (manager interface, port scanner and autoattack)
First, we need to make sure that the targeted service is vulnerable to DNS rebinding. It can be done with a simple curl request:
If the server returns the expected result (e.g. the regular web page) then the service is vulnerable. If the server returns an error message (e.g. 404 or similar), the server has most likely protections implemented which prevent DNS rebinding attacks.
Then, if the service is vulnerable, we can abuse DNS rebinding by following these steps:
- Register a domain.
- Setup Singularity of Origin.
- Edit the autoattack HTML page for your needs.
- Browse to “http://rebinder.your.domain:8080/autoattack.html”.
- Wait for the attack to finish (it can take few seconds/minutes).
Protection Bypasses for DNS Rebinding
There are several ways that attackers may attempt to bypass protections against DNS rebinding attacks. Some of these include:
- Using multiple domains: Attackers may register multiple domains and use them in a coordinated attack to bypass protections that only block a single domain.
- Using subdomains: Attackers may use subdomains to bypass protections that only block the main domain.
- Using SSL: Attackers may use SSL encryption to hide the traffic and make it difficult for protections to detect and block the attack.
- Using IP addresses: Attackers may use IP addresses directly instead of domain names to bypass protections that only block domain names.
- Using Tor: Attackers may use the Tor network to hide their IP addresses and make it difficult to trace the attack back to its source.
- Using Server-side attacks: Attackers can use a server-side attack, where they control a server that is trusted by the target, to bypass client-side protections.
- Using local network: Attackers may use a local network to bypass protections that only block external traffic.
It’s important to note that DNS rebinding attacks are a complex attack that may involve multiple techniques, so it’s important to use multiple layers of protection to defend against them. This can include using a firewall or other security measures to block incoming traffic from untrusted sources, keeping software and operating systems up to date, and using browser extensions that protect against these attacks.
Most DNS protections are implemented in the form of blocking DNS responses containing unwanted IP addresses at the perimeter, when DNS responses enter the internal network. The most common form of protection is to block private IP addresses as defined in RFC 1918 (i.e. 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16). Some tools allow to additionally block localhost (127.0.0.0/8), local (internal) networks, or 0.0.0.0/0 network ranges.
In the case where DNS protection are enabled (generally disabled by default), NCC Group has documented multiple DNS protection bypasses that can be used.
We can use the IP address 0.0.0.0 to access the localhost (127.0.0.1) to bypass filters blocking DNS responses containing 127.0.0.1 or 127.0.0.0/8.
We can use DNS CNAME records to bypass a DNS protection solution that blocks all internal IP addresses. Since our response will only return a CNAME of an internal server, the rule filtering internal IP addresses will not be applied. Then, the local, internal DNS server will resolve the CNAME.
$ dig cname.example.com +noall +answer ; <<>> DiG 9.11.3-1ubuntu1.15-Ubuntu <<>> example.com +noall +answer ;; global options: +cmd cname.example.com. 381 IN CNAME target.local.
We can use “localhost” as a DNS CNAME record to bypass filters blocking DNS responses containing 127.0.0.1.