CVE-2026-141525
JSON

5.9medium

Addressable: Regular Expression Denial of Service in Addressable templates on MRI Ruby 3.2 and TruffleRuby

Severity
5.9medium CVSS:3.1 by GitHub_M
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-jrfq-gw62-2f3j

Description

Addressable is an alternative implementation to the URI implementation that is part of Ruby's standard library. From 2.9.1 until 2.10.0, Addressable URI template regular expressions containing lookaround assertions can lose regular-expression memoization on MRI Ruby 3.2 and can backtrack on TruffleRuby 40.0. Calling Template#match or Template#extract with a crafted URI against an affected template can consume polynomial CPU time and cause denial of service. The remediation does not cover processor-supplied variable patterns or certain templates that combine exploded or multi-variable expressions with other expressions, which can remain polynomial on MRI Ruby before 3.3, JRuby, and TruffleRuby. This issue is fixed in version 2.10.0.

Affected

Product or packageVersionsReported by
sporkmonger addressable>= 2.9.1, < 2.10.0CVE List
addressable (RubyGems)from 2.9.1 before 2.10.0GitHub Advisory Database

All scores

GitHub_M5.9medium CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H
GitHub5.9medium CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H

Classification

What each source says

CVE List

Addressable is an alternative implementation to the URI implementation that is part of Ruby's standard library. From 2.9.1 until 2.10.0, Addressable URI template regular expressions containing lookaround assertions can lose regular-expression memoization on MRI Ruby 3.2 and can backtrack on TruffleRuby 40.0. Calling Template#match or Template#extract with a crafted URI against an affected template can consume polynomial CPU time and cause denial of service. The remediation does not cover processor-supplied variable patterns or certain templates that combine exploded or multi-variable expressions with other expressions, which can remain polynomial on MRI Ruby before 3.3, JRuby, and TruffleRuby. This issue is fixed in version 2.10.0.

GitHub Advisory Database
Impact

Addressable 2.9.1 changed the regular expressions generated for URI templates to fix GHSA-9f42-57jx-vpp3 and GHSA-4w5q-wg7v-w6gp. The new regular expressions contain lookaround assertions for some expressions, such as {a}{b}, {a,b}, {/a,b}, {?a*,b} and expressions with an exploded variable followed by unexploded ones. MRI Ruby 3.2 doesn't memoize a regular expression that contains a lookaround, and memoization is decided for the whole template's regular expression, so one such expression makes the rest of the template backtrack as on older Rubies. TruffleRuby 40.0 also backtracks for some of these regular expressions.

As a result, templates that 2.9.0 matched in linear time on these runtimes are polynomial since 2.9.1. On MRI Ruby 3.2, this includes templates that combine a common shape with one of those expressions, such as /{year}-{month}-{day}/{a}{b}. 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, on MRI Ruby 3.2:

  • /{year}-{month}-{day}/{a}{b} takes 12 seconds to reject 2 KB of input. With 2.9.0, it takes under 0.001 seconds.
  • {?a,a*,a*}{a*}{.a*,b*,c} takes over 15 seconds to reject 2 KB of input. With 2.9.0, it takes 0.001 seconds.
  • {?a*,b,c*} takes about 1 second to reject 19 KB of input. With 2.9.0, it takes 0.003 seconds.
  • {a,b}{c,d}{e,f} takes 2.9 seconds to reject 1 KB of input. With 2.9.0, it takes under 0.001 seconds.

On TruffleRuby 40.0, {?a,a*,a*}{a*}{.a*,b*,c} takes over 10 minutes to reject 2 KB of input, and {?a*,b,c*} takes 7.7 seconds to reject 19 KB. With 2.9.0, each takes under 0.01 seconds.

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.9.1, including 2.9.2, on MRI Ruby 3.2 and TruffleRuby 40.0. It is fixed in 2.10.0, with two exceptions where matching can still take polynomial time on MRI Ruby < 3.3, JRuby and TruffleRuby: when a processor's match method gives a variable its own pattern, since 2.10.0 then keeps every choice open, as earlier versions did, so that the pattern decides the values; and for some templates that combine an exploded variable, or several variables in one expression, with other expressions, such as {+c*,d}{&b}.{b}.

MRI Ruby 3.3 and later memoize regular expressions with lookarounds and are not affected. On MRI Ruby < 3.2 and JRuby, which don't memoize, these templates were already slow with 2.9.0 and are covered by GHSA-xj9m-f88p-5j38, GHSA-xfg6-27c4-wr4r and GHSA-grhv-8jgq-r74x. MRI Ruby 3.2 reached its end of life on 2026-03-31. Earlier TruffleRuby versions were not tested.

This has been confirmed on the following runtimes with Addressable 2.9.2:

RuntimeStatus
MRI Ruby 2.7Not affected by this issue
MRI Ruby 3.1Not affected by this issue
MRI Ruby 3.2Vulnerable
MRI Ruby 3.3Not affected
MRI Ruby 4.0Not affected
JRuby 9.4Not affected by this issue
TruffleRuby 40.0Vulnerable
Workarounds
  • Upgrade to MRI Ruby 3.3 or later.
  • Limit the length of user-supplied URIs before matching them. Because the cost is polynomial, this only bounds it, but it works on every runtime, including TruffleRuby, where a timeout doesn't.
  • On MRI Ruby 3.2, apply a short timeout, such as Timeout.timeout, around any call to Template#match or Template#extract that processes user-supplied data. It interrupts the matching thread at an arbitrary point, so it isn't safe in every application. On TruffleRuby, it doesn't stop a regular expression match.
  • On MRI Ruby 3.2, setting Regexp.timeout makes a slow match raise Regexp::TimeoutError. It applies to every regular expression in the process.
Credits

Found by Bob Aman (@sporkmonger).

For more information

If there are any questions or comments about this advisory:

References

Sources

SourceRecordLicence
CVE ListCVE-2026-141525 changed 2026-12-01CVE Terms of Use
GitHub Advisory DatabaseGHSA-jrfq-gw62-2f3j changed 2026-12-01CC-BY-4.0
NVDCVE-2026-141525 changed 2026-12-01Public domain