All vulnerabilities

RubyGems

CVE-2026-141535

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

Severity
Low 3.7
Published
1 Dec 2026
Last changed
2 Dec 2026
Added to UpHeron
2 Dec 2026
Fixed in
2.10.0
Weakness
Improper input validation (CWE-20)CWE-436Server-side request forgery (CWE-918)
Attack
Over the network · Only under certain conditions · No login needed · No user action needed
Attacker can
Read some data
CVSS vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N
Also known as
GHSA-c7j3-jq7p-v3pr
Sources
OSV.dev and GitHub

Description

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:

From the GitHub Advisory Database, CC BY 4.0. Shortened; the full text is there.

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.
Workarounds as given by the GitHub Advisory Database, CC BY 4.0.

Affected software

SoftwareAffected versions
addressableRubyGems · osv:RubyGems:addressable
  • From 2.3.5 before 2.10.0

About addressable

Total downloads (RubyGems)
1,323,514,580RubyGems, 1 Dec 2026

References