Background
Rack is the standard interface between Ruby web servers and Ruby web applications. Rails, Sinatra and most other Ruby web frameworks are built on it, and servers such as Puma run Rack applications. Its request parsing code is therefore present in a very large number of Ruby deployments.
One thing Rack parses is multipart/form-data, the format browsers use for file uploads and large forms. The request body contains several parts separated by a boundary string. The boundary is declared in the Content-Type header, for example multipart/form-data; boundary=AaB03x, and the parser splits the body wherever that string appears.
Many sites also place a WAF (web application firewall) or a filtering reverse proxy in front of the application. It reads each request and blocks the ones that look like attacks, for example by matching known malicious payloads inside form fields.
Terms used below:
- Parser differential is a situation where two programs read the same input and reach different conclusions about what it means.
- ModSecurity and the OWASP Core Rule Set (CRS) are a widely used open-source WAF engine and its default rule collection.
Summary
A crafted multipart header can make Rack accept form fields that an inspecting proxy never examines. The boundary extractor skips the beginning of a quoted value and selects a later boundary-like substring. Its ambiguity guard then checks only the text remaining after that match, missing the input that caused the disagreement.
This bypasses the earlier mitigation for CVE-2026-26961. In a test deployment of nginx with ModSecurity and the OWASP Core Rule Set, a normal multipart request containing the test payload was blocked. Changing the boundary header let the same payload reach the application. The failed boundary is the agreement between the inspection layer and the backend parser.
How the Vulnerability Works
A WAF can only protect an application if it sees the same request the application sees. The attack in this finding creates a request that the WAF reads one way and Rack reads another, so the payload is hidden from the first and delivered to the second.
The key is the header’s boundary parameter. A quoted value may contain unusual characters, and a correct parser treats everything inside the quotes as one value. Rack extracts the boundary with a regular expression, and with the right input the expression skips the start of the quoted value and matches a boundary-looking piece inside it:
Content-Type: multipart/form-data; boundary=";boundary=AaB03x"A parser that follows the quoting rules (RFC 9110) reads the boundary as the literal string ;boundary=AaB03x. An empty first parameter, as in boundary=; boundary=AaB03x, triggers the same skip. Rack’s regular expression instead finds boundary=AaB03x inside the quotes and decides the boundary is AaB03x. If the body is written with AaB03x as its separator, Rack splits it into fields correctly. A parser following the standard grammar sees a different boundary, or no valid multipart body at all. The advisory notes that the only conformant outcome is rejection, because that value is not a legal boundary under RFC 2046. An inspecting intermediary such as ModSecurity therefore does not see the form fields, and the payload passes uninspected.
Rack already had a guard for this situation, which was added after an earlier CVE (CVE-2026-26961). It rejects a header with more than one boundary. But it checks only the text after the regular expression’s match. The part that caused the confusion has been matched already and is no longer examined, so the guard finds nothing wrong. An ordinary duplicate boundary was still rejected, which confirms the weakness is in how the guard handles a skipped first parameter.
In the recorded setup, nginx with ModSecurity and the OWASP Core Rule Set blocked a payload sent normally and let it through with the crafted header. Rack itself grants the attacker nothing a well-formed request could not. The harm is that a layer of defence is removed, which is why the published rating is low (3.7). The class is called interpretation conflict (CWE-436). The published fix counts boundary= occurrences across the whole header and rejects the request if there is more than one.
Prerequisites
An unauthenticated client needs access to an application that parses multipart data through Rack. For a WAF bypass, an intermediary must interpret or reject the crafted header differently and still forward the request to the application.
The demonstrated deployment used Puma behind nginx with ModSecurity 3.0.12 and OWASP CRS 3.3.5. A proxy that rejects the malformed request before forwarding it prevents this chain. Application authorization and input validation remain separate controls.
Attack Path
- STARTUnauthenticated client
- STEP 01Submit an ambiguous multipart header
The body uses the boundary that Rack extracts from inside the quoted value.
MITIGATION Reject ambiguous boundary parameters at the proxy
- STEP 02Intermediary skips multipart inspection
- STEP 03Rack accepts the hidden form fields
MITIGATION Validate boundary occurrences across the whole header
- STEP 04Uninspected input reaches the application
Root Cause
Rack::Multipart::Parser.parse_boundary uses a regular expression with a lazy prefix and a value pattern that excludes certain delimiters. If the first candidate cannot match, the prefix can advance to another occurrence inside the quoted value.
The recorded example was:
Content-Type: multipart/form-data; boundary=";boundary=AaB03x"Rack extracts AaB03x, then examines data.post_match for another boundary parameter. The match has already consumed the suspicious text, leaving nothing for that guard to reject. A parser following the quoted parameter structure does not derive the same boundary. The tested intermediary stopped multipart processing, while Rack still exposed the body’s fields through Rack::Request#POST.
An unquoted duplicate boundary was rejected by the existing check. The gap was in how the guard selected and inspected the header, not the complete absence of an ambiguity check.
Validation
The proof of concept tested main revision a9833c8 and the maintained 2.2, 3.1 and 3.2 branch implementations. It also sent control and crafted requests through the real inspection stack and directly to the backend.
| Request | Intended behavior | Recorded result |
|---|---|---|
| Ordinary boundary with the test payload | Inspect and block the payload | HTTP 403 from the intermediary |
| Unquoted duplicate boundaries | Reject ambiguity | Rack rejected the header |
| Crafted quoted boundary | Reject the malformed header | HTTP 200 and payload in application parameters |
The direct-backend comparison located the boundary selection in Rack. The proxy comparison established an effect on inspection, beyond an unusual parser result. These results come from the original research. The fixed releases were not retested here.
Impact
An attacker can deliver form fields or uploads that the edge inspection policy would otherwise block. The test established an inspection bypass with an XSS test string, not JavaScript execution in a separate vulnerable application.
The result depends on a layered deployment with different parsing behavior. Rack itself receives the same parameters that a well-formed request with that body could supply. Overview uses the published GitHub rating of 3.7 under CVSS v3.1.
Remediation
Upgrade to the fixed release for the relevant branch: 2.2.25, 3.1.23 or 3.2.8. The published fix checks boundary occurrences across the entire header instead of relying on the unmatched suffix.
Before upgrading, reject ambiguous multipart boundary parameters at the reverse proxy. Regression coverage should include quoted and empty leading values alongside ordinary duplicate parameters. Check rejection at both layers, so a working edge rule does not hide a backend parsing disagreement.