Skip to content

Extra modification#3520

Open
JonathanBerrew wants to merge 1 commit intoowasp-modsecurity:v2/masterfrom
JonathanBerrew:extra-modification
Open

Extra modification#3520
JonathanBerrew wants to merge 1 commit intoowasp-modsecurity:v2/masterfrom
JonathanBerrew:extra-modification

Conversation

@JonathanBerrew
Copy link
Copy Markdown

This is a Marc Stern modification, I don't have much more insight on the code he made. To be reviewed with caution and check if this is still relevant.
I'm not sure from which commit Marc made those modifications.

@sonarqubecloud
Copy link
Copy Markdown

@airween airween requested a review from Copilot April 22, 2026 15:33
@airween airween added the 2.x Related to ModSecurity version 2.x label Apr 22, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds defensive handling and extra Apache IfDefine tokens for ModSecurity, likely to prevent crashes and advertise feature availability at config time.

Changes:

  • Add a NULL-guard in construct_single_var() around msc_rule_mptmp.
  • Add additional MODSEC_* entries to ap_server_config_defines, including a PCRE2 indicator.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
apache2/msc_util.c Adds an early return when the per-rule temp pool (msc_rule_mptmp) is missing during variable construction.
apache2/mod_security2.c Pushes additional MODSEC_* defines into Apache’s ap_server_config_defines for conditional configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apache2/mod_security2.c
@@ -1664,7 +1664,11 @@ static void register_hooks(apr_pool_t *mp) {

/* Add the MODSEC_a.b define */
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says "Add the MODSEC_a.b define" but this block now adds multiple defines (including feature/compile-mode defines). Update the comment (or split it) so it accurately describes what is being added.

Suggested change
/* Add the MODSEC_a.b define */
/* Add version, feature, and compile-mode ModSecurity defines. */

Copilot uses AI. Check for mistakes.
Comment thread apache2/msc_util.c
msre_var *vx = NULL;
char *my_error_msg = NULL;

if (msr->msc_rule_mptmp == NULL) return NULL;
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

construct_single_var now returns NULL whenever msr->msc_rule_mptmp is NULL. msr->msc_rule_mptmp is initialized to NULL at transaction creation (apache2/mod_security2.c:582) and is only created during rule processing (apache2/re.c:3362-3368), so requests that reach logging without any rule execution will stop producing log variables (instead of being computable from msr->mp). Consider lazily creating msc_rule_mptmp here (e.g., apr_pool_create with parent msr->mp) or otherwise providing a safe fallback pool rather than returning NULL.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.x Related to ModSecurity version 2.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants