HighGHSA-58mf-c3jj-277pCVE-2026-142592

Rack: Multipart parser searches the load path for every unknown part `charset`, allowing denial of service via CPU exhaustion

Published 3 Dec 2026 · Updated 4 Dec 2026

Affected packages

rackRubyGems
Affected
>=3.0.0 <3.1.24
Fixed in
3.1.24
Update to the fixed version for your release line, for example:bundle update --conservative rack # Gemfile: '>= 3.1.24'
rackRubyGems
Affected
>=3.2.0 <3.2.9
Fixed in
3.2.9
Update to the fixed version for your release line, for example:bundle update --conservative rack # Gemfile: '>= 3.2.9'

We confirm your address first. See our privacy policy.

Which rack does your project really install?

Drop your Gemfile.lock hereWe find the exact rack version you install, even when another package pulls it in, and tell you if it’s affected and what to run. Free, no sign-up.

Works for private projects: the file is read in memory to run the scan and then dropped. Also reads Gemfile.

Public repo?

Look after several Rails or Ruby apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie

Details

Summary

Rack::Multipart::Parser#tag_multipart_encoding calls Encoding.find once for every charset parameter in the Content-Type header of a multipart part. When the name is not a known encoding, Ruby's Encoding.find attempts to load an encoding library of that name, which searches every directory on $LOAD_PATH before failing. Rack rescues the resulting ArgumentError and falls back to binary, does not remember the failure, and does not limit the number of charset parameters a part may carry. An attacker can send a part whose Content-Type contains thousands of unknown charset parameters, and each one costs a full load-path search. This results in a denial of service condition for applications that accept multipart requests.

Details

The relevant code is:

if k == "charset"
  encoding = find_encoding(v)
end

def find_encoding(enc)
  Encoding.find enc
rescue ArgumentError
  Encoding::BINARY
end

For a name absent from Encoding.name_list, Encoding.find calls load_encoding in encoding.c, which requires enc/<name>.so through Ruby's internal loader. The lookup is not cached, is not visible to RubyGems or Bootsnap, and costs roughly 3–5 µs per $LOAD_PATH entry: about 30 µs on a bare Ruby, about 500 µs in a Bundler application with 200 load-path entries on macOS, and about 2.5 ms per lookup measured on Linux with 167 entries.

Each ;charset=x costs 10 bytes. Existing limits do not bound the attack: the part limit (RACK_MULTIPART_PART_LIMIT, 4096) counts parts, not parameters; the 64 KiB part header limit is only enforced when a header spans two reads, so a single header of up to the 1 MiB buffer size is accepted; and part headers count toward the 16 MiB retained-size limit, which allows about 1.6 million lookups per request. A single part with 4000 unknown charset parameters (64 KB) takes about 1.7 s to parse in a mid-sized Bundler application; a 1 MB request with 16 such parts takes 27–40 s. Through Puma in a default Rails application, four concurrent 1 MB requests delayed an unrelated health-check endpoint by over 10 s. The result is binary regardless of how many unknown names appear, so none of the lookups beyond the first are useful.

Rack 3.0, 3.1 and 3.2 are affected. Rack 2.2 is not affected by the denial of service: it does not rescue the ArgumentError, so the first unknown charset aborts parsing after a single lookup.

Impact

Any application that parses multipart bodies through Rack::Request#POST or #params is affected in its default configuration. In a default Rails application a POST to any path, including one with no route, is sufficient, because Rack::MethodOverride parses the body before routing. An unauthenticated attacker can occupy a worker thread for tens of seconds with a request under 1 MB, and for minutes with a larger one; concurrent requests exhaust the thread pool. The cost grows with the number of gems in the application's bundle. No authentication, malformed HTTP, or unusual configuration is required.

Mitigation

  • Update to a patched version of Rack, in which Encoding.find is only called for names present in Encoding.name_list, so unknown charset values are mapped to binary without searching the load path.
  • At a reverse proxy, limit the size of multipart requests and reject requests whose part headers contain many repeated charset parameters.

Is GHSA-58mf-c3jj-277p in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected rack, and gives you the command that fixes it.

More advisories for rack

  • MediumCVE-2026-142591Rack: `Rack::QueryParser` separator pattern allocates ~48 bytes per space after `&`, allowing denial of service via memory amplification · 3 Dec 2026
  • MediumCVE-2026-142593Rack: `Rack::Directory` lists directories outside the root when `..` follows a symbolic link · 3 Dec 2026
  • LowCVE-2026-142594Rack: `Rack::Multipart` extracts the boundary by substring match rather than parameter parsing, allowing parser differentials and WAF bypass · 3 Dec 2026
  • MediumCVE-2026-142590Rack: `Rack::Multipart::Parser` preserves CRLF from multipart part headers in parsed parameter names (incomplete fix for CVE-2026-26962) · 2 Dec 2026
  • HighCVE-2026-125111Rack: Multipart parsing allows DoS via unbounded scan buffer growth · 10 Nov 2026
  • LowCVE-2026-125108Rack: Multipart boundary ambiguity guard in Rack::Multipart::Parser can be bypassed with a quoted boundary value, allowing WAF bypass · 10 Nov 2026
All 59 advisories for rack

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.