CVE-2026-141529: Addressable::Template builds its regexp in quadratic time for patterns with non-ASCII characters or many adjacent expressions

Published Dec 1, 2026
·
Updated

Impact

Addressable::Template builds a regular expression from its pattern the first time it's needed, by #match, #extract, #toregexp, #variables (and its aliases #keys and #names), #variabledefaults or #freeze. When the pattern has non-ASCII characters, or a long run of expressions with no literal text between them (such as {a}{b}{c}), building it takes time quadratic in the pattern's length. A non-ASCII pattern of a few hundred kilobytes takes seconds on MRI and longer on JRuby. A run of 5,000 expressions, 15 KB, takes about 4 seconds on MRI and 8 seconds on JRuby. Other templates build in linear time.

The cost is in the pattern, not in the URI being matched, so only an application that builds templates from untrusted input is affected. Matching untrusted URIs against the application's own templates isn't. The regular expression is cached on the template, so the cost is paid once per template, except that #match and #extract with a processor build it on every call. #expand and #partialexpand don't build it and aren't affected.

Templates from untrusted sources are uncommon, and the attacker needs a pattern of many kilobytes to cause a delay of seconds, so attack complexity is high.

Affected Versions

This vulnerability affects Addressable >= 2.9.1. Version 2.9.1 added a step that looks at what follows each expression. It finds each expression's position by character offset, and for each expression it looks through every later expression with no literal text before it, so either kind of pattern makes building the regular expression quadratic. It is fixed in 2.10.0, where the step works in byte offsets and in a single pass.

Workarounds

- Don't match, extract, list the variables of or freeze templates from untrusted sources, or limit their length. - Reject templates with non-ASCII characters, or pct-encode those characters before building the template, and reject templates with long runs of expressions next to each other.

Proof of Concept

ruby require "addressable/template"

[10000, 20000].each do |count| template = Addressable::Template.new("é{a}" count) started = Process.clockgettime(Process::CLOCKMONOTONIC) template.toregexp elapsed = Process.clockgettime(Process::CLOCKMONOTONIC) - started puts "%6d expressions: %.2fs" % [count, elapsed] end

On affected versions, doubling the number of expressions roughly triples to quadruples the time. On fixed versions, and with a in place of é on any version, it roughly doubles.

The same holds for expressions next to each other, at smaller sizes:

ruby require "addressable/template"

[2500, 5000].each do |count| template = Addressable::Template.new("{a}" count) started = Process.clockgettime(Process::CLOCKMONOTONIC) template.toregexp elapsed = Process.clockgettime(Process::CLOCKMONOTONIC) - started puts "%6d expressions: %.2fs" % [count, elapsed] end

On affected versions, doubling the number of expressions quadruples the time. On fixed versions, and with a{a} in place of {a} on any version, it roughly doubles.

Credits

Found by Bob Aman (@sporkmonger).

For more information

If ther 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.9.1 until 2.10.0, Addressable::Template builds its cached regular expression in quadratic time when an untrusted template pattern contains non-ASCII text or a long run of adjacent expressions. Operations that compile or inspect such templates, including match, extract, toregexp, variables, variabledefaults, and freeze, can consume excessive CPU and cause denial of service. This issue is fixed in version 2.10.0.

— MITRE

Affected Software

3 affected componentsFixes available
rubygems/addressable>=2.9.1<2.10.0
rubygems/addressable>=2.9.1<=2.9.2
2.10.0
rubygems/addressable>=2.9.1<2.10.0
2.10.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade rubygems/addressable to a version that resolves this vulnerability.

    Fixed in 2.10.0
  2. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 2.10.0
  3. Compensating control

    For templates from untrusted sources, do not match, extract, list variables from, or freeze them; limit their length; reject non-ASCII characters or percent-encode them before building the template; and reject long runs of adjacent expressions.

Event History

Dec 1, 2026
CVE Published
via MITRE·09:05 PM
Data Sourced
via MITRE·09:05 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·09:17 PM
DescriptionSeverityWeakness
Advisory Published
via GitHub·11:48 PM
Data Sourced
via GitHub·11:48 PM
DescriptionSeverityWeaknessAffected Software
Data Sourced
via OSV·11:48 PM
Affected Software

Frequently Asked Questions

1

Who is exposed to this denial-of-service issue?

Applications using Addressable::Template versions from 2.9.1 up to, but not including, 2.10.0 are exposed when they compile or inspect attacker-controlled template patterns containing non-ASCII text or long runs of adjacent expressions.

2

Does exploitation require authentication or user interaction?

No. The vector is network-reachable and requires neither privileges nor user interaction, but an attacker must be able to supply a malicious template pattern that the application processes.

3

Which operations can trigger excessive CPU use?

The affected cached regular-expression construction can be triggered by match, extract, to_regexp, variables, variable_defaults, and freeze when used with a crafted template.

4

What is the remediation?

Upgrade Addressable to version 2.10.0, which fixes the issue.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203