{"id":"GHSA-qrq6-rcpx-pmm6","summary":"Addressable URI userinfo setters store delimiters raw, so the serialized URI names a different host","details":"### Impact\n\n`Addressable::URI#user=`, `#password=`, `#userinfo=` and the matching `Addressable::URI.new` options store the value they are given without encoding or rejecting delimiters. A value containing `/`, `?` or `#` ends the userinfo early when the URI is serialized, so `#to_s` names a different host than `#host` and `#origin` report.\n\nThe URI object keeps the component as assigned, and its own accessors agree with each other: `host` is the host the application set, and `origin` is built from it. `#to_s` joins the components with their delimiters but doesn't encode them, so `user = \"alice@evil.example/\"` serializes as `https://alice@evil.example/@api.example.com/…`. Addressable and Ruby's `URI` both read `evil.example` as the host of that string. A `[` or `]` in the userinfo makes the serialized URI fail to parse, a `:` in the user moves the rest of it into the password, and browsers read a `\\` as a `/`, ending the userinfo there. `#normalize` encodes all of these correctly.\n\nAn application that puts an untrusted value into the userinfo of a URI for a trusted host, checks `host` or `origin`, and then passes `to_s` to an HTTP client sends the request to a host the attacker chose. Headers or a body meant for the trusted service, such as an API token, go with it. The attacker needs the application to build URIs this way, so attack complexity is high.\n\n### Affected Versions\n\nThis vulnerability affects Addressable \u003e= 2.0.0. In 2.9.2, `#userinfo=` ignores a value without a colon, so the injected text has to follow one, as in `u:x@evil.example/`. It is fixed in 2.10.0, where `#user=`, `#password=`, `#userinfo=`, `#authority=`, `URI.new` and `URI.parse` raise `InvalidURIError` for `/`, `?`, `#`, `[`, `]` or `\\` in the user or password, or `:` in the user. An `@` is still accepted: the last `@` ends the userinfo, so it reads the same once serialized.\n\n### Workarounds\n\n- Serialize with `uri.normalize.to_s`, which encodes the delimiters, instead of `uri.to_s`.\n- Encode userinfo values before assigning them, for example with `Addressable::URI.encode_component(value, Addressable::URI::CharacterClasses::UNRESERVED)`.\n- Check the host of the final string with `Addressable::URI.parse(uri.to_s).host`, not of the object.\n\n### Credits\n\nFound by Bob Aman (@sporkmonger).\n\n### For more information\n\nIf there are any questions or comments about this advisory:\n* [Open an issue](https://github.com/sporkmonger/addressable/issues)","aliases":["CVE-2026-141538"],"modified":"2026-12-02T00:00:04.145338401Z","published":"2026-12-01T23:52:47Z","database_specific":{"nvd_published_at":null,"cwe_ids":["CWE-436","CWE-74"],"severity":"MODERATE","github_reviewed":true,"github_reviewed_at":"2026-12-01T23:52:47Z"},"references":[{"type":"WEB","url":"https://github.com/sporkmonger/addressable/security/advisories/GHSA-qrq6-rcpx-pmm6"},{"type":"WEB","url":"https://github.com/sporkmonger/addressable/commit/651722f370f679ce4cdf64ed1d2c9527d5e6958b"},{"type":"PACKAGE","url":"https://github.com/sporkmonger/addressable"},{"type":"WEB","url":"https://github.com/sporkmonger/addressable/releases/tag/addressable-2.10.0"}],"affected":[{"package":{"name":"addressable","ecosystem":"RubyGems","purl":"pkg:gem/addressable"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.0.0"},{"fixed":"2.10.0"}]}],"versions":["2.0.0","2.0.1","2.0.2","2.1.0","2.1.1","2.1.2","2.2.0","2.2.1","2.2.2","2.2.3","2.2.4","2.2.5","2.2.6","2.2.7","2.2.8","2.3.2","2.3.3","2.3.4","2.3.5","2.3.6","2.3.7","2.3.8","2.4.0","2.5.0","2.5.1","2.5.2","2.6.0","2.7.0","2.8.0","2.8.1","2.8.10","2.8.2","2.8.3","2.8.4","2.8.5","2.8.6","2.8.7","2.8.8","2.8.9","2.9.0","2.9.1","2.9.2"],"database_specific":{"last_known_affected_version_range":"\u003c= 2.9.2","source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/12/GHSA-qrq6-rcpx-pmm6/GHSA-qrq6-rcpx-pmm6.json"}}],"schema_version":"1.9.2","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:N"}]}