Track vulnerabilities like this one.
Sign up free to get alerted when software you use is affected.
3.7
CVE-2026-142594: Rack may interpret multipart boundaries incorrectly, causing request mismatch
CVE-2026-142594 · published today
Summary
The Rack web framework can pick the wrong boundary string from multipart form requests because it looks for the word “boundary=” anywhere in the header instead of reading the header parameters correctly. This can make Rack see a different set of uploaded parts than security tools or other servers, potentially letting malicious data slip past filters. Update Rack to the latest version or apply the provided patch to fix the parsing logic.
What to do
- Update rack to version 2.2.26.
- Update rack to version 3.1.24.
- Update rack to version 3.2.9.
Affected software
| Ecosystem | Vendor | Product | Affected versions |
|---|---|---|---|
| rubygems | – | rack |
< 2.2.26 >= 3.0.0, < 3.1.24 >= 3.2.0, < 3.2.9 Fix: upgrade to 2.2.26
|
| – | rack | rack | < 2.2.26 |
Original advisory text
Rack: `Rack::Multipart` extracts the boundary by substring match rather than parameter parsing, allowing parser differentials and WAF bypass
## Summary
`Rack::Multipart::Parser.parse_boundary` locates the multipart boundary by matching `boundary=` anywhere in the `Content-Type` header with a regular expression, rather than parsing the header's parameters. The matched value is also cut at the first `"`, `;`, or `,` even inside a quoted-string, and surrounding whitespace is kept. Rack therefore derives a boundary from headers in which a conforming parser (RFC 9110 Section 8.3.1, as implemented by Go's `mime.ParseMediaType`, Python's `email` package, and WAF engines built on them) finds a different boundary or none at all. An attacker can choose such a header and lay out a body that an inspecting intermediary and Rack read as different sets of parts.
## Details
The boundary is extracted with:
```ruby
MULTIPART = /\Amultipart\/.*?#{NOT_AFTER_TOKEN_CHAR}boundary(\s*)="?([^";,]+)"?/ni
```
This has three consequences:
* `boundary=` inside another parameter's value is accepted as the boundary. `multipart/form-data; name=" boundary=EVIL"` and `multipart/form-data; x=boundary=AaB03x` both yield a boundary for Rack, while a conforming parser finds no `boundary` parameter. The duplicate-boundary guard added for CVE-2026-125108 counts one occurrence and does not fire, and the token-character lookbehind does not help because a space or `=` is not a token character.
* A quoted boundary is truncated at `,` or `;`. `multipart/form-data; boundary="AaB03x,1"` yields `AaB03x` for Rack and `AaB03x,1` for a conforming parser. This header is fully valid: `,` is permitted in a boundary by RFC 2046 Section 5.1.1 and inside a quoted-string by RFC 9110, so an intermediary has no reason to reject it.
* Whitespace after `=` or before `;` becomes part of the boundary, and quoted-pair escapes such as `\"` are not unescaped.
`Rack::MediaType.params(content_type)["boundary"]` returns `nil` for the in-value shapes while `parse_boundary` returns a value, so Rack's own API is inconsistent with itself.
All supported versions, including 2.2, are affected.
## Impact
Applications that accept `multipart/form-data` behind a web application firewall, reverse proxy, or other component that inspects multipart bodies with a conforming parser. The intermediary sees no multipart body, or a different set of parts, so form fields and file uploads reach the application without inspection. This was confirmed end to end against OWASP Coraza with the OWASP Core Rule Set: a rule that blocks an ordinary PHP file upload does not fire on the smuggled form, while the Rack application receives the file. No authentication, malformed HTTP, or large payload is required. Rack itself grants no capability beyond that of a well-formed request with the same body.
## Mitigation
* Update to a patched version of Rack, in which the boundary is taken only from a parameter named `boundary` using an RFC 9110 parameter parser, quoted-strings are honoured, and a request with more than one boundary parameter is rejected.
* At the reverse proxy, reject multipart requests whose `Content-Type` does not contain exactly one well-formed `boundary` parameter, and reject boundary values containing `,` or `;`.
`Rack::Multipart::Parser.parse_boundary` locates the multipart boundary by matching `boundary=` anywhere in the `Content-Type` header with a regular expression, rather than parsing the header's parameters. The matched value is also cut at the first `"`, `;`, or `,` even inside a quoted-string, and surrounding whitespace is kept. Rack therefore derives a boundary from headers in which a conforming parser (RFC 9110 Section 8.3.1, as implemented by Go's `mime.ParseMediaType`, Python's `email` package, and WAF engines built on them) finds a different boundary or none at all. An attacker can choose such a header and lay out a body that an inspecting intermediary and Rack read as different sets of parts.
## Details
The boundary is extracted with:
```ruby
MULTIPART = /\Amultipart\/.*?#{NOT_AFTER_TOKEN_CHAR}boundary(\s*)="?([^";,]+)"?/ni
```
This has three consequences:
* `boundary=` inside another parameter's value is accepted as the boundary. `multipart/form-data; name=" boundary=EVIL"` and `multipart/form-data; x=boundary=AaB03x` both yield a boundary for Rack, while a conforming parser finds no `boundary` parameter. The duplicate-boundary guard added for CVE-2026-125108 counts one occurrence and does not fire, and the token-character lookbehind does not help because a space or `=` is not a token character.
* A quoted boundary is truncated at `,` or `;`. `multipart/form-data; boundary="AaB03x,1"` yields `AaB03x` for Rack and `AaB03x,1` for a conforming parser. This header is fully valid: `,` is permitted in a boundary by RFC 2046 Section 5.1.1 and inside a quoted-string by RFC 9110, so an intermediary has no reason to reject it.
* Whitespace after `=` or before `;` becomes part of the boundary, and quoted-pair escapes such as `\"` are not unescaped.
`Rack::MediaType.params(content_type)["boundary"]` returns `nil` for the in-value shapes while `parse_boundary` returns a value, so Rack's own API is inconsistent with itself.
All supported versions, including 2.2, are affected.
## Impact
Applications that accept `multipart/form-data` behind a web application firewall, reverse proxy, or other component that inspects multipart bodies with a conforming parser. The intermediary sees no multipart body, or a different set of parts, so form fields and file uploads reach the application without inspection. This was confirmed end to end against OWASP Coraza with the OWASP Core Rule Set: a rule that blocks an ordinary PHP file upload does not fire on the smuggled form, while the Rack application receives the file. No authentication, malformed HTTP, or large payload is required. Rack itself grants no capability beyond that of a well-formed request with the same body.
## Mitigation
* Update to a patched version of Rack, in which the boundary is taken only from a parameter named `boundary` using an RFC 9110 parameter parser, quoted-strings are honoured, and a request with more than one boundary parameter is rejected.
* At the reverse proxy, reject multipart requests whose `Content-Type` does not contain exactly one well-formed `boundary` parameter, and reject boundary values containing `,` or `;`.
References
- https://github.com/rack/rack/commit/6cce362d027f437362eb1d2ae330e7e880e6a01d
- https://github.com/rack/rack/security/advisories/GHSA-r243-pfwh-7rpx
- https://github.com/rack/rack/releases/tag/v2.2.26
- https://github.com/rack/rack/releases/tag/v3.1.24
- https://github.com/rack/rack/commit/c74dbad94cbe91c7fa6e68f89fad22578a6135e0
- https://github.com/rack/rack/commit/e5045fef634b491f0ea25b0e8bbfb946f7cbadd4
- https://github.com/rack/rack/releases/tag/v3.2.9
- https://github.com/advisories/GHSA-r243-pfwh-7rpx
Internet-facing
14 days
Internal
60 days
- Not known to be exploited
- Can be exploited automatically (estimated)
- Gives an attacker partial control (estimated)
Type
CWE-436Interpretation Conflict
Timeline
Published3 Dec 2026
Updated3 Dec 2026
First seen2 Dec 2026
Track software like this
Free during beta