Rack: `Rack::Multipart` extracts the boundary by substring match rather than parameter parsing, allowing parser differentials and WAF bypass
Published: December 03, 2026
SECURITY IDENTIFIERS
- CVE: CVE-2026-142594 (NVD)
- GHSA: GHSA-r243-pfwh-7rpx
GEM
SEVERITY
CVSS v3.x: 3.7 (Low)
PATCHED VERSIONS
~> 2.2.26
~> 3.1.24
>= 3.2.9
DESCRIPTION
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:
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"andmultipart/form-data; x=boundary=AaB03xboth yield a boundary for Rack, while a conforming parser finds noboundaryparameter. 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"yieldsAaB03xfor Rack andAaB03x,1for 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
boundaryusing 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-Typedoes not contain exactly one well-formedboundaryparameter, and reject boundary values containing,or;.
RELATED
- https://nvd.nist.gov/vuln/detail/CVE-2026-142594
- https://github.com/rack/rack/security/advisories/GHSA-r243-pfwh-7rpx
- https://github.com/rack/rack/commit/6cce362d027f437362eb1d2ae330e7e880e6a01d
- https://github.com/rack/rack/commit/c74dbad94cbe91c7fa6e68f89fad22578a6135e0
- https://github.com/rack/rack/commit/e5045fef634b491f0ea25b0e8bbfb946f7cbadd4
- 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/releases/tag/v3.2.9
- https://github.com/advisories/GHSA-r243-pfwh-7rpx
