CVE-2026-142592: Denial of Service via Multipart Charset Encoding Resolution in Rack
Vulnerability ID: CVE-2026-142592
CVSS Score: 7.5
Published: 2026-12-03
CVE-2026-142592 is an uncontrolled resource consumption vulnerability (CWE-400) in Rack, the modular Ruby web server interface. In affected versions within the 3.1.x and 3.2.x branches, the multipart form-data parser directly passes untrusted charset parameters to Ruby's internal Encoding.find method without pre-validation or caching. Because Ruby's MRI runtime traverses the entire $LOAD_PATH searching for shared libraries whenever an unknown encoding is requested, an unauthenticated attacker can submit a multipart payload with thousands of invalid charset parameters to trigger millions of filesystem lookup operations, exhausting CPU and I/O resources and causing denial of service.
TL;DR
Unauthenticated remote attackers can cause CPU and filesystem I/O exhaustion in Ruby web applications using Rack 3.0.0 through 3.1.23 and 3.2.0 through 3.2.8 by sending crafted multipart/form-data requests containing thousands of invalid charset directives. Upgrade to Rack 3.1.24 or 3.2.9 to resolve the issue.
⚠️ Exploit Status: POC
Technical Details
- CVE ID: CVE-2026-142592 (GHSA-58mf-c3jj-277p)
- Weakness Class: CWE-400: Uncontrolled Resource Consumption
- CVSS v3.1 Score: 7.5 HIGH (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H)
- EPSS Score: 0.64% (52.32nd Percentile)
- Attack Vector: Unauthenticated Network HTTP Multipart POST Request
- Affected Component: Rack::Multipart::Parser#find_encoding (lib/rack/multipart/parser.rb)
- Patched Versions: Rack 3.1.24 and Rack 3.2.9 (Rack 2.2.x is not affected)
- CISA KEV Status: Not Listed
Affected Systems
- Ruby Gem: rack (>= 3.0.0, < 3.1.24)
- Ruby Gem: rack (>= 3.2.0, < 3.2.9)
- Ruby on Rails, Sinatra, Hanami, and other Ruby web frameworks utilizing vulnerable Rack 3.x releases
- 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: 7c16c66
Pre-validate multipart charset encodings against Encoding.name_list set before invoking Encoding.find (v3.1 branch)
@@ -1,5 +1,6 @@ # frozen_string_literal: true +require 'set' require 'strscan' require_relative '../utils' @@ -643,13 +644,27 @@ def tag_multipart_encoding(filename, content_type, name, body) body.force_encoding(encoding) end + ENCODING_NAMES = Set.new(Encoding.name_list.map(&:downcase)).freeze + private_constant :ENCODING_NAMES + # Return the related Encoding object. However, because # enc is submitted by the user, it may be invalid, so # use a binary encoding in that case. def find_encoding(enc) - Encoding.find enc - rescue ArgumentError - Encoding::BINARY + if respect_requested_encoding?(enc) + begin + Encoding.find(enc) + rescue ArgumentError + nil + end + end || Encoding::BINARY + end + + # Whether to respect the given encoding (given as a string). If a + # requested encoding is not respected, binary encoding is used. + # The string may be nil or in any encoding, so compare it as bytes. + def respect_requested_encoding?(encoding_string) + ENCODING_NAMES.include?(encoding_string.to_s.b.downcase(:ascii)) end REENCODE_DUMMY_ENCODINGS = { Commit: 8ae2ea8
Pre-validate multipart charset encodings against Encoding.name_list set before invoking Encoding.find (v3.2 branch)
@@ -1,5 +1,6 @@ # frozen_string_literal: true +require 'set' require 'strscan' require_relative '../utils' @@ -643,13 +644,27 @@ def tag_multipart_encoding(filename, content_type, name, body) body.force_encoding(encoding) end + ENCODING_NAMES = Set.new(Encoding.name_list.map(&:downcase)).freeze + private_constant :ENCODING_NAMES + # Return the related Encoding object. However, because # enc is submitted by the user, it may be invalid, so # use a binary encoding in that case. def find_encoding(enc) - Encoding.find enc - rescue ArgumentError - Encoding::BINARY + if respect_requested_encoding?(enc) + begin + Encoding.find(enc) + rescue ArgumentError + nil + end + end || Encoding::BINARY + end + + # Whether to respect the given encoding (given as a string). If a + # requested encoding is not respected, binary encoding is used. + # The string may be nil or in any encoding, so compare it as bytes. + def respect_requested_encoding?(encoding_string) + ENCODING_NAMES.include?(encoding_string.to_s.b.downcase(:ascii)) end REENCODE_DUMMY_ENCODINGS = { Mitigation Strategies
- Upgrade the Rack gem to version 3.1.24 or 3.2.9 to ensure encoding names are pre-validated against an in-memory Set of registered Ruby encodings before invoking Encoding.find.
- For applications pinned to unsupported Rack 3.0.x releases that cannot immediately upgrade, apply an application initializer monkey-patch to override Rack::Multipart::Parser#find_encoding with Set-based pre-validation.
- Deploy Web Application Firewall (WAF) or reverse proxy rules to inspect multipart/form-data request bodies and block requests where any individual part Content-Type header contains more than one charset= parameter or an excessive count of semicolon delimiters.
- Enforce strict request body size limits (e.g., NGINX client_max_body_size) on endpoints that do not require large file uploads to reduce the maximum number of parameters an attacker can transmit in a single request.
Remediation Steps:
- Audit the application's Gemfile.lock to determine the currently installed version of the rack gem (
bundle info rackorgrep -A 2 "rack (" Gemfile.lock). - Update the Gemfile to require
rack >= 3.1.24(if on 3.0.x or 3.1.x) orrack >= 3.2.9(if on 3.2.x). - Run
bundle update --conservative rackto update only the rack gem without inadvertently upgrading unrelated dependencies. - Execute the application test suite and verify the fix using the regression test from Rack's test/spec_multipart.rb to ensure unknown charsets immediately resolve to Encoding::BINARY without triggering filesystem lookups.
- Redeploy the application and restart all Ruby application server worker processes (Puma, Unicorn, Falcon, or Passenger).
References
- GitHub Security Advisory GHSA-58mf-c3jj-277p: Rack Multipart parser searches the load path for every unknown part charset
- Rack Patch Commit 7c16c669fe2040ac395cf05a242f80527ddab16b (v3.1 branch)
- Rack Patch Commit 8ae2ea868a13eec2cfa7065a1ea8b527c567fad9 (v3.2 branch)
- Rack v3.1.24 Release
- Rack v3.2.9 Release
- NVD - CVE-2026-142592 Detail
- CVE.org Record: CVE-2026-142592
- CVEProject cvelistV5 Record for CVE-2026-142592
Read the full report for CVE-2026-142592 on our website for more details including interactive diagrams and full exploit analysis.
