owasp-modsecurity / owasp-modsecurity/ModSecurity

Custom Response Body Rule Not Blocking for Responses Larger Than 1KB

Open
#3,282 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.x
Dominant language
C++
Stars
9.8k
Forks
1.8k
Avg merge
2h 46m
Merged PRs (30d)
1

Description

Describe the bug

The custom rule below is triggered correctly when the response body contains the word "jolly." However, if the response size exceeds 1KB, the rule no longer blocks the request, even though the rule is triggered.

Custom Rule:
SecRule RESPONSE_BODY "@rx (?i)(\n|\''|\:|\W*)jolly" \
    "id:102, \
    phase:4, \
    deny, \
    log, \
    t:none, \
    msg:'UNAUTHORIZED DATA ACCESS'"

This issue occurs despite the configurations set for response body access limits and processing, indicating that the rule might not be evaluated correctly for larger response sizes.


Logs and dumps
  1. Debug Logs (Level 9):
    Modsecurity-Response-Debug.txt

  2. Audit Logs:
    modsec_audit_waf.theviscousweb.com.txt

  3. Error Logs:
    [Attach relevant error logs]

  4. Core Dump (if applicable):
    [Attach core dump if there was a crash]


To Reproduce
  1. Curl Request:

    curl -X GET "https://your-server-endpoint" -H "Content-Type: application/json"
    
  2. Ensure that the response body contains:

    ...some data...\n jolly
    
  3. Ensure the response body size is greater than 1KB.

  4. Verify that the request goes through when it should be denied based on the rule.


Expected behavior

The custom rule should deny the request and log the corresponding message whenever the word "jolly" appears in the response body, regardless of the response size.


Server (please complete the following information):
  • ModSecurity version (and connector):
    ModSecurity v3.0.7 with nginx-connector v1.0.1

  • WebServer:
    nginx-1.24.0

  • OS (and distro):
    Linux, Ubuntu 24


Rule Set (please complete the following information):
  • Running any public or commercial rule set?
    OWASP CRS

  • Version number:
    4.7.0-nginx-202410030910 (OWASP CRS Docker image)


Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied curl case with ModSecurity v3.0.7, the nginx connector, and the OWASP CRS Docker image, using the custom RESPONSE_BODY rule and the attached debug and audit logs. Trace how response-body access limits handle bodies over 1KB and verify that a matching “jolly” response is denied regardless of size.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, docker, nginx
Domain
security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.