Skip to content

fix: name the multipart Content-Disposition error codes and return 0 from m.setvar (2.x) - #3675

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

fzipi wants to merge 1 commit 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 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.
  • apache2/msc_lua.c: l_setvar returned -1 on bad arguments. A Lua C function returns the number of results, so it now returns 0.

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 a Debian bookworm container (apache2 2.4): on untouched v2/master both cases fail (the log says (-15)); on this branch both pass, and the existing 00-multipart-parser.t (42) and 10-multipart-filenamestar.t (7) still pass.

References

Related to #3655, #3657

🤖 Generated with Claude Code

…from m.setvar

Port of the internal 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.
- l_setvar returned -1 on bad arguments; a Lua C function must return
  the number of results, so it now returns 0.

Related to owasp-modsecurity#3655

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0181jBv5JdNQviwDzfnkf1Gy
@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
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6296279c-5625-408c-8c75-fb214f0d9d22

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

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant