GitHub advisory · RubyGems
Addressable::Template#match and #extract take variable names from the URI, so a URI can add or reassign variables
Description
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:
; expression before a path variable;restore acts on a value by its name, such as recording an identifier. restore is called with the name the URI gives, so a query parameter can make restore act again for a variable the template takes from the path. The processor then records the query's value, while the mapping keeps the path's;match pattern to restrict the value of such a variable. Another expression's variable can take the text and give it the restricted variable's name, so the pattern isn't applied.Exploded variables, such as {?q*}, aren't affected: the names they take from the URI are kept inside…
Manual fix · RubyGems
bundle update addressableSources