You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
v2: !@validateHash matches when the regex fails (same as #3123) #3710
ModSecurity v2's @validateHash has the same flaw #3123 describes for @rx. When the regex can't be evaluated, the operator returns 0 ("no match"), and the generic negation in execute_operator() (apache2/re.c) turns that into a match. A !@validateHash rule therefore fires on a regex error.
On v2/master (0875b19), in msre_op_validateHash_execute() (apache2/re_operators.c):
Line 848: a macro-expanded pattern that fails to compile at runtime sets *error_msg and returns 0.
Line 918: when the PCRE match or recursion limit is exceeded, it sets TX:MSC_PCRE_LIMITS_EXCEEDED and returns 0.
The match limit is easy for a client to hit with a long input, especially with the low SecPcreMatchLimit in modsecurity.conf-recommended.
Expected behavior
As with @rx in #3709, a regex failure should be neither a match nor a mismatch. Return rule->op_negated on both paths, so that neither @validateHash nor !@validateHash matches, and keep the error visible through the TX:MSC_* flags. For a compile error, that means setting TX:MSC_PCRE_ERROR, which #3709 introduces.
Line 815 returns 0 when the hash engine is disabled (SecHashEngine Off), so !@validateHash matches every request in that configuration too. That case is a configuration choice rather than a runtime error, so whether it should change is open for discussion.
libModSecurity v3 isn't affected by the regex issue: its ValidateHash operator is a stub and doesn't evaluate a regex.
The fix should come with regression tests in tests/regression/, mirroring misc/10-pcre-negated.t from #3709.
Fixed by #3712 (merged into v2/master on 2026-10-27): @validateHash now returns the negation flag on a regex compile error or exceeded PCRE limits, so a !@validateHash rule no longer matches on a regex error. Closing.
Activity
fzipi commentedon Nov 30, 2026
Fixed by #3712 (merged into
v2/masteron 2026-10-27):@validateHashnow returns the negation flag on a regex compile error or exceeded PCRE limits, so a!@validateHashrule no longer matches on a regex error. Closing.