Addressable URI normalization takes quadratic time on long runs of combining marks
Affected packages
| Package | Affected → Fixed | |
|---|---|---|
| sporkmongeraddressable | — | Not listed |
| rubygemsaddressable |
≥ 2.0.0, < 2.10.0→ 2.10.0 |
2.10.0 |
Original description The description as published by the source.
Impact
Normalizing a URI that contains a long run of combining marks takes time quadratic in the length of the run. A 16 kB path takes about 2 seconds of CPU time. The marks can also be pct-encoded, so a URI with only ASCII characters triggers it. An attacker who can submit a URI that an application normalizes, compares or matches against a template can hold a worker for seconds per request, and for over a minute with longer input. There is no confidentiality or integrity impact.
String#unicode_normalize orders the combining marks after a character with a loop that is quadratic in their number, and Addressable calls it on attacker-controlled text. It is reached from:
URI.normalize_component, so#normalize,#normalized_pathand the othernormalized_*methods,#==,#===,#display_uri,#route_fromand#route_toURI.normalized_encodeTemplate#expand,#matchand#extractIDNA.to_asciiwith the pure-Ruby IDNA implementation, for hosts. With the native implementation (libidn), the host is linear.
URI.parse by itself doesn't normalize and is unaffected.
Affected Versions
This vulnerability affects Addressable >= 2.0.0. Versions 2.0.0 through 2.2.4 are affected on every Ruby. From 2.2.5 on, it affects only Rubies whose String#unicode_normalize has the quadratic loop: every Ruby 3.2 release and earlier, 3.3.0 through 3.3.10 and 3.4.0 through 3.4.7. Ruby 3.3.11, 3.4.8 and 4.0.0 fixed the loop. It is fixed in 2.10.0 on every Ruby, w…
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