From b348dae4beb4d45ce74d49d6728afc714a4dc88c Mon Sep 17 00:00:00 2001 From: fuomag9 <1580624+fuomag9@users.noreply.github.com> Date: Fri, 6 Mar 2026 17:27:08 +0100 Subject: [PATCH] remove DetectionOnly WAF mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DetectionOnly was fundamentally broken in coraza-caddy (actually blocks requests via anomaly scoring), caused massive audit log flooding, and the threshold workaround had several issues: - t:none is meaningless in a SecAction (no target to transform) - SecRuleEngine directive ordering relative to SecAction is implementation- defined, making the override fragile - host.mode ?? 'DetectionOnly' fallbacks silently gave any host without an explicit mode the broken DetectionOnly behaviour Changes: - Remove DetectionOnly from UI (global settings radio, per-host engine mode) - Coerce legacy DB values of 'DetectionOnly' to 'On' in buildWafHandler - Fix fallback defaults: host.mode ?? 'DetectionOnly' → host.mode ?? 'On' - Fix action parsers: unknown mode defaults to 'On' (was 'DetectionOnly') - Fix global settings defaultValue: ?? 'DetectionOnly' → ?? 'On' (or 'Off') - Remove the fragile threshold SecAction workaround - Update types: mode is now 'Off' | 'On' throughout Co-Authored-By: Claude Sonnet 4.6 --- app/(dashboard)/proxy-hosts/actions.ts | 2 +- app/(dashboard)/settings/SettingsClient.tsx | 6 ++---- app/(dashboard)/settings/actions.ts | 2 +- app/(dashboard)/waf-events/WafEventsClient.tsx | 2 +- src/components/proxy-hosts/WafFields.tsx | 6 +++--- src/lib/caddy.ts | 14 ++++---------- src/lib/models/proxy-hosts.ts | 2 +- src/lib/settings.ts | 2 +- 8 files changed, 14 insertions(+), 22 deletions(-) diff --git a/app/(dashboard)/proxy-hosts/actions.ts b/app/(dashboard)/proxy-hosts/actions.ts index bc438b06..0e54ed4d 100644 --- a/app/(dashboard)/proxy-hosts/actions.ts +++ b/app/(dashboard)/proxy-hosts/actions.ts @@ -393,7 +393,7 @@ function parseWafConfig(formData: FormData): { waf?: WafHostConfig | null } { const wafMode: WafHostConfig["waf_mode"] = rawMode === "override" ? "override" : "merge"; const rawEngineMode = formData.get("waf_engine_mode"); const engineMode: WafHostConfig["mode"] = - rawEngineMode === "On" ? "On" : rawEngineMode === "Off" ? "Off" : rawEngineMode === "DetectionOnly" ? "DetectionOnly" : undefined; + rawEngineMode === "On" ? "On" : rawEngineMode === "Off" ? "Off" : undefined; const loadCrs = parseCheckbox(formData.get("waf_load_owasp_crs")); const customDirectives = typeof formData.get("waf_custom_directives") === "string" ? (formData.get("waf_custom_directives") as string).trim() diff --git a/app/(dashboard)/settings/SettingsClient.tsx b/app/(dashboard)/settings/SettingsClient.tsx index dc22a172..cbdf68fd 100644 --- a/app/(dashboard)/settings/SettingsClient.tsx +++ b/app/(dashboard)/settings/SettingsClient.tsx @@ -811,9 +811,8 @@ export default function SettingsClient({ Engine Mode - + } label="Off" /> - } label="Detection Only" /> } label="On (Blocking)" /> @@ -874,8 +873,7 @@ export default function SettingsClient({ - WAF events (blocked requests) are stored for 90 days and viewable under WAF Events in the sidebar. - Events only appear when the engine is set to On (Blocking) — Detection Only mode matches rules without blocking and produces no events here. + WAF events are stored for 90 days and viewable under WAF Events in the sidebar.