Files
haproxy-manager-base/coraza-spoa/config.yaml
T
rootandClaude Opus 5.5 4a453df83e
Build and push coraza-spoa / Build-and-Push (push) Successful in 5m42s
coraza-spoa: Coraza engine v3.8.1 (security), SecArgumentsLimit 65536, RC-only publish branch
Security update of the WAF engine. coraza-spoa v0.7.1 pins
github.com/corazawaf/coraza/v3 v3.7.0, which is affected by the v3.8.x
advisories; several are bypasses of rules WHP enforces, reproduced in WHP's
WAF regression net on v3.7.0:

- GHSA-pc5q-qfxp-ggqv jsDecode octal: Log4Shell with ${ } as \44\173 ... \175
  escapes is not seen by the enforced 944150.
- GHSA-5gj4-9gm7-2fx2 JSON key collision: LFI in {"a.b":..} shadowed by a
  later {"a":{"b":..}} (or a case/duplicate collision) is not seen by 930120.
- GHSA-x26q-wvhg-fh4m ProcessURI: a raw 0x7f in the query drops ALL ARGS_GET.
- GHSA-w253-m66g-rx24: the LAST Content-Type picked the body processor.

Dockerfile: keep coraza-spoa v0.7.1 and CRS (coraza-coreruleset v4.25.0)
unchanged; upgrade only the engine in place (ARG CORAZA_VERSION=v3.8.1,
go get, verified against go.sum/sum.golang.org). The build fails unless
`go version -m` shows exactly that version in the binary.

config.yaml: Coraza 3.8 enforces SecArgumentsLimit (default 1000) on
urlencoded/JSON bodies and the query string and never inspects arguments
past it. With the default, "1000 filler args + LFI in arg 1001" bypassed
930120 on 3.8.1 (it is blocked on 3.7.0). Upstream's mitigation (deny rules
200004/200005) is in Coraza's own coraza.conf-recommended, not in the one
coraza-coreruleset v4.25.0 embeds (the @coraza.conf-recommended we load).
Set SecArgumentsLimit 65536 (= SecRequestBodyLimit / 2: no accepted body can
reach it, so every argument is inspected as on 3.7) and add 209620/209621:
deny in enforce / log in detect_only if arguments were ever dropped
(ARGUMENTS_LIMIT_REACHED, 3.8-only variable, so it lives in the image).

