Skip to content
SSRF Disclosed report Intermediate

DNS Rebinding Attack

The SSRF filter validates the hostname's IP address but then passes the hostname to Net::HTTP.start(), which performs a second DNS lookup. An attacker controlling a DNS server can return a safe public IP during validation and then [redacted] during the second lookup, bypassing the filter and reaching internal services on localhost.

newby99 Follow

Originally disclosed on HackerOne

Critical 10.0 View original
  • Disclosed after 5 days

Hi, there is a DNS rebinding vulnerability in your SSRF filter.

image.png
image.png From the original on HackerOne

You validate the hostname's IP address, but then pass the hostname to Net::HTTP.start(), which does its own DNS lookup. An attacker can control a DNS server that returns a safe public IP during validation, then returns 127.0.0.1 when Net::HTTP resolves it shortly later...

::Net::HTTP.start(uri.hostname, uri.port, **http_options) do |http| # Currently using uri.hostname which triggers a new dns lookup!

Example POC: Attacker sets up evil.com DNS to alternate responses. First query (your validation) returns 8.8.8.8. Second query (Net::HTTP's internal lookup) returns 127.0.0.1. As a result: SsrfFilter.get('http://evil.com:6379') bypasses all protection and hits some internal service on localhost..

Suggested fix: Connect directly to the validated IP instead of the hostname. Change Net::HTTP.start(uri.hostname, ...) to Net::HTTP.start(validated_ip, ...) and set the Host header manually: headers['Host'] = uri.hostname. Also use ssl_hostname: uri.hostname for proper TLS certificate validation. This eliminates the race window entirely since DNS only resolves once during validation.

Impact

The library validates DNS resolution but passes the hostname (not the validated IP) to Net::HTTP, which performs a second DNS lookup. Attacker's DNS server returns different IPs for each query

The original report as published on HackerOne, by newby99. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The code validates the resolved IP but then passes the original hostname to Net::HTTP.start(), which performs a second DNS resolution that can return a different address.

Impact

An attacker could bypass the SSRF filter and make the application send requests to internal services on localhost, potentially reaching services that should not be accessible.

What the attacker needed

Attacker controls a DNS server; application uses the vulnerable SSRF filter

The fix

The code should connect directly to the validated IP address instead of the hostname, set the Host header manually, and use ssl_hostname for TLS validation, so DNS is resolved only once during validation.

How it was found

  1. Attacker sets up a DNS server for a domain that alternates responses.
  2. The first DNS query, made during validation, returns a safe public IP address.
  3. The second DNS query, made internally by Net::HTTP, returns 127.0.0.1.
  4. The request bypasses the SSRF filter and reaches an internal service on localhost.

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 report has not been written yet. The Original tab links to the source.

A server-side request forgery (SSRF) filter is meant to stop a program from being tricked into contacting internal services. This filter checks the IP address of a hostname, but then the HTTP library looks up the hostname again and may get a different, internal address. An attacker who controls DNS can make the first lookup look safe and the second lookup point to localhost, so the program ends up talking to an internal service.

What is SSRF?

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.

More by newby99

View all

1 more disclosed report, best first.

More from arkadiyt-projects

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.