Tools & Prevention
This section will introduce Singularity, a robust and versatile DNS rebinding attack framework. Moreover, we will explore techniques to prevent DNS rebinding.
DNS Rebinding Tools
Singularity
A powerful DNS rebinding attack framework.
Installation
git clone https://github.com/nccgroup/singularity
cd singularity/cmd/singularity-server
go buildSetup
mkdir -p ~/singularity/html
cp singularity-server ~/singularity/
cp -r ../../html/* ~/singularity/html/Run Server
Start on the same port as the target web application:
sudo ~/singularity/singularity-server --HTTPServerPort 80Configure Singularity as the nameserver for your domain (see Singularity's setup guide).
Using Singularity
Victim browses to
http://rebinder.attacker.htbConfigure the attack:
Attack Host Domain:
dynamic.attacker.htbTarget Host:
192.168.178.1Target Port:
80Attack Payload:
Simple Fetch Get
Click Start Attack
Wait (may take minutes due to DNS pinning)
Alert popup confirms successful data access
For advanced options, see Singularity's wiki.
Prevention
SSRF Filter Bypasses
Resolve before checking
Resolve domain name before checking to ensure IP format is expected
Use whitelist
If possible, check resolved IP against whitelist of allowed IPs
Block private ranges
Block 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 127.0.0.0/8, 0.0.0.0/8
Handle redirects
Consider HTTP/HTML redirects and implement mitigations
Firewall rules
Prevent outgoing access from vulnerable app to internal network
Preventing DNS Rebinding in SSRF Filters
Do not resolve the domain name twice!
After resolving in the SSRF filter:
Fix the resolved IP address
Reuse it when making the actual request
Implementation is application-dependent
DNS Rebinding (Same-Origin Policy Bypass)
The danger: DNS rebinding enables attackers to access applications in victim's local network, circumventing firewalls/NAT.
Best Practices for Internal Network Design
Use authentication on ALL internal services
DNS rebinding only accesses with cookies of corresponding domain name. Without credentials, only unauthenticated access possible.
Use TLS on ALL services
Certificate mismatch occurs when accessing internal service via incorrect domain name
Hardening Measures
Refuse DNS lookups of internal IPs
DNS server responds with NXDOMAIN for domains resolving to internal IPs
Validate HTTP Host header
DNS rebinding uses incorrect domain name/Host header - reject unexpected values
Summary
Last updated