Workflow: a push to coraza-release/** publishes ONLY :<coraza-spoa/VERSION>-rc
and :<sha> (never :latest), for a staged per-host rollout through WHP's coraza
image pin. Not release/**: that prefix also triggers the edge image build.
main keeps publishing :latest (+ :<version> + :<sha>). New coraza-spoa/VERSION
2026.11.1.

Do not merge until the staged rollout is done: merging moves :latest, which
apply-coraza-waf-mode.sh pulls on every unpinned host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0185ukXi4YX5FxJGqhi6qab6
2026-11-27 21:38:57 -08:00

140 lines
7.1 KiB
YAML

# Coraza-SPOA configuration for WHP haproxy-manager integration.
#
# One named application "haproxy" — the haproxy-manager spoe template
# references this same name in its spoe-agent block, so the SPOA knows
# which rules to apply when HAProxy dispatches a request.
#
# Mode: SecRuleEngine DetectionOnly globally; overrides.conf promotes
# specific high-confidence rule ID ranges to enforcement individually.
# This is the safest posture for v1 — every rule logs, but only the
# unambiguous ones (scanner UAs, RCE, LFI, webshells, Log4Shell) block.
bind: 0.0.0.0:9000
# Process-level logging (separate from per-request audit logging below)
log_level: info
log_file: /dev/stdout
log_format: json
# Fallback when the request doesn't match a named application — we only
# have one, so it's also the default.
default_application: haproxy
applications:
- name: haproxy
directives: |
# CRS-bundled defaults: recommended Coraza settings + CRS setup +
# the rule pack itself (~16 MB of rules embedded in the binary).
Include @coraza.conf-recommended
# Request-body limits, set explicitly instead of inheriting the
# recommended file's 12.5 MB / Reject. HAProxy only ever hands us one
# buffer of body (tune.bufsize 16384 in haproxy-manager's
# hap_header.tpl), and the SPOP library refuses frames over 65535
# bytes, so no body we receive can exceed 64 KB. The invariant is:
# tune.bufsize (16 KB) < SPOP frame cap (65535) < SecRequestBodyLimit
# Breaking it is NOT harmless: SecRequestBodyLimitAction Reject
# interrupts with 413 even under DetectionOnly (Coraza
# setAndReturnBodyLimitInterruption ignores the engine mode), which the
# edge turns into a 403 on every large upload. ProcessPartial is the
# belt to that brace. InMemoryLimit == BodyLimit keeps the body buffer
# off disk (this image is distroless). Pinned by
# haproxy-manager-base/scripts/test-waf-body-inspection.py.
SecRequestBodyLimit 131072
SecRequestBodyInMemoryLimit 131072
SecRequestBodyLimitAction ProcessPartial
# JSON nesting limit (the recommended file sets 1024). Coraza's JSON
# flattener is quadratic in nesting: a 601-byte `[[[...]]]` of depth 300
# cost 297 ms and depth 1000 (2 KB) 3.1 s of CPU -- past the 100 ms SPOE
# timeout, so the request passed UNINSPECTED (fail-open) while the WAF
# burned CPU. Over the limit the body fails to parse (REQBODY_ERROR,
# 0.1 ms), which WHP's enforce-mode body-integrity rule denies on a
# complete body. Legitimate depth, measured on the JSON shipped in
# WordPress 6.x core, Gutenberg, WooCommerce and Elementor (theme.json,
# styles/*.json, block.json, checkout schemas): max 8, so a global-styles
# save is ~9; 64 leaves ~7x headroom for Divi/Elementor-style module
# trees that could not be sampled. Depth 64 itself costs ~21 ms.
SecRequestBodyJsonDepthLimit 64
# Argument-count limit, per source (ARGS_GET, ARGS_POST, ARGS_PATH).
# Coraza 3.8 started ENFORCING SecArgumentsLimit (default 1000) on
# urlencoded and JSON bodies and on the query string: parsing stops at
# the limit, ARGUMENTS_LIMIT_REACHED is set, and every argument after it
# is never inspected (GHSA-3ww9-vw83-9w5x). Coraza <= 3.7 inspected every
# urlencoded/JSON argument. With the default, "1000 filler args + an
# LFI in arg 1001" bypassed 930120 (an enforced rule) on 3.8.1 in WHP's
# regression net. Upstream pairs the cap with deny rules 200004/200005,
# but those live in Coraza's own coraza.conf-recommended; the
# @coraza.conf-recommended Included above is the one embedded in
# coraza-coreruleset v4.25.0, which predates them.
# 65536 = SecRequestBodyLimit / 2: a urlencoded pair is at least two
# bytes ("a&"), so no body we accept can reach the limit, and the query
# string is bounded by tune.bufsize (16 KB) far below it. Every argument
# is therefore inspected, exactly as on 3.7. Memory stays bounded by
# the body limit (the reason upstream added the cap). WHP's JSON
# argument-count guard (991900030/031, ">= 1000" in pre-overrides.conf)
# is unaffected: it counts what this limit lets through.
SecArgumentsLimit 65536
# Defense in depth for the limit above (unreachable while it is
# >= SecRequestBodyLimit / 2): if arguments were ever dropped, Coraza
# did not see the whole request. Same two-rule shape as WHP's JSON
# guard: 209620 switches the engine on in enforce mode
# (tx.whp_enforce_mode, set in phase 1 by WHP's local-overrides.conf),
# 209621 denies; in detect_only it only logs (audit-logged). Phase 2
# and placed before pre-overrides/CRS so it runs before every CRS
# phase-2 rule. ARGUMENTS_LIMIT_REACHED exists only on Coraza >= 3.8,
# which is why this lives in the image, not in WHP's rendered files.
SecRule TX:whp_enforce_mode "@eq 1" \
"id:209620,phase:2,pass,nolog,t:none,chain"
SecRule ARGUMENTS_LIMIT_REACHED "@eq 1" \
"t:none,ctl:ruleEngine=On"
SecRule ARGUMENTS_LIMIT_REACHED "@eq 1" \
"id:209621,phase:2,deny,status:400,log,t:none,msg:'Argument limit reached: arguments were dropped uninspected',tag:'whp/coraza-arguments-limit',ctl:auditEngine=On"
Include @crs-setup.conf.example
# Runtime-managed PRE-CRS exclusions written by WHP UI. Empty by default.
# Loaded BEFORE the CRS rules so per-host ctl:ruleRemoveById exemptions
# fire in phase:1 BEFORE the CRS rule they're trying to exempt would
# otherwise match. Server-wide overrides live in local-overrides.conf
# (loaded after CRS) instead.
Include /etc/coraza/pre-overrides.conf
Include @owasp_crs/*.conf
# WHP-specific overrides — day-one enforce list, plus tuning for
# the customer mix (WordPress, WooCommerce, Divi). Read this file
# to see exactly what blocks vs what's detect-only.
Include /etc/coraza/overrides.conf
# Runtime-managed POST-CRS overrides written by WHP UI. Empty by default.
Include /etc/coraza/local-overrides.conf
# Global mode: log all alerts, block only what overrides.conf
# explicitly promotes via ctl:ruleEngine=On.
SecRuleEngine DetectionOnly
# Audit log: JSON to a bind-mounted file so AI Monitor + log
# rotation can pick it up. RelevantOnly means we don't log every
# passing request, only ones that triggered at least one rule.
SecAuditEngine RelevantOnly
SecAuditLog /var/log/coraza/audit.log
SecAuditLogFormat JSON
SecAuditLogParts ABIJDEFHKZ
# HAProxy sends request-only events for v1. Response inspection adds
# latency on every page render with marginal additional protection
# for our customer mix; can be turned on later if we want it.
response_check: false
# Transactions cache for 60s. SPOE protocol is fire-and-forget per
# request, so this is just how long Coraza holds context for any
# multi-stage processing.
transaction_ttl_ms: 60000
log_level: info
log_file: /var/log/coraza/spoa.log
log_format: json