medium

CVE-2026-142591

RubyGems · rack

Summary

Rack: `Rack::QueryParser` separator pattern allocates ~48 bytes per space after `&`, allowing denial of service via memory amplification

Severity
medium
CVSS
5.3
EPSS
0.6% (p51)
CWE
CWE-400
Also known as
GHSA-f7cc-57h7-qrcg
Published
2026-12-03
Updated
2026-12-03

Advisory details

Summary

Rack::QueryParser splits query strings and application/x-www-form-urlencoded bodies on the regular expression /& */n, which also consumes spaces following each &. Matching a long run of spaces with this pattern makes Ruby's regular expression engine allocate about 48 bytes of backtracking state per space, so an input consisting of & followed by spaces causes the process to allocate roughly 48 times the size of the input. This results in a denial of service condition through memory exhaustion for applications that parse query strings or form bodies.

Details

The separator is defined as:

DEFAULT_SEP = /& */n
COMMON_SEP = { ";" => /; */n, ";," => /[;,] */n, "&" => /& */n }

A body of a=1& followed by 4 MiB of spaces then b=2 is one separator match. The match is linear in time (about 20 ms) but allocates about 186 MB of transient memory on top of the 4 MiB input, a factor of 46–48 that holds from 256 KiB (14 MB) to 16 MiB (770 MB). The memory is released after the match, so the peak is set by concurrency: with the default 4 MiB RACK_QUERY_PARSER_BYTESIZE_LIMIT and Puma's default of five threads, five concurrent requests reach about 1 GB. Applications that raise the limit for large forms scale accordingly; a 30 MiB body allocates about 1.5 GB.

RACK_QUERY_PARSER_BYTESIZE_LIMIT bounds the input and therefore the cost per request, but the limit was introduced to cap parsing work at roughly the size of the input, and this multiplies it by about 48. RACK_QUERY_PARSER_PARAMS_LIMIT does not apply, since the input contains only one separator.

The same per-byte cost arises from a second pattern in the parser, without any spaces in the input. When a parameter name uses array syntax, params_hash_has_key? splits the name on /[\[\]]+/; the + quantifier makes a long run of [ or ] characters allocate the same backtracking state. A body of a[][b]=1&a[][ followed by 4 MiB of [ has two parameters, is within the default limits, and allocates about 200 MB while being parsed. Rack 2.2 is additionally affected through normalize_params, where the pattern /\A[\[\]]*([^\[\]]+)\]*/ applied to a long parameter name has the same cost.

All supported versions are affected. The space-consuming separator dates from the first Rack release.

Impact

Any application that reads request.params, request.GET or request.POST is affected in its default configuration. An unauthenticated attacker sending a single urlencoded body or query string consisting mostly of spaces, or mostly of bracket characters in a parameter name, causes the process to allocate about 48 times the request size; several concurrent requests can exceed the memory of a small container and trigger the out-of-memory killer. No authentication is required, since the body is parsed before any session or CSRF check, and the request is well-formed HTTP. Normal clients never send unencoded spaces after &, as browsers encode them as + or %20.

Mitigation

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.