A chain starter with `multiMatch` logged every matching value as soon
as the operator matched, through the per-match branch of
`RuleWithActions::performLogging`. That pushed the message into
`Transaction::m_rulesMessages` and called the server log callback
before the chained rules had been evaluated, so with
`SecAuditEngine RelevantOnly` a request that matched only the first
rule of the chain was still saved to the audit log (CRS 942131 hits
this). Rules without `multiMatch` were already deferred until the end
of the chain.
Keep the per-match messages of a chained rule in a local list and hand
them to the transaction in `RuleWithOperator::evaluate` only when the
chain has matched; a failed chain drops them. Rules that are not
chained, and the last rule of a chain, keep logging immediately.
Fixes owasp-modsecurity#2672.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tz1sULBvqAwnRreKh5eC9h
What
A chain starter with
multiMatchlogged every matching value as soon as its operator matched, before the chained rules ran. The message landed inTransaction::m_rulesMessagesand went through the server log callback, so withSecAuditEngine RelevantOnlya request that matched only the first rule of the chain was still saved to the audit log. Rules withoutmultiMatchwere already deferred to the end of the chain.The per-match messages of a chained rule are now kept in a local list inside
RuleWithOperator::evaluateand handed to the transaction only when the whole chain has matched. A failed chain drops them. Rules that are not chained, and the last rule of a chain, keep logging each match immediately as before.Why
Fixes #2672. CRS 942131 (
multiMatch+chain) hits this path, so every request that trips only its first rule is written to the audit log underRelevantOnly.Tests
test/test-cases/regression/issue-2672.json(registered intest/test-suite.in):multiMatchstarter matched: status 200 and "Return code200' is not interesting to audit logs". Fails onv3/master`, passes with this change.msg.Full
make checkon macOS with YAJL, PCRE2 and LMDB: 5113 passed, 0 failed, 20 skipped. The existing chainedmultiMatchcases inauditlog.jsonstill pass.🤖 Generated with Claude Code
Summary by CodeRabbit