Repository navigation
Conversation
…_end_raw Once a request body exceeds SecRequestBodyInMemoryLimit it is written to a temporary file and the in-memory chunk array is released (msc_reqbody_chunks = NULL). modsecurity_request_body_end_raw still walked that array to build the single raw buffer, so any processor that needs the raw body for such a request, in practice URLENCODED forced through ctl:requestBodyProcessor on a non form content type, crashed the worker with a NULL dereference. When the storage is on disk the body is now read back through the existing modsecurity_request_body_retrieve API into the raw buffer, the storage mode is left on disk, and modsecurity_request_body_clear frees the buffer that in this case is not owned by a chunk. Fixes owasp-modsecurity#3300 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0181jBv5JdNQviwDzfnkf1Gy
|
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 configuration
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 |
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
modsecurity_request_body_end_raw(apache2/msc_reqbody.c) now handles a body that was moved to disk: it reads the temporary file back through the existingmodsecurity_request_body_retrieve_*API into the raw buffer, sized from the file (msc_reqbody_lengthonly counts the bytes that were stored in memory before the spill), setsmsc_reqbody_lengthto the real size, and leaves the storage mode on disk.modsecurity_request_body_clearfrees that buffer, which in this case is not owned by a chunk.Why
Once a request body exceeds
SecRequestBodyInMemoryLimitit is written to a temporary file and the in-memory chunk array is released (msc_reqbody_chunks = NULL).modsecurity_request_body_end_rawstill walked that array, so any processor that needs the raw body for such a request crashed the worker with a NULL dereference. In practice that isURLENCODEDforced throughctl:requestBodyProcessoron a non form content type, which is what the backtrace in #3300 shows. It only triggers for bodies above the in-memory limit, hence the "only some POSTs" symptom.Tests
New
tests/regression/misc/40-reqbody-disk.t(auto-discovered by the runner):SecRequestBodyInMemoryLimit 64, atext/plainPOST of ~215 bytes switched toURLENCODEDbyctl, with a rule onARGS:aand one onREQUEST_BODY.Verified in a Debian bookworm container (apache2 2.4,
--enable-assertions --enable-pcre-study --enable-pcre-jit):v2/master: both cases fail withchild pid ... exit signal Segmentation fault (11)inerror.log;String match "1" at ARGS:a,String match "&b=2" at REQUEST_BODY).References
Fixes #3300
🤖 Generated with Claude Code