Skip to content
SSRF Disclosed report Advanced CVE-2017-0904

Blind SSRF in "Integrations" by abusing a bug in Ruby's native resolver.

The Integrations panel used a Ruby gem to block server-side requests to private addresses, but a bug in Ruby's native resolver could return an empty address list for certain encoded IP formats, which the blacklist check treated as safe. This let an attacker bypass the SSRF filter and potentially scan the internal network, though the reporter could not complete a full exploit.

edoverflow Follow

Originally disclosed on HackerOne

  • Triaged in 3 days
  • Fixed in 6 days
  • Disclosed after 6 days

Summary

HackerOne allows bug bounty programs to integrate their reports queue with issue tracking tools such as Jira and Phabricator. By abusing a bug that I discovered in Ruby's native resolver, I am able to bypass the SSRF filter and could potentially scan your internal network.

Vulnerability Details

HackerOne uses the private_address_check gem to prevent SSRF on the "Integrations" panel: https://hackerone.com/{BBP}/integrations. The actual filtering takes place in lib/private_address_check.rb. The process starts by attempting to resolve the user-supplied URL with Resolv::getaddresses and then compares the returned value with a the values in the blacklist. I discovered a bug in Resolv::getaddresses that allows me to return an empty value, which is not included in the blacklist and therefore completely bypasses any checks.

Ruby
def resolves_to_private_address?(hostname)
    ips = Resolv.getaddresses(hostname)
    ips.any? do |ip| 
      private_address?(ip)
    end
end

The bypass consists of providing encoded IP addresses that when forwarded on to the operating system in lib/resolv.rb return an empty value.

http://0177.1:22/
http://0x7f.1:22/
http://127.000.001:22/

I discovered the bug in Resolv::getaddresses by running it on different Linux machines and noticing that the outputs vary. Until the Ruby Core come up with a better solution I suggest not relying on this library for any security-related features.

Machine 1 returned the following:

irb(main):001:0> require 'resolv'
irb(main):002:0> Resolv.getaddresses("127.000.000.1")
=> []

And Machine 2 returned this:

irb(main):001:0> require 'resolv'
irb(main):002:0> Resolv.getaddresses("127.000.000.1")
=> ["127.0.0.1"]

Exploit

Admittedly, I was unable to actually exploit this issue and I am still playing around to see if I can exfiltrate valuable data. The current issue only consists of a filter bypass.

Mitigation

I would suggest using Socket.getaddrinfo() as it is more reliable and is not affected by this bug. Something along the lines of this should work:

Ruby
require "socket"
...
def resolves_to_private_address?(hostname)
  ips = Socket.getaddrinfo(hostname, nil).sample[3]
  ips.any? do |ip| 
    private_address?(ip)
  end
end

My suggested patch can be found here: (Attachment on the original report: private_address_check.rb.patch).

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

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

HackerOne lets bug bounty programs connect their report queues to issue tracking tools such as Jira and Phabricator. This is done through the "Integrations" panel, reachable at https://hackerone.com/{BBP}/integrations, where a program supplies a URL that HackerOne's backend will fetch. Because the server makes that request on the program's behalf, the feature is a natural SSRF surface: without a filter, a program could point the integration at internal hosts and have HackerOne's infrastructure reach them.

To prevent this, HackerOne uses the private_address_check gem. The filtering logic lives in lib/private_address_check.rb. The process starts by resolving the user-supplied URL's hostname with Resolv::getaddresses and then compares each returned address against a blacklist of private addresses. The relevant method is:

Ruby
def resolves_to_private_address?(hostname)
    ips = Resolv.getaddresses(hostname)
    ips.any? do |ip|
      private_address?(ip)
    end
end

The check is only as good as the resolver's output. If Resolv.getaddresses returns nothing, ips.any? iterates over an empty collection and returns false, so the hostname is treated as safe.

Setup

The researcher tested Ruby's resolver behaviour directly in irb on different Linux machines. The report does not list specific Ruby versions or distributions. The bypass requires that Resolv.getaddresses returns an empty value for the supplied hostname on the machine running the check.

