Skip to content

fix: ignore case when evaluating exceptions - #3442

Merged
airween merged 5 commits into
owasp-modsecurity:v3/masterfrom
airween:v3/caseinsruleremovetarget
Sep 17, 2025
Merged

airween merged 5 commits into
owasp-modsecurity:v3/masterfrom
airween:v3/caseinsruleremovetarget

Conversation

@airween

@airween airween commented Sep 16, 2025

Copy link
Copy Markdown
Member

what

This PR fixes the wrong behavior: variable names are treated as case sensitive. Also it contains two new test cases for regression tests.

why

An issue opened (see below) where the reporter explained the problem: if an exclusion adds a collection member with lowercase, it won't have any effect during the rule evaluation.

The issue mentions only the REQUEST_HEADERS collection, but that's true for all targets.

mod_security2 Apache module uses strncasecmp() in all cases, not just REQUEST_HEADERS.

additional notes

I didn't want to mix C and C++ functions, this is why I ignored strncasecmp(). I also wanted to avoid copying strings and create new functions to comparing strings, so the only solution seemed to be to use std::equal() with a lambda function.

references

#3441

@airween airween added the 3.x Related to ModSecurity version 3.x label Sep 16, 2025
@airween
airween requested a review from theseion September 16, 2025 15:22
Comment thread test/test-cases/regression/action-ctl_rule_remove_target_by_id.json Outdated
Comment thread test/test-cases/regression/action-ctl_rule_remove_target_by_id.json Outdated
airween and others added 2 commits September 17, 2025 09:17
….json

Co-authored-by: Max Leske <250711+theseion@users.noreply.github.com>
….json

Co-authored-by: Max Leske <250711+theseion@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

@airween
airween requested a review from theseion September 17, 2025 07:21
@airween
airween merged commit e523d72 into owasp-modsecurity:v3/master Sep 17, 2025
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.x Related to ModSecurity version 3.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants