Objective
Compile and execute the stable ModSecurity 3.0.16 / Coraza 3.7.0 union of disruptive, flow-control, chain, multi-match, and runtime control actions using typed immutable plan data and bounded transaction-local state. Decisions must compose atomically with WAF-14 metadata/non-disruptive effects and never require audit, UI, network, or database I/O on the request path.
Deliverables
Typed plan ABI and validation
- Compile allow, block, deny, drop, pass, proxy, redirect, and status into typed descriptors; validate values and incompatible or duplicate action families before publication.
- Preserve block as delegation to the phase SecDefaultAction disruptive action, including its effective status.
- Compile allow scopes (phase, request, and transaction/default scope), macro-bearing redirect/proxy destinations, and status codes with stable diagnostics.
- Compile bounded skip, statically/dynamically resolved skipAfter, chain, and multiMatch execution metadata without request-time plan mutation.
- Compile the stable runtime ctl union: ruleEngine, auditEngine, auditLogParts, requestBodyAccess, responseBodyAccess, requestBodyProcessor, requestBodyLimit, forceRequestBodyVariable, ruleRemoveById, ruleRemoveByTag, ruleRemoveTargetById, and ruleRemoveTargetByTag.
- Reject unavailable proxy execution explicitly; never silently treat it as pass.
Atomic match and chain decisions
- Extend WAF-14 matched-rule/chain application so metadata, captures, local/persistent effects, runtime controls, flow decisions, match intent, and intervention intent either commit together or leave transaction state unchanged.
- Only a fully matched chain executes actions; use chain-head metadata/disruptive semantics while retaining member actions in source order where upstream semantics require them.
- Detection-only mode records the same disruptive evidence but does not interrupt phases, terminate inspection, redirect, proxy, or pause connector I/O.
- Enforce deterministic conflict/precedence semantics for defaults, rule actions, status, and repeated controls.
Flow execution API
- Add a bounded per-phase execution cursor over immutable phaseRules that applies skip, skipAfter, allow scopes, disabled rules/tags, and terminal decisions without allocation in steady-state iteration.
- skip counts executable chain heads, not chain members or markers; skipAfter resumes at the compiled same-phase rule after the selected marker.
- allow:phase, allow:request, and bare allow stop exactly the upstream-defined future phase scopes while phase-5 logging remains reachable exactly once.
- pass does not interrupt execution; deny, redirect, and drop expose connector-owned interventions; drop terminates later inspection but not logging.
- Define connector contracts for redirect location ownership, proxy destination ownership/capability, and drop behavior; reserve pause capability/intervention ABI while WAF-21 owns bounded duration parsing and execution.
Runtime controls and exclusions
- Store engine/audit/body controls transaction-locally with phase legality checks.
- Implement bounded rule-id intervals, exact rule-tag exclusions, and exact/regex rule-target exclusions by id/tag with deterministic matching and zig-regex limits.
- Apply controls only to subsequent rule/target evaluation, never retroactively to the committing rule.
- Expose read-only control state for body processors, audit writers, connectors, event records, and the future C ABI.
Evidence and qualification
- Add focused unit/integration tests for every action/value/precedence/error path, chains, all five phases, detection-only, lifecycle boundaries, and allocation rollback.
- Add pinned ModSecurity/Coraza differential fixtures and relevant CRS 4.28 control/exclusion cases with an executable evidence manifest.
- Add deterministic fuzzing for action/control parsing and execution-state transitions with hostile values and bounded collections.
- Add ReleaseFast benchmarks for decision commit, execution cursor, rule exclusions, and dynamic skipAfter; record allocations, throughput, and p50/p95/p99.
- Update the compatibility matrix, architecture/action documentation, and feature discovery only after executable evidence passes.
Acceptance criteria
- Every listed stable action has a typed compiled representation, stable malformed-input diagnostic, runtime test, and upstream/CRS evidence reference.
- No partial state is observable after allocation failure, invalid macro expansion, unavailable proxy capability, illegal late control, persistence failure under fail-closed policy, or intervention conflict.
- Untrusted counts, strings, macro expansion, intervals, exclusions, regex work, pause duration, redirect/proxy destination, and control storage have deterministic limits.
- Request-path decision/cursor benchmarks perform no blocking I/O and demonstrate bounded allocation behavior.
- Zig checks, focused fuzz/evidence steps, ReleaseFast benchmarks, formatting, and hosted CI pass on the exact closing SHA.
- Work lands directly on main in small conventional commits with issue/commit links; no submodules or silent compatibility fallbacks are introduced.
Tests
- Parser/plan: values, defaults, overrides, macros, static/dynamic markers, control grammar, and limits.
- Engine: atomic rollback, chain order, allow scopes, detection-only, intervention precedence, body-control timing, exclusions, exactly-once logging.
- Differential/evidence: pinned ModSecurity and Coraza action/control suites plus CRS 4.28 control/exclusion rules.
- Security: malformed intervals, hostile regex selectors, macro limits, redirect policy input, allocation-failure exhaustiveness.
- Performance: pass/deny/redirect/control commits, no-op and exclusion-heavy cursors, dynamic marker resolution.
Relationships
- Parent: WAF-00 #1
Blocked by
- WAF-11 #12 — immutable execution plans (complete)
- WAF-14 #15 — atomic metadata/non-disruptive commit (complete)
- REGEX-05 zig-regex#18 — allocation-safe regex compilation (complete)
Blocks / feeds
- WAF-21 #22 — pause/exec/content mutation execution
- WAF-24 #25 — request buffering/body controls
- WAF-28 #29 — response controls
- WAF-29 #30 — audit serialization
- WAF-32 #33 — connector ABI
- WAF-34 #35 — SecRules Test Set
- WAF-37 #38 — CRS FTW
- WAF-40 #41 — proxy enforcement