Bypassing Filters: SSRF Exploitation via DNS Rebinding with Just 1 in 30 Successful Requests
An endpoint accepted a URL parameter and fetched it server-side, but a filter blocked requests to internal addresses. By using a DNS rebinding hostname that alternated between a loopback address and the cloud metadata address, roughly one in thirty requests slipped past the filter and returned AWS instance metadata.
Hey everyone, hope you’re all doing well! I wanted to share a cool bug story I came across a few months ago.
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 application validated the resolved IP address separately from the request that was actually made, so a hostname that changed its answer between the check and the fetch could bypass the block.
Impact
An attacker could read AWS instance metadata, which may include instance identity and network details, and potentially credentials, though the exploit succeeded only about one in thirty attempts.
What the attacker needed
A URL parameter fetched server-side; a DNS rebinding service; many repeated requests
How it was found
- Find a parameter that takes a URL and is fetched by the server.
- Send test URLs through the parameter and observe that most return 501 or 503 errors.
- Notice one response returned 200 with a JSON error containing an ami-id.
- Use a DNS rebinding hostname that alternates between a loopback address and the metadata address.
- Resend the request repeatedly until the rebinding hostname resolves to the metadata address and returns metadata.
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.
Server-side request forgery (SSRF) is when a website fetches a URL you supply, and you trick it into fetching something internal instead. Here the site tried to block internal addresses, but a DNS rebinding service returns a hostname that resolves to different addresses over time, so occasionally the check saw a harmless address while the actual fetch went to the cloud metadata service. That metadata service holds credentials and configuration for the cloud instance.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.