Addressable native IDNA backend truncates a host at a pct-encoded NUL when normalizing
Affected packages
| Package | Affected → Fixed | |
|---|---|---|
| sporkmongeraddressable | — | Not listed |
| RubyGemsaddressable |
< 2.10.0→ 2.10.0 |
2.10.0 |
Original description The description as published by the source.
Impact
With the native IDNA backend, which Addressable uses when the idn-ruby gem is installed, a host with a pct-encoded NUL is cut short when it is normalized. Addressable::URI#normalized_host decodes the host and passes each label to libidn, which reads the NUL as the end of the string and drops the rest of the label. http://internal.example%00x/ normalizes to http://internal.example/.
#host and #to_s keep the host as written, while #normalize, #normalized_host, #normalized_authority, #normalized_site, #origin and #display_uri give the shortened host, and #== treats the URI as equal to one with the shortened host. An application that checks one form and uses the other can be made to send a request to a host it meant to block: a denylist check of uri.host lets internal.example%00x through, and a request built from uri.normalize or uri.origin goes to internal.example. An application would need to mix the two to be vulnerable.
The pure-Ruby IDNA backend, used when idn-ruby isn't installed, keeps the NUL and isn't affected.
Affected Versions
This vulnerability affects Addressable >= 2.2.5 when the idn-ruby gem is installed. It is fixed in 2.10.0, where the native backend leaves a label with a NUL unchanged, as the pure-Ruby backend does.
Workarounds
- Check the same host you use: if the request is made from
uri.normalizeoruri.origin, checkuri.normalize.host, noturi.host. - Reject a URI whose host contains `…
Source: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory
References
- advisory github.com
- advisory nvd.nist.gov
- package github.com
- web github.com
- web github.com
- web github.com
- web github.com