Finding it

The researcher found a bug in Resolv::getaddresses that allows it to return an empty value for certain hostnames. An empty result is not in the blacklist, so the comparison loop has nothing to compare and the check passes. The bypass consists of supplying encoded IP addresses that, when forwarded on to the operating system in lib/resolv.rb, return an empty value.

The three payloads given are:

Text
http://0177.1:22/
http://0x7f.1:22/
http://127.000.001:22/

The three payloads given are: The bypass consists of encoded IP addresses that, when forwarded on to the operating system in lib/resolv.rb, return an empty value.

The behaviour was not consistent across machines. On Machine 1:

Text
irb(main):001:0> require 'resolv'
irb(main):002:0> Resolv.getaddresses("127.000.000.1")
=> []

On Machine 2:

Text
irb(main):001:0> require 'resolv'
irb(main):002:0> Resolv.getaddresses("127.000.000.1")
=> ["[redacted]"]

So the same input yields an empty array on one host and the correct loopback address on another. The researcher discovered the bug by running the resolver on different Linux machines and noticing that the outputs vary. Where the empty array is returned, the private_address_check filter is bypassed entirely.

Exploitation

Step 1: Identify the filter

The Integrations panel resolves the supplied URL with Resolv::getaddresses and compares the result against a private-address blacklist, as shown in resolves_to_private_address? above. Any hostname whose resolution returns an empty list is accepted.

Step 2: Supply an encoded loopback address

Instead of a normal hostname or dotted-quad address, submit one of the encoded forms:

Text
http://0177.1:22/
http://0x7f.1:22/
http://127.000.001:22/

Where Resolv.getaddresses returns an empty value, the blacklist comparison finds nothing to reject and the URL passes the filter.

Step 3: Observe the resolver discrepancy

The researcher confirmed the underlying cause in irb, comparing two machines with the same call:

Text
irb(main):001:0> require 'resolv'
irb(main):002:0> Resolv.getaddresses("127.000.000.1")
=> []
Text
irb(main):001:0> require 'resolv'
irb(main):002:0> Resolv.getaddresses("127.000.000.1")
=> ["[redacted]"]

The empty result is the condition that makes the bypass work. The researcher states plainly that they were unable to actually exploit the issue and were still experimenting to see whether valuable data could be exfiltrated. What was demonstrated is a filter bypass, not data exfiltration.

Root cause

The mistake is trusting Resolv::getaddresses as the single source of truth for what a hostname resolves to. The method can return an empty array for inputs that the operating system's resolver still resolves, and the check treats an empty array as "not private" because any? over an empty collection is false. The bypass consists of encoded IP addresses that, when forwarded on to the operating system in lib/resolv.rb, return an empty value.

The inconsistency across machines (Machine 1 returning [], Machine 2 returning ["[redacted]"]) shows the behaviour is environment-dependent, so the filter's effectiveness depends on which host runs it. The existing defence, the blacklist comparison, never gets a chance to act because there is no address to compare. The researcher's conclusion is that until the Ruby Core provides a better solution, this library should not be relied on for security-related features.

Impact

By abusing the resolver bug, the researcher was able to bypass the SSRF filter on the Integrations panel and states that this could potentially allow scanning of HackerOne's internal network. The demonstrated result is a filter bypass only: the researcher explicitly says they were unable to actually exploit the issue and were still working on whether valuable data could be exfiltrated. The demonstrated result is a filter bypass only; the researcher was unable to actually exploit the issue.

Fix

The researcher suggests using Socket.getaddrinfo() instead, as it is more reliable and is not affected by this bug. A sketch of the replacement:

Ruby
require "socket"
...
def resolves_to_private_address?(hostname)
  ips = Socket.getaddrinfo(hostname, nil).sample[3]
  ips.any? do |ip|
    private_address?(ip)
  end
end

The suggested patch was attached to the report as private_address_check.rb.patch.

Variants to test

  1. Alternative IP encodings. Try octal, hexadecimal and zero-padded decimal forms of loopback and private ranges, for example 0177.1, 0x7f.1 and 127.000.001, against any SSRF filter that resolves hostnames before checking them. A positive result is the filter accepting the URL.
  2. Resolver disagreement. Compare what the application's resolver library returns with what the system resolver returns for the same hostname. A positive result is the filter seeing an empty result where the system resolver returns a private address.
  3. Environment-dependent behaviour. Run the same resolution call on different hosts in the target's fleet. A positive result is one host returning [] where another returns the real address, as seen between Machine 1 and Machine 2.
  4. Empty-result handling. Look for any check that iterates over resolved addresses with any? or similar and treats an empty list as safe. A positive result is a hostname that resolves to nothing in the filter.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 10 min read.

What happened, in plain words

HackerOne is a website where companies (called "bug bounty programs") pay independent researchers to find security problems in their software. Each program has a queue of incoming reports, and HackerOne lets a program connect that queue to an issue tracking tool such as Jira or Phabricator, so that a new report automatically becomes a ticket in the tool the program already uses. This connection is set up on a page called "Integrations".

To make the connection, the program supplies a web address (a URL). This is the important part: the request is made by HackerOne's computers, from inside HackerOne's network, not by the program's computer. Without a filter, a program could point the integration at internal hosts. That class of bug is called SSRF, short for Server-Side Request Forgery: tricking a server into making a request on your behalf.

To stop this, HackerOne uses a small piece of Ruby code (a "gem", which is Ruby's word for a reusable library) called private_address_check. It looks up which numeric address the URL's hostname points to and compares it against a blacklist of private addresses. A private address is one that only makes sense inside a local network, such as [redacted], which always means "this same machine".

The researcher found that the lookup function used by that check, Resolv::getaddresses, has a bug: for certain unusual ways of writing an address, it returns an empty result instead of the real address. The check then has nothing to compare against its blacklist, decides the address is fine, and lets the URL through. The researcher could not go on to actually use the bypass to steal data, but the filter itself was defeated.

Background: what the pieces are

Before the details, here are the ideas you need.

  • A URL is a web address, like https://hackerone.com/example/integrations. The part before the first slash is the hostname (here hackerone.com), and an optional :number at the end is the port, which is like a numbered door on a building. Port 22 is the door normally used for SSH, a way to log in to a machine remotely.
  • An IP address is the numeric address of a machine on a network. [redacted] is special: it always means "the machine you are on right now", also called the loopback address.
  • DNS is the system that turns a hostname such as example.com into an IP address, like a phone book. A resolver is the part of the software that does this lookup.
  • A server-side request is a request made by a website's own server, rather than by your browser. When HackerOne's Integrations feature fetches a URL you gave it, that is a server-side request.
  • SSRF (Server-Side Request Forgery) is when an attacker can choose the address that a server fetches. The danger is that the server sits inside a private network and can reach machines that the attacker cannot reach directly.
  • A blacklist is a list of things to refuse. Here it is a list of private IP address ranges.
  • Ruby is a programming language. irb is Ruby's interactive prompt: you type a line of code, press enter, and it shows you the result immediately. It is a good way to test how a function behaves.
  • A gem is a packaged Ruby library that other programs can install and use.

The vulnerable check

HackerOne's Integrations panel lives at https://hackerone.com/{BBP}/integrations, where {BBP} stands for the program's short name. The filtering logic is in a file called lib/private_address_check.rb inside the private_address_check gem. The key method is this one:

Ruby
def resolves_to_private_address?(hostname)
    ips = Resolv.getaddresses(hostname)
    ips.any? do |ip|
      private_address?(ip)
    end
end

Line by line:

  1. def resolves_to_private_address?(hostname) defines a method (a named block of code) that takes one input, hostname, and is meant to answer a yes/no question: does this hostname point to a private address?
  2. ips = Resolv.getaddresses(hostname) asks Ruby's resolver to look up the hostname and store every address it finds in a variable called ips. The result is a list (an array).
  3. ips.any? do |ip| goes through that list one address at a time, calling each one ip, and asks: is there any address for which the following is true?
  4. private_address?(ip) is the test applied to each address: is this one private?
  5. end closes the block, and the method returns true if at least one address was private, otherwise false.

The flaw is subtle. If Resolv.getaddresses returns an empty list, then any? is asked whether any of zero items match. The answer is always false. So an empty lookup is treated exactly like a lookup that found only public addresses: the hostname is considered safe.

Finding the bug

The researcher discovered that Resolv::getaddresses can return an empty value for certain hostnames. An empty value is not on the blacklist, so the comparison loop has nothing to reject and the check passes. The bypass works by supplying encoded IP addresses that, when passed on to the operating system inside lib/resolv.rb, come back empty.

The three payloads are:

Text
http://0177.1:22/
http://0x7f.1:22/
http://127.000.001:22/

The three payloads are:

  1. 0177.1 uses octal (base 8) notation for the first part. In octal, 0177 is 127.
  2. 0x7f.1 uses hexadecimal (base 16). 0x7f is 127.
  3. 127.000.001 pads the numbers with leading zeros. Numerically it is still 127.0.0.1.

The bypass consists of encoded IP addresses that, when forwarded on to the operating system in lib/resolv.rb, return an empty value.

The behaviour was not the same on every machine. On Machine 1, the researcher ran this in irb:

Text
irb(main):001:0> require 'resolv'
irb(main):002:0> Resolv.getaddresses("127.000.000.1")
=> []

Line by line:

  1. require 'resolv' loads Ruby's resolver library so its functions are available.
  2. Resolv.getaddresses("127.000.000.1") asks the resolver to look up that zero-padded form of the loopback address.
  3. => [] is the answer: an empty list. The resolver found nothing.

On Machine 2, the same two lines gave a different answer:

Text
irb(main):001:0> require 'resolv'
irb(main):002:0> Resolv.getaddresses("127.000.000.1")
=> ["[redacted]"]

Here the resolver returned the correct loopback address. So the same input produces an empty list on one host and the real address on another. The researcher found the bug by running the resolver on different Linux machines and noticing that the outputs vary. Where the empty list appears, the private_address_check filter is bypassed completely.

How the bypass would be used

Step 1: Understand the filter

The Integrations panel resolves the URL you supply with Resolv::getaddresses and compares the result against the private-address blacklist, as in resolves_to_private_address? above. Any hostname whose lookup returns an empty list is accepted.

Step 2: Supply an encoded loopback address

Instead of a normal hostname or a plain dotted address, you submit one of the encoded forms:

Text
http://0177.1:22/
http://0x7f.1:22/
http://127.000.001:22/

Where Resolv.getaddresses returns an empty value, the blacklist comparison finds nothing to reject, and the URL passes the filter. The URL passes the filter.

Step 3: Confirm the cause

The researcher confirmed the underlying cause in irb, comparing two machines with the same call:

Text
irb(main):001:0> require 'resolv'
irb(main):002:0> Resolv.getaddresses("127.000.000.1")
=> []
Text
irb(main):001:0> require 'resolv'
irb(main):002:0> Resolv.getaddresses("127.000.000.1")
=> ["[redacted]"]

The empty result is the condition that makes the bypass work. The researcher states plainly that they were unable to actually exploit the issue and were still experimenting to see whether valuable data could be taken out. What was demonstrated is a filter bypass, not data theft.

Why it works

The mistake is trusting Resolv::getaddresses as the single source of truth for what a hostname points to. The method can return an empty list for inputs that the operating system's resolver still resolves, and the check treats an empty list as "not private" because any? over an empty collection is false.

The inconsistency between machines (Machine 1 returning [], Machine 2 returning ["[redacted]"]) shows the behaviour depends on the environment, so the filter's effectiveness depends on which host runs it. The blacklist comparison never gets a chance to act, because there is no address to compare. The researcher's conclusion is that until the Ruby Core team provides a better solution, this library should not be relied on for security-related features.

What the impact is

By abusing the resolver bug, the researcher was able to bypass the SSRF filter on the Integrations panel, and states that this could potentially allow scanning of HackerOne's internal network. The demonstrated result is a filter bypass only: the researcher explicitly says they were unable to actually exploit the issue and were still working on whether valuable data could be taken out. The demonstrated result is a filter bypass only; the researcher was unable to actually exploit the issue.

The suggested fix

The researcher suggests using Socket.getaddrinfo() instead, as it is more reliable and is not affected by this bug. A sketch of the replacement:

Ruby
require "socket"
...
def resolves_to_private_address?(hostname)
  ips = Socket.getaddrinfo(hostname, nil).sample[3]
  ips.any? do |ip|
    private_address?(ip)
  end
end

Line by line:

  1. require "socket" loads Ruby's socket library, which talks to the operating system's own networking functions.
  2. ... stands for the rest of the file, which is unchanged.
  3. def resolves_to_private_address?(hostname) defines the same method as before, with the same name and input.
  4. ips = Socket.getaddrinfo(hostname, nil).sample[3] asks the operating system to look up the hostname, passing nil for the port because no port is needed for the lookup. getaddrinfo returns a list of entries, each holding several pieces of information. .sample picks one entry at random, and [3] takes the fourth item from that entry, which is the address itself.
  5. The any? loop and the private_address? test are the same as before: check whether any returned address is private.
  6. end closes the method.

The suggested patch was attached to the report as private_address_check.rb.patch.

Things worth testing elsewhere

  1. Alternative IP encodings. Try octal, hexadecimal and zero-padded decimal forms of loopback and private ranges, for example 0177.1, 0x7f.1 and 127.000.001, against any SSRF filter that resolves hostnames before checking them. A positive result is the filter accepting the URL.
  2. Resolver disagreement. Compare what the application's resolver library returns with what the system resolver returns for the same hostname. A positive result is the filter seeing an empty result where the system resolver returns a private address.
  3. Environment-dependent behaviour. Run the same lookup call on different hosts in the target's fleet. A positive result is one host returning [] where another returns the real address, as seen between Machine 1 and Machine 2.
  4. Empty-result handling. Look for any check that iterates over resolved addresses with any? or similar and treats an empty list as safe. A positive result is a hostname that resolves to nothing in the filter.

Glossary

  • API: a defined way for one piece of software to talk to another, like a menu of requests a service accepts.
  • Array: an ordered list of values in programming; it can be empty.
  • Blacklist: a list of values that are refused.
  • Bug bounty program: a scheme where a company pays independent researchers for finding security problems in its systems.
  • DNS: the system that translates hostnames into IP addresses, like a phone book.
  • Gem: a packaged, reusable Ruby library.
  • Hexadecimal: base 16 notation, where 0x7f means 127.
  • Hostname: the human-readable part of a URL, such as example.com.
  • Integration: a connection between two services so they exchange data automatically, here between HackerOne and an issue tracker.
  • IP address: the numeric address of a machine on a network.
  • irb: Ruby's interactive prompt, where you type code and see the result immediately.
  • Jira / Phabricator: issue tracking tools that teams use to record and manage tasks.
  • Loopback address: [redacted], which always means the machine itself.
  • Method: a named block of code that performs a task and can take inputs.
  • Octal: base 8 notation, where 0177 means 127.
  • Port: a numbered channel on a machine, like a numbered door; port 22 is normally SSH.
  • Private address: an IP address that only makes sense inside a local network and should not be reachable from the internet.
  • Resolver: the part of a system that turns a hostname into an IP address.
  • Ruby: a programming language.
  • Ruby Core: the team that maintains the Ruby language itself.
  • Server-side request: a request made by a website's server rather than by your browser.
  • SSH: a protocol for logging in to a machine remotely, normally on port 22.
  • SSRF (Server-Side Request Forgery): a bug where an attacker can choose the address a server fetches, potentially reaching internal machines.
  • URL: a web address.
  • Variable: a named place in a program that holds a value.

More by edoverflow

View all

27 more disclosed reports, best first.

More from HackerOne

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.