Addressable: Regular Expression Denial of Service in templates with exploded variables next to other variables
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
Within the URI template implementation in Addressable, some templates with exploded variables still generate regular expressions vulnerable to excessive backtracking. GHSA-4w5q-wg7v-w6gp reported expressions with several exploded variables and listed 2.9.1 as patched, but its fix didn't cover these shapes:
- An exploded expression directly before an expression with exploded variables (e.g.,
{a*}{.a*,b*,c}), which is cubic in the input length. - Several exploded variables in a
.or default expression (e.g.,{.a*,b*,c}, which is quadratic, or{c*,d*,a*}, which is cubic). - An unexploded variable between exploded ones in a
?or&expression (e.g.,{?a*,b,c*}), which is quadratic in the number of members. - An exploded variable followed by unexploded ones in a
/,.or default expression (e.g.,{a*,b,c}-), which is quadratic.
A run of members can be divided among the variables in many ways. When Template#match or Template#extract is called with a maliciously crafted URI, this can result in uncontrolled resource consumption, leading to denial of service. With 2.9.2, {a*}{.a*,b*,c} takes over 6 seconds to reject 800 bytes of input on MRI Ruby 2.7, and over 15 seconds on JRuby.
Users of the URI parsing capabilities in Addressable but not the URI template matching capabilities are unaffected. Users who only call Template#expand are unaffected.
Affected Versions
This vulnerability affects Addressable >= 2.3.0 (note: 2.3.0 and 2.3.1 w…
Source: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory
References
- advisory github.com
- package github.com
- web github.com
- web github.com
- web github.com
- web nvd.nist.gov
- web github.com