Skip to content

fix: name the multipart Content-Disposition error codes (2.x) - #3675

Open
fzipi wants to merge 3 commits into
owasp-modsecurity:v2/masterfrom
fzipi:v2/issue-3655-error-codes
Open

fzipi wants to merge 3 commits into
owasp-modsecurity:v2/masterfrom
fzipi:v2/issue-3655-error-codes

Conversation

@fzipi

@fzipi fzipi commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

What

2.x counterpart of the internal part of #3657:

  • apache2/msc_multipart.c: the Content-Disposition parser's bare negative return codes become an enum with a message table, and every error path now returns the named code. The error text now reads Invalid Content-Disposition header (-20: duplicate filename parameter): ... instead of (-15). The two duplicate cases that shared -15 get their own codes (-20 filename, -21 filename*). All other numeric values are unchanged, since tests and log matching pin them; -9 stays reserved (the tolerated IE escaping case) and -15 is retired.

The Lua m.setvar return value fix that was originally part of this PR is dropped: #3736 already landed it on v2/master. The branch is rebased onto current v2/master and no longer touches apache2/msc_lua.c.

Why

The numbers alone were useless in the logs and -15 was ambiguous. Same reasoning as #3655, applied to 2.x.

Tests

New tests/regression/misc/70-multipart-cd-errors.t: duplicate filename and duplicate filename* parts, asserting the new -20 / -21 text through REQBODY_ERROR_MSG.

Verified in an Ubuntu 24.04 container (apache2 2.4) after the rebase: misc/70-multipart-cd-errors.t (2), target/10-multipart_filename.t (8), target/10-variable-multipart_strict_error.t (14), misc/10-multipart-filenamestar.t (7) and misc/00-multipart-parser.t (42) all pass.

References

Related to #3655, #3657

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 29ed3859-5173-47ec-a9d0-9ec86a2ebab6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@airween airween added the 2.x Related to ModSecurity version 2.x label Oct 16, 2026
fzipi and others added 3 commits November 10, 2026 18:32
Port of the multipart part of owasp-modsecurity#3657 to 2.x.

The Content-Disposition parser returned bare negative numbers that
only showed up as "Invalid Content-Disposition header (-15)" in the
logs, and -15 was shared by the duplicate filename and duplicate
filename* cases. The codes are now an enum with a message table, the
log line reads "(-20: duplicate filename parameter)", and the two
duplicate cases get their own codes (-20, -21). Existing numeric
values are unchanged because tests and log matching pin them.

The m.setvar() return value fix of the original version of this change
landed separately in owasp-modsecurity#3736.

Related to owasp-modsecurity#3655

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0181jBv5JdNQviwDzfnkf1Gy
The previous commit changed the REQBODY_ERROR_MSG text from
"(-N): header" to "(-N: description): header" and split the shared -15
into -20 and -21, but left six existing expectations on the old text.
Update them to the new codes and descriptions.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tz1sULBvqAwnRreKh5eC9h
multipart_parse_content_disposition() still returned bare numbers on
all paths except the two duplicate filename cases, so the enum and the
code it was meant to document could drift apart. Return the enum
constants everywhere, as the 3.x parser does. The numeric values do not
change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XeLG4vp4DU9WxVbQHwgWT3
@fzipi
fzipi force-pushed the v2/issue-3655-error-codes branch from ae3ad9b to 8301a11 Compare November 10, 2026 22:45
@sonarqubecloud

Copy link
Copy Markdown

@fzipi fzipi changed the title fix: name the multipart Content-Disposition error codes and return 0 from m.setvar (2.x) fix: name the multipart Content-Disposition error codes (2.x) Nov 10, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.x Related to ModSecurity version 2.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants