# GHSA-F7CC-57H7-QRCG: Summary Rack::QueryParser splits query strings and application/x-www-form-urlencoded bodies on the regular expression /& \*/n, which also consumes spaces following each &

- Database: GitHub
- Severity: CVSS 5.3 (Medium)
- Published: 2026-11-20
- Modified: 2026-12-02

## Tracked as

- [CVE-2026-142591](https://cve.now/CVE-2026-142591.md): Rack is a modular Ruby web server interface

## Affected versions

- rack (RubyGems): fixed in 2.2.26
- rack (RubyGems): from 3.0, fixed in 3.1.24
- rack (RubyGems): from 3.2, fixed in 3.2.9

## Description

## 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:

```ruby
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

* Update to a patched version of Rack, in which the separator is matched as a plain string, leading spaces are removed from each pair without a regular expression, and parameter names are split on brackets without a quantified pattern.
* Lower `RACK_QUERY_PARSER_BYTESIZE_LIMIT` to the largest form body the application actually needs; the transient allocation is about 48 times that value per concurrent request.
* At a reverse proxy, reject requests whose query string or urlencoded body contains unencoded space characters.

## References

- https://github.com/rack/rack/security/advisories/GHSA-f7cc-57h7-qrcg

Page: https://cve.now/GHSA-F7CC-57H7-QRCG

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
