low

CVE-2026-141524

RubyGems · addressable

Summary

Addressable::Template#match and #extract take variable names from the URI, so a URI can add or reassign variables

Severity
low
CVSS
3.7
EPSS
0.7% (p53)
CWE
CWE-20, CWE-915
Also known as
GHSA-q5vw-6v74-fg2g
Published
2026-12-01
Updated
2026-12-01

Advisory details

Impact

Addressable::Template#match and #extract take the name of a variable in a ;, ? or & expression from the URI, not from the template, when the variable isn't exploded. The template /search{?q} matches /search?admin=true and gives {"q" => nil, "admin" => "true"}: the mapping has a variable the template doesn't have, and q is missing its value. The URI can also give its value to another of the template's variables, which takes the first value it's given. /files{;version}/{id} matches /files;id=secret/42 and gives id the value "secret", not the 42 in its place in the path.

A URI Template can only expand such a variable to its own name followed by = (Sections 3.2.7 to 3.2.9 of RFC 6570), and matching assigns the parts of a URI "to the named variables" (Section 1.4). So these URIs aren't expansions of the template, and the mappings name variables that the URI's text doesn't give them.

An application is affected if it matches an untrusted URI against a template with an unexploded ;, ? or & expression, and does one of these:

Exploded variables, such as {?q*}, aren't affected: the names they take from the URI are kept inside the variable's value. Templates without ;, ? or & expressions aren't affected, and neither is #expand.

Affected Versions

This vulnerability affects Addressable >= 2.3.0, the first version with RFC 6570 templates. Before 2.3.6, a URI can only add variables to the mapping, which then leaves out the variable whose value the URI took; giving a value to another of the template's variables, and the processor case, start with 2.3.6. It is fixed in 2.10.0, where an unexploded ;, ? or & expression only matches its own variables' names, so these URIs don't match. A processor's match pattern for such a variable then matches only its value, as documented, not the name and = as well, and restore is only called with the template's names.

Workarounds

Proof of Concept

require "addressable/template"

search = Addressable::Template.new("/search{?q}")
p search.extract("/search?admin=true")

files = Addressable::Template.new("/files{;version}/{id}")
p files.extract("/files;id=secret/42")

# Workaround: keep only the template's variables, and accept the URI only
# if they expand back to it.
def extract_strictly(template, uri)
  mapping = template.extract(uri)
  return nil unless mapping
  mapping = mapping.select { |name, _| template.variables.include?(name) }
  template.expand(mapping).to_s == uri ? mapping : nil
end
p extract_strictly(search, "/search?admin=true")
p extract_strictly(files, "/files;id=secret/42")
p extract_strictly(files, "/files;version=2/42")

Affected versions print:

{"q" => nil, "admin" => "true"}
{"version" => nil, "id" => "secret"}
nil
nil
{"version" => "2", "id" => "42"}

Fixed versions print:

nil
nil
nil
nil
{"version" => "2", "id" => "42"}

Credits

Found by Bob Aman (@sporkmonger).

For more information

If there are any questions or comments about this advisory:

References

Related advisories

Is your project exposed to this? Stateward checks every dependency on every pull request and flags it only if your code actually reaches it.

Check my repo

Summarize with AI

ChatGPTClaudePerplexity

Sources: CISA KEV (public domain), OSV.dev & GitHub Advisory Database (CC-BY-4.0), FIRST EPSS, NVD/CWE (public domain). Served live from the Stateward advisory database.