CVE-2026-141530: Addressable pure IDNA implementation skips the nameprep bidi rule, so hosts under different domains can display identically
Impact
Nameprep, part of IDNA2003, requires a label with a right-to-left character to have no left-to-right characters, and to start and end with a right-to-left character (Section 6 of RFC 3491 and Section 6 of RFC 3454). Without the rule, two strings with the same characters in a different order can display identically. Addressable::IDNA.tounicode in the pure-Ruby IDNA implementation, and so Addressable::URI#displayuri, doesn't apply the rule, so it decodes labels that break it. The native implementation, which uses libidn, applies the rule and isn't affected.
When a label is next to a right-to-left label, the bidirectional algorithm can display its digits or letters on the other side of the dot between them. A label that breaks the rule lets an attacker choose which side they end up on, so a host under a domain the attacker controls can display identically to a host under a different domain. xn--1-3mcxl0f.23.example, under 23.example, is displayed as 1شركة.23.example, which in a left-to-right context renders the same as شركة.123.example, a host under 123.example.
The practical risk is limited. The target host has to have a right-to-left label with digits next to the dot on either side of it, such as 123 in شركة.123.example, and the attacker needs a domain whose name completes the target's, such as 23.example for a host under 123.example. A user has to trust the displayed host. The rule applies to each label separately, so even with it, two hosts made of valid labels can display identically, such as اب.1.example and 1.اب.example.
Affected Versions
This vulnerability affects Addressable >= 2.0.0 when the pure-Ruby IDNA implementation is in use, which is when the idn-ruby gem isn't installed. It is fixed in 2.10.0, where the pure-Ruby tounicode returns a label that breaks the rule unchanged, as libidn does.
Workarounds
- Install libidn and the idn-ruby gem, so that Addressable uses the native IDNA implementation. - Don't make security decisions on displayuri or tounicode output. Compare hosts using normalizedhost.
Proof of Concept
ruby require "addressable/uri"
%w( https://xn--ogbpi5d.123.example/ https://xn--1-3mcxl0f.23.example/ ).each do |input| uri = Addressable::URI.parse(input) puts uri.displayuri.host end
With the pure-Ruby implementation, affected versions print two hosts that render identically in a left-to-right context:
شركة.123.example 1شركة.23.example
With the native implementation, or in fixed versions, the second line is xn--1-3mcxl0f.23.example.
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.0.0 until 2.10.0, the pure-Ruby Addressable::IDNA.tounicode implementation omits the IDNA2003 nameprep bidirectional-label rule. Addressable::URI#displayuri can render an attacker-controlled host identically to a target host only when the target has a right-to-left label with digits beside a dot and the attacker's complementary domain completes that displayed name. A user who trusts the displayed host can therefore be misled about the actual domain. 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 to a fixed release to a version that resolves this vulnerability.
Fixed in 2.10.0 - Compensating control
Install libidn and the idn-ruby gem so Addressable uses the native IDNA implementation.
- Compensating control
Do not make security decisions based on display_uri or to_unicode output; compare hosts using normalized_host.
Event History
Frequently Asked Questions
Which deployments are affected?
Affected deployments use the pure-Ruby Addressable::IDNA.to_unicode implementation in Addressable versions from 2.0.0 through versions before 2.10.0. The issue is relevant where attacker-controlled hostnames are rendered with Addressable::URI#display_uri and users rely on that displayed hostname.
What conditions are required for exploitation?
An attacker needs to supply a specially complementary domain name, and the target hostname must contain a right-to-left label with digits adjacent to a dot. Exploitation also requires a user to trust the misleading displayed host rather than the actual domain.
Is a default configuration affected?
The provided information identifies the pure-Ruby IDNA implementation as affected, but does not state whether it is used by default in a particular application configuration. Exposure depends on whether the application uses the affected display functionality with attacker-controlled hosts.
What is the remediation?
Upgrade Addressable to version 2.10.0, which fixes the missing IDNA2003 nameprep bidirectional-label rule.