Repeating an unknown charset can turn a Rack multipart request into a CPU denial of service
Repeating an unknown charset can turn a Rack multipart request into a CPU denial of service Rack-based applications accept multipart bodies for file uploads and ordinary forms. A parsing detail in those bodies now has
Repeating an unknown charset can turn a Rack multipart request into a CPU denial of service
Rack-based applications accept multipart bodies for file uploads and ordinary forms. A parsing detail in those bodies now has a denial-of-service consequence: each unknown charset parameter can trigger a search of every directory on Ruby's load path. Sending thousands of parameters in one part creates a large amount of work with little traffic.
The issue is CVE-2026-142592. Rack 3.0 releases before 3.1.24 and 3.2 releases before 3.2.9 are affected. Fixed releases are 3.1.24 and 3.2.9.
Mechanism
Rack::Multipart::Parser#tag_multipart_encoding calls Encoding.find for each charset parameter in a part header. When Ruby does not recognize the name, it attempts to load an encoding library with that name. Ruby searches the load path before returning an error. Rack rescues the error and falls back to binary, but it does not cache the failed lookup or cap repeated charset parameters.
An attacker can therefore place a series of short ;charset=x values in a multipart header. The advisory estimates a few microseconds per load-path entry on a bare runtime and milliseconds per lookup in applications with large dependency paths. The exact cost varies, but the amplification is the problem. A single request can cause many full searches before the framework finishes parsing it.
Existing controls do not necessarily stop the pattern. Rack's part limit counts parts rather than parameters. A header may remain within the parser's buffer while still carrying a large number of values. Applications that accept multipart requests are exposed even when the handler would reject the upload later, because parsing occurs first.
Operational impact
CPU exhaustion can delay every request handled by the same worker pool. A small number of concurrent malicious uploads may be enough to consume all available workers, depending on the server and load path. The result is reduced availability rather than direct data access. Logs may show multipart parse latency or worker saturation without a clear application error, so incident responders should inspect request bodies and edge telemetry as well as application traces.
Remediation
Upgrade to Rack 3.1.24 or 3.2.9, or a later supported release. For applications that cannot update immediately, enforce a small request-body and header limit at the reverse proxy, reject multipart requests with excessive parameters and rate-limit upload endpoints. These controls are compensating measures; they do not repair the parser.
After upgrading, test multipart forms used by real clients. Validate that the proxy preserves legitimate long filenames and metadata while rejecting abnormal repeated charset values. Add monitoring for parser time and worker queue depth so a future amplification attempt is visible before the service fails.
References
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.