Skip to content

Clarify chain action timing and SecRuleUpdateActionById on chains - #2

Open
fzipi wants to merge 1 commit into
mainfrom
fix/chain-and-update-action-docs
Open

fzipi wants to merge 1 commit into
mainfrom
fix/chain-and-update-action-docs

Conversation

@fzipi

@fzipi fzipi commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Addresses the remaining items of owasp-modsecurity/ModSecurity#2860 (reported by @diablodale, originally from coreruleset/coreruleset#3080).

chain

  • Rewrites the misleading bullet ("executed if the rule that contains them matches"). Chained rules are evaluated in order and evaluation stops at the first non-match, so a non-disruptive action runs once its rule and every rule before it matched.
  • Keeps the v2/v3 distinction: in v2 this applies to every non-disruptive action, in v3 only to setvar.
  • Adds a worked three-rule example (+1/+2/+4 ends at 3 when the last rule fails).
  • Links to the update-action caveats.

SecRuleUpdateActionById: replaces the short note with an "Updating chained rules" subsection.

  • v2: msre_actionset_merge always takes is_chained from the update, so an update without chain unchains the rule (the case-5 failure in coreruleset#3080). Repeat chain only on rules that already have it. RULEID:offset semantics are documented. Includes a wrong/right example.
  • v3: updates are runtime overlays keyed by rule ID. Only the starter can be targeted, the chain can't be broken, and a repeated chain is ignored with a "General failure" message. Every updated action, setvar included, runs only on a full chain match.

How this was verified

  • v3: ran a scratch regression file through test/regression_tests on current v3/master, covering a failing last rule, a failing starter, a 3-rule partial match, ctl in the starter, update with and without chain, and deny/setvar added by update. All the v3 statements match the measured results.
  • v2: from source (apache2/re.c, apache2/apache2_config.c on v2/master) plus @diablodale's measured 2.9.3 repro in coreruleset#3080. Not re-run in v2 here. The "msg not logged" point is attributed as a report rather than stated as fact.

Refs owasp-modsecurity/ModSecurity#2860 (it won't auto-close across repos).

🤖 Generated with Claude Code

The chain entry said non-disruptive actions run when "the rule that
contains them matches", which reads as if a later rule could fire on
its own. Chained rules are evaluated in order and stop at the first
non-match, so an action runs once its rule and every rule before it
matched. Add a worked example.

SecRuleUpdateActionById now collects the chain caveats in one place:
v2 takes the chain flag from the update (so chain must be repeated, and
must not be added to a rule without it), v3 applies updates at run time
to the chain starter only and runs every updated action, setvar
included, only on a full chain match.

Refs owasp-modsecurity/ModSecurity#2860

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RiUJuqXNvvpytiGRiDFyTy

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant