CVE-2026-142591: CVE-2026-142591: Denial of Service via Regex Memory Amplification in Rack QueryParser
CVE-2026-142591: Denial of Service via Regex Memory Amplification in Rack QueryParser Vulnerability ID: CVE-2026-142591 CVSS Score: 5.3 Published: 2026-12-03 CVE-2026-142591 (GHSA-f7cc-57h7-qrcg) is an uncontrolled
CVE-2026-142591: Denial of Service via Regex Memory Amplification in Rack QueryParser
Vulnerability ID: CVE-2026-142591
CVSS Score: 5.3
Published: 2026-12-03
CVE-2026-142591 (GHSA-f7cc-57h7-qrcg) is an uncontrolled resource consumption vulnerability in the Rack Ruby web server interface library. The flaw resides in Rack::QueryParser, which uses quantified regular expressions to split query strings, parse application/x-www-form-urlencoded request bodies, and evaluate nested parameter names. In Ruby's Onigmo regular expression engine, greedy quantifiers allocate approximately 48 bytes of native backtracking state per matched character. An unauthenticated remote attacker can transmit crafted payloads containing long runs of spaces or bracket characters within Rack's default 4 MiB byte-size limit to trigger an approximate 48x transient memory amplification, allocating up to 200 MB per request and exhausting process or container memory under concurrent load.
TL;DR
Quantified regular expressions in Rack::QueryParser cause Ruby's Onigmo regex engine to allocate 48 bytes of native backtracking state per matched character when processing long runs of spaces or square brackets. Unauthenticated attackers can achieve a 48x memory amplification (~200 MB per 4 MiB request), leading to Out-Of-Memory (OOM) Denial of Service across Rack versions prior to 2.2.26, 3.1.24, and 3.2.9.
⚠️ Exploit Status: POC
Technical Details
- Vulnerability Type: Uncontrolled Resource Consumption / Memory Amplification (CWE-400)
- Affected Component: Rack::QueryParser (lib/rack/query_parser.rb)
- Attack Vector: Network (Unauthenticated HTTP GET/POST)
- CVSS v3.1 Score: 5.3 Medium (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L)
- EPSS Score: 0.61% (50.52nd Percentile)
- Amplification Factor: ~48 bytes per character (~192 MB per 4 MiB request)
- Exploit Status: Proof-of-Concept in unit tests; Not in CISA KEV
- Fixed Versions: Rack 2.2.26, 3.1.24, 3.2.9
Affected Systems
- Ruby on Rails applications using vulnerable Rack versions
- Sinatra, Hanami, and Roda web applications using vulnerable Rack versions
- Ruby web servers (Puma, Unicorn, Falcon, Passenger) running Rack < 2.2.26, >= 3.0.0 < 3.1.24, or >= 3.2.0 < 3.2.9
-
rack: < 2.2.26 (Fixed in:
2.2.26) -
rack: >= 3.0.0, < 3.1.24 (Fixed in:
3.1.24) -
rack: >= 3.2.0, < 3.2.9 (Fixed in:
3.2.9)
Code Analysis
Commit: 59fae90
Avoid regexp backtracking state allocation in QueryParser (Rack 3.2 branch)
File: lib/rack/query_parser.rb
@@ -5,8 +5,8 @@
module Rack
class QueryParser
- DEFAULT_SEP = /& */n
- COMMON_SEP = { ";" => /; */n, ";," => /[;,] */n, "&" => /& */n }
+ DEFAULT_SEP = "&"
+ COMMON_SEP = { ";" => ";", ";," => /[;,]/n, "&" => "&" }
# ParameterTypeError is the error that is raised when incoming structural
# parameters (parsed by parse_nested_query) contain conflicting types.
@@ -210,10 +210,17 @@ def params_hash_type?(obj)
def params_hash_has_key?(hash, key)
return false if /\[\]/.match?(key)
- key.split(/[\[\]]+/).inject(hash) do |h, part|
- next h if part == ''
- return false unless params_hash_type?(h) && h.key?(part)
- h[part]
+ # Equivalent to walking key.split(/[\[\]]+/), but a quantified regexp
+ # allocates backtracking state for every bracket matched, so find the
+ # segments with single character searches instead, which do not
+ # backtrack.
+ pos = 0
+ while (start = key.index(/[^\[\]]/, pos))
+ stop = key.index(/[\[\]]/, start) || key.length
+ part = key[start, stop - start]
+ return false unless params_hash_type?(hash) && hash.key?(part)
+ hash = hash[part]
+ pos = stop
end
true
@@ -226,7 +233,14 @@ def each_query_pair(qs, separator, unescaper = nil)
raise QueryLimitError, "total query size exceeds limit (#{@bytesize_limit})"
end
- pairs = qs.split(separator ? (COMMON_SEP[separator] || /[#{separator}] */n) : DEFAULT_SEP, @params_limit + 1)
+ pairs = qs.split(separator ? (COMMON_SEP[separator] || /[#{separator}]/n) : DEFAULT_SEP, @params_limit + 1)
+
+ # Remove spaces following the separator. A quantified regexp such as
+ # /& */ allocates backtracking state for every space matched, so find
+ # the first non-space character instead, which does not backtrack.
+ pairs.each do |pair|
+ pair.slice!(0, pair.index(/[^ ]/) || pair.length) if pair.getbyte(0) == 32
+ end
if pairs.size > @params_limit
param_count = pairs.size + pairs.last.count(separator || "&")
Commit: d895d94
Backport QueryParser non-backtracking fix to Rack 3.1 branch
Commit: bc0ad07
Backport QueryParser and normalize_params non-backtracking fix to Rack 2.2 branch
Exploit Details
- GitHub: Official patch commit containing regression test specifications in test/spec_query_parser.rb demonstrating the space and bracket amplification payloads.
Mitigation Strategies
- Upgrade the Rack gem to version 2.2.26, 3.1.24, or 3.2.9 to replace quantified regex splitting with linear non-backtracking string indexing.
- Lower the Rack::QueryParser bytesize_limit in an application initializer from the 4 MiB default to 64 KiB (65,536 bytes) to restrict maximum memory amplification.
- Enforce strict URI and query string length limits (e.g., 8 KiB to 32 KiB) and constrain client_max_body_size on application/x-www-form-urlencoded endpoints at the reverse proxy layer.
- Deploy WAF inspection rules to drop requests containing long consecutive runs of ASCII space characters or square brackets in query strings and form bodies.
Remediation Steps:
- Audit the application's Gemfile.lock to identify the installed version of the rack gem (
bundle list | grep rack). - Update the Gemfile to require
>= 2.2.26(for 2.x),>= 3.1.24(for 3.1.x), or>= 3.2.9(for 3.2.x) and runbundle update rack. - Run the application test suite to verify compatibility and redeploy all web and background worker containers.
- If patching is delayed, create an initializer configuring
Rack::Utils.default_query_parser = Rack::QueryParser.make_default(Rack::Utils.key_space_limit, 65536)and apply WAF filtering rules.
References
- GitHub Security Advisory GHSA-f7cc-57h7-qrcg
- Rack 3.2 Fix Commit (59fae908d13587922bb29a89c161441d4de0cab6)
- Rack 3.1 Fix Commit (d895d94b88a3233eb0f2e59d3ddb9fc6a0b630ef)
- Rack 2.2 Fix Commit (bc0ad07de8603e545fb07936c8d28b9e7ec29804)
- Rack v3.2.9 Release
- Rack v3.1.24 Release
- Rack v2.2.26 Release
- NVD - CVE-2026-142591
- CVE.org Record - CVE-2026-142591
- MITRE ATT&CK T1499 - Endpoint Denial of Service
Read the full report for CVE-2026-142591 on our website for more details including interactive diagrams and full exploit analysis.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.