{"id":"GHSA-r243-pfwh-7rpx","summary":"Rack: `Rack::Multipart` extracts the boundary by substring match rather than parameter parsing, allowing parser differentials and WAF bypass","details":"## Summary\n\n`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.\n\n## Details\n\nThe boundary is extracted with:\n\n```ruby\nMULTIPART = /\\Amultipart\\/.*?#{NOT_AFTER_TOKEN_CHAR}boundary(\\s*)=\"?([^\";,]+)\"?/ni\n```\n\nThis has three consequences:\n\n* `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.\n* 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.\n* Whitespace after `=` or before `;` becomes part of the boundary, and quoted-pair escapes such as `\\\"` are not unescaped.\n\n`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.\n\nAll supported versions, including 2.2, are affected.\n\n## Impact\n\nApplications 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.\n\n## Mitigation\n\n* 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.\n* 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 `;`.","aliases":["CVE-2026-142594"],"modified":"2026-12-03T00:15:08.351529082Z","published":"2026-12-03T00:08:43Z","database_specific":{"cwe_ids":["CWE-436"],"severity":"LOW","github_reviewed":true,"github_reviewed_at":"2026-12-03T00:08:43Z","nvd_published_at":null},"references":[{"type":"WEB","url":"https://github.com/rack/rack/security/advisories/GHSA-r243-pfwh-7rpx"},{"type":"WEB","url":"https://github.com/rack/rack/commit/6cce362d027f437362eb1d2ae330e7e880e6a01d"},{"type":"WEB","url":"https://github.com/rack/rack/commit/c74dbad94cbe91c7fa6e68f89fad22578a6135e0"},{"type":"WEB","url":"https://github.com/rack/rack/commit/e5045fef634b491f0ea25b0e8bbfb946f7cbadd4"},{"type":"PACKAGE","url":"https://github.com/rack/rack"},{"type":"WEB","url":"https://github.com/rack/rack/releases/tag/v2.2.26"},{"type":"WEB","url":"https://github.com/rack/rack/releases/tag/v3.1.24"},{"type":"WEB","url":"https://github.com/rack/rack/releases/tag/v3.2.9"}],"affected":[{"package":{"name":"rack","ecosystem":"RubyGems","purl":"pkg:gem/rack"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"2.2.26"}]}],"versions":["0.1.0","0.2.0","0.3.0","0.4.0","0.9.0","0.9.1","1.0.0","1.0.1","1.1.0","1.1.1","1.1.1.pre","1.1.2","1.1.3","1.1.4","1.1.5","1.1.6","1.2.0","1.2.1","1.2.2","1.2.3","1.2.4","1.2.5","1.2.6","1.2.7","1.2.8","1.3.0","1.3.0.beta","1.3.0.beta2","1.3.1","1.3.10","1.3.2","1.3.3","1.3.4","1.3.5","1.3.6","1.3.7","1.3.8","1.3.9","1.4.0","1.4.1","1.4.2","1.4.3","1.4.4","1.4.5","1.4.6","1.4.7","1.5.0","1.5.0.beta.1","1.5.0.beta.2","1.5.1","1.5.2","1.5.3","1.5.4","1.5.5","1.6.0","1.6.0.beta","1.6.0.beta2","1.6.1","1.6.10","1.6.11","1.6.12","1.6.13","1.6.2","1.6.3","1.6.4","1.6.5","1.6.6","1.6.7","1.6.8","1.6.9","2.0.0.alpha","2.0.0.rc1","2.0.1","2.0.2","2.0.3","2.0.4","2.0.5","2.0.6","2.0.7","2.0.8","2.0.9","2.0.9.1","2.0.9.2","2.0.9.3","2.0.9.4","2.1.0","2.1.1","2.1.2","2.1.3","2.1.4","2.1.4.1","2.1.4.2","2.1.4.3","2.1.4.4","2.2.0","2.2.1","2.2.10","2.2.11","2.2.12","2.2.13","2.2.14","2.2.15","2.2.16","2.2.17","2.2.18","2.2.19","2.2.2","2.2.20","2.2.21","2.2.22","2.2.23","2.2.24","2.2.25","2.2.3","2.2.3.1","2.2.4","2.2.5","2.2.6","2.2.6.1","2.2.6.2","2.2.6.3","2.2.6.4","2.2.7","2.2.8","2.2.8.1","2.2.9"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/12/GHSA-r243-pfwh-7rpx/GHSA-r243-pfwh-7rpx.json"}},{"package":{"name":"rack","ecosystem":"RubyGems","purl":"pkg:gem/rack"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.0.0"},{"fixed":"3.1.24"}]}],"versions":["3.0.0","3.0.1","3.0.10","3.0.11","3.0.12","3.0.13","3.0.14","3.0.15","3.0.16","3.0.17","3.0.18","3.0.2","3.0.3","3.0.4","3.0.4.1","3.0.4.2","3.0.5","3.0.6","3.0.6.1","3.0.7","3.0.8","3.0.9","3.0.9.1","3.1.0","3.1.1","3.1.10","3.1.11","3.1.12","3.1.13","3.1.14","3.1.15","3.1.16","3.1.17","3.1.18","3.1.19","3.1.2","3.1.20","3.1.21","3.1.22","3.1.23","3.1.3","3.1.4","3.1.5","3.1.6","3.1.7","3.1.8","3.1.9"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/12/GHSA-r243-pfwh-7rpx/GHSA-r243-pfwh-7rpx.json"}},{"package":{"name":"rack","ecosystem":"RubyGems","purl":"pkg:gem/rack"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.2.0"},{"fixed":"3.2.9"}]}],"versions":["3.2.0","3.2.1","3.2.2","3.2.3","3.2.4","3.2.5","3.2.6","3.2.7","3.2.8"],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/12/GHSA-r243-pfwh-7rpx/GHSA-r243-pfwh-7rpx.json"}}],"schema_version":"1.9.2","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:N"}]}