Bypassing Server-Side Request Forgery filters by abusing a bug in Ruby's native resolver
A bug in Ruby's Resolv::getaddresses method caused it to return an empty list for certain IP address formats, allowing attackers to bypass SSRF filters that relied on this method. This enabled scanning of internal networks in applications like GitLab and HackerOne.
[email protected] (EdOverflow) Follow
Published on edoverflow.com
This is a security advisory for a bug that I discovered in Resolv::getaddresses that enabled me to bypass multiple Server-Side Request Forgery filters. Applications such as GitLab and HackerOne were affected by this bug.
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 Resolv::getaddresses method returns an empty array when reverse DNS lookup fails for certain IP address formats, and filters that only check the returned addresses do not treat an empty result as a blocked address.
Impact
Attackers could bypass SSRF protections and scan internal networks of affected applications, though in one case (HackerOne) the SSRF itself could not be exploited, only the filter bypass was demonstrated.
What the attacker needed
Application uses Resolv::getaddresses for SSRF filtering; attacker can supply a URL or IP address to the application
The fix
The issue was fixed in Ruby and in the private_address_check gem by updating to versions that handle empty resolution results correctly, and the author recommends using the Socket library instead of Resolv::getaddresses.
How it was found
- Call Resolv.getaddresses with an IP address in a format that fails reverse DNS lookup, such as '127.1'.
- Observe that the method returns an empty array instead of the resolved IP.
- Compare the empty result against a blocklist of private IPs; the intersection is empty, so the filter is bypassed.
- Use the bypassed address in an SSRF attack to reach internal network resources.
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 an attacker tricks a server into making requests to internal systems. Many applications try to block SSRF by checking if a user-supplied address resolves to a private IP, but a bug in a Ruby library made that check fail for some address formats, so the block was bypassed.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.