CVE-2026-141539: Addressable native IDNA backend truncates a host at a pct-encoded NUL when normalizing
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#normalizedhost 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 #tos keep the host as written, while #normalize, #normalizedhost, #normalizedauthority, #normalizedsite, #origin and #displayuri 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.normalize or uri.origin, check uri.normalize.host, not uri.host. - Reject a URI whose host contains %00. - Remove the idn-ruby gem, so Addressable uses the pure-Ruby backend.
Credits
Found by Bob Aman (@sporkmonger).
For more information
If there are any questions or comments about this advisory: Open an issue
Other sources
Addressable is an alternative implementation to the URI implementation that is part of Ruby's standard library. From 2.2.5 until 2.10.0, With the native IDNA backend, Addressable::URI#normalizedhost passes a percent-encoded NUL after decoding to libidn, which truncates the remainder of the label. An application that checks the original host but uses normalize, origin, displayuri, or normalizedhost can be made to send a request to a shortened host that it intended to block. This issue is fixed in version 2.10.0.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
rubygems/addressableto a version that resolves this vulnerability.Fixed in 2.10.0 - Upgrade
Upgrade
Addressableto a version that resolves this vulnerability.Fixed in 2.10.0 - Remove
Remove
idn-rubyfrom your environment.Remove the idn-ruby gem so Addressable uses the pure-Ruby IDNA backend.
- Compensating control
Reject any URI whose host contains %00.
- Compensating control
Check the same host representation that the request uses; for requests made from uri.normalize or uri.origin, check uri.normalize.host rather than uri.host.
Event History
Frequently Asked Questions
Which deployments are affected?
Addressable versions from 2.2.5 up to, but not including, 2.10.0 are affected when using the native IDNA backend. The issue applies where an application validates an original host and later uses a normalized host value.
What does an attacker need to exploit this?
An attacker needs to supply a host containing a percent-encoded NUL and reach an application flow that checks the original host but uses normalize, origin, display_uri, or normalized_host for the resulting request. The decoded NUL can cause libidn to truncate the rest of the label, changing the destination host.
What should be done if the application cannot be upgraded immediately?
Avoid using normalized Addressable host values to make requests when authorization or blocklist decisions were made against the original host. Ensure the host value used for validation is the same value used for the outbound request, and reject percent-encoded NULs in host input.
How can I determine whether an application is exposed?
Review uses of Addressable::URI#normalized_host and related normalize, origin, or display_uri methods. Exposure exists if a host is checked before normalization but a normalized result is subsequently used to select the request destination.