Skip to content

docs: REQUEST_BODY_LENGTH without URLENCODED; @rx macro escaping changed in 2.9.8 - #10

Open
fzipi wants to merge 1 commit into
mainfrom
docs/request-body-length-and-rx-macro
Open

fzipi wants to merge 1 commit into
mainfrom
docs/request-body-length-and-rx-macro

Conversation

@fzipi

@fzipi fzipi commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

what

Two reference-manual corrections that close two ModSecurity issues.

REQUEST_BODY_LENGTH (owasp-modsecurity/ModSecurity#3466)

The manual only said "Contains the number of bytes read from a request body", and readers took the REQUEST_BODY sentence about the URLENCODED processor to apply to it too. Added:

  • it is set whichever request body processor is used, as long as request body access is enabled, so SecRule REQUEST_BODY_LENGTH "@gt 0" is the "request has a body" check asked for in the issue (with an example rule);
  • in v3 the variable is only set for a non-empty body.

Checked against the code: v2 var_request_body_length_generate returns msc_reqbody_length, which modsecurity_request_body_store_memory accumulates for every processor; v3 sets it in Transaction::processRequestBody from the raw body buffer, after the body-access check and only when the body is not empty.

@rx and macro expansion (owasp-modsecurity/ModSecurity#3380)

Documented the 2.9.8 change from ModSecurity 2105ed06 ("Do not escape special chars in regex pattern with macro"): the expanded pattern is now compiled as is, which is also how v3 has always behaved. Up to 2.9.7, v2 ran the whole expanded pattern through log_escape_re, which escapes + . ? ( ) [ ] / (and :, ") but not | ^ $ * \. The note uses the CRS 3.x allowed_request_content_type case from the issue as the example (application/soap+xml), and says that CRS 3.2/3.3 rules 920420 and 920480 need the value escaped in the variable; CRS 4 does not use the construct.

testing

hugo builds without errors.

🤖 Generated with Claude Code

…g changed in 2.9.8

- REQUEST_BODY_LENGTH: state that it is set whichever request body
  processor is used (unlike REQUEST_BODY in v2), so `@gt 0` is the way to
  check that a request has a body; note that v3 only sets it for a
  non-empty body. (owasp-modsecurity/ModSecurity#3466)
- @rx: document that a macro-expanded pattern is compiled as is since
  2.9.8 (and always in v3), list what 2.9.7 and earlier escaped, and how
  that affects CRS 3.2/3.3 rules 920420 and 920480.
  (owasp-modsecurity/ModSecurity#3380)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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