Repository navigation
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The new missing-name flag path lacks a regression assertion for MULTIPART_INVALID_PART.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Aligns v2 multipart error flags and regression expectations with v3.
Changes:
- Marks malformed, missing, or nameless
Content-Dispositionparts invalid. - Flags malformed
filename*charset quoting. - Updates regression logging and assertions to use
REQBODY_ERROR.
| File | Description |
|---|---|
apache2/msc_multipart.c |
Sets multipart invalid-part and invalid-quoting flags. |
tests/regression/misc/00-multipart-parser.t |
Verifies parser state for mixed multipart failures. |
tests/regression/target/10-variable-multipart_strict_error.t |
Updates state logging and flag expectations. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|




This PR was inspired by a bit wider, but similar for v3, #3650.
what
1. Parser flags for invalid part headers (
apache2/msc_multipart.c)MULTIPART_INVALID_PART(flag_invalid_part) is now set inmultipart_process_part_header()when:Content-Dispositionheader,-*the
Content-Dispositionheader cannot be parsed (any negative result ofmultipart_parse_content_disposition()),nameparameter is missing.MULTIPART_INVALID_QUOTING(flag_invalid_quoting) is now also set whenfilename*has no valid charset before the first'(error-16, e.g. a quotedfilename*="UTF-8''...").2. Regression tests check the parser state flags
tests/regression/target/10-variable-multipart_strict_error.t: seven cases now also match the logged flag values (error => [...]), the same as their v3 counterparts invariable-MULTIPART_STRICT_ERROR.json:Content-Typepart header:DH 1filename*invalid syntax (-17):IQ 1filename, duplicatefilename*, duplicatefilenameafterfilename*:DH 1, IQ 0, IP 1filename*(%ZZ,-18):DH 0, IQ 0, IP 1filename*(-16):DH 0, IQ 1, IP 1tests/regression/misc/00-multipart-parser.t: the two "multipart mixed" cases log the flag values in themsgof the strict rule and checkIP 1, as in v3.PARSER_STATElogdataand the newmsguseRE %{REQBODY_ERROR}instead ofPE %{REQBODY_PROCESSOR_ERROR}.why
Flags. Unlike v3, the v2 parser already stops at the first invalid part header, because
multipart_process_part_header()returns-1. However, these error paths only set the request body error. The individual flags stayed0, so a rule or log line checkingMULTIPART_INVALID_PARTgave no hint that the part itself was invalid. With this change, v2 reports the same flag values as v3 for the same requests:Content-Dispositionmakes the part invalid,filename*without a valid charset is a quoting problem.Tests. The existing cases only checked the debug log message, so the flag values were never verified. The five
PARSER_STATEactions referencedREQBODY_PROCESSOR_ERROR. That variable was removed in 2.9.14 (#3578), so the macro expanded to an empty string (PE ,), and nothing caught it because no test looked at the output.REQBODY_ERRORis the variable v2'smodsecurity.conf-recommendeduses as well (RE %{REQBODY_ERROR}).There is no behaviour change for request blocking: these requests were and still are rejected through
REQBODY_ERROR. Only the values ofMULTIPART_INVALID_PARTandMULTIPART_INVALID_QUOTINGchange, and thereforeMULTIPART_STRICT_ERROR, which already was1through the request body error.references
process_part_header()returning0instead of-1on error, which let parsing continue and produced falseMULTIPART_DUPLICATE_PART_HEADERvalues. v2 was not affected by that part.REQBODY_PROCESSOR_ERRORin v2