fix: free intervention strings on mcf NULL early return path#379
Open
eilandert wants to merge 1 commit into
Open
fix: free intervention strings on mcf NULL early return path#379eilandert wants to merge 1 commit into
eilandert wants to merge 1 commit into
Conversation
When msc_intervention() succeeds and fills intervention.log and/or intervention.url, then ngx_http_get_module_loc_conf() returns NULL (unexpected misconfiguration), the function returned immediately with NGX_HTTP_INTERNAL_SERVER_ERROR without freeing either string. Free both intervention.log and intervention.url before the early return to prevent the leak on this error path. Severity: Medium Reported-by: Security audit 2026-05-13
|
Member
|
Hi @eilandert, thanks for this PR too - here my question is the same: is it possible to add some tests? |
There was a problem hiding this comment.
Pull request overview
Fixes a memory leak in the Nginx ModSecurity connector by ensuring ModSecurity-provided intervention strings are freed when the request’s module loc-conf unexpectedly resolves to NULL.
Changes:
- Free
intervention.logandintervention.urlbefore returningNGX_HTTP_INTERNAL_SERVER_ERRORon themcf == NULLearly-return path.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+166
to
+171
| if (intervention.log != NULL) { | ||
| free(intervention.log); | ||
| } | ||
| if (intervention.url != NULL) { | ||
| free(intervention.url); | ||
| } |
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.



When msc_intervention() succeeds and fills intervention.log and/or intervention.url, then ngx_http_get_module_loc_conf() returns NULL (unexpected misconfiguration), the function returned immediately with NGX_HTTP_INTERNAL_SERVER_ERROR without freeing either string.
Free both intervention.log and intervention.url before the early return to prevent the leak on this error path.