Addressable: Regular Expression Denial of Service in templates with literal text between expressions
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, templates with literal text between expressions generate regular expressions vulnerable to excessive backtracking when a variable before the literal text can also match it. Realistic templates are affected:
/{year}-{month}-{day}, where each variable can contain-/v{major}.{minor}.{patch}, where each variable can contain.{+base}/{+path}/{+file}, where each variable can contain/{+path}/{name}-{+rest}, wherepathcan contain/andnamecan contain-
A run of the literal's characters can be divided among k variables in O(n^k) 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, /{year}-{month}-{day} and {+base}/{+path}/{+file} each take about 10 seconds to reject 2 KB of input on MRI Ruby 2.7, and over 15 seconds on JRuby. Because the cost is cubic for these templates, request-size limits of a few kilobytes don't prevent it.
GHSA-9f42-57jx-vpp3 covered expressions next to each other with no literal text between them. This shape wasn't covered by that advisory or its fix.
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 were yan…
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