CloFix WAF · Scripting Engine

CloFix AI Protection Engine

Inline obfuscated-payload classifier and behavioral anomaly scoring with Threat Learning - CRS-independent, mode-capped, sub-millisecond hot path. Runs custom WAF logic with isolated engines for precise request control.

Scripting Engine #7 16 details Published

Overview

💡 How it works: On each request the AI Protection Engine builds a capped field map (path, query, body, headers), runs Module A payload scoring and Module B behavioral scoring under a hard millisecond budget, then applies CapAction so enforcement never exceeds the configured mode. When Threat Learning is on, high-confidence decisions create or hit IP-independent signatures (skeleton + SimHash for payloads, client fingerprints, behavior sequences). Matching active signatures can challenge or block without CRS. Decisions stream to ClickHouse asynchronously; the in-memory ring powers the Recent table on `/waf-dashboard/ai-engine`. Safe rollout: start at `mode monitor`, watch FP rate, raise to `challenge`, then `block`.

Feature details

CRS-Independent

Runs before / without OWASP CRS - disable CRS and AI still learns and enforces based on `ai_engine` mode

Payload Classifier (Module A)

Multi-layer normalize (URL / HTML entity / Base64 / hex / unicode, max 5 layers) with bomb guards (64KB norm, 16KB per field)

40-Dim Feature Vector

Entropy, density, decode layers, plus attack shapes for SQLi, XSS, RCE, LFI/RFI, SSRF, XXE, SSTI, JNDI, GraphQL, JWT, prompt injection, and more

Logistic Model

Pure-Go logistic regression (`seed-v2` / payload-v2.json) with explainable top feature reasons on every decision

Behavioral Detector (Module B)

Per-domain velocity windows (10s / 1m / 10m / 1h), path diversity, scanner UA signals, EWMA/MAD baselines

Action Ladder

Allow → Monitor → Challenge → RateLimit → Block, then capped by mode ceiling (`monitor` / `challenge` / `block`)

Mode Ceiling (CapAction)

`mode monitor` never returns Challenge/Block even if score is high - safe rollout path

Threat Learning

IP-independent payload / client / behavior signatures with candidate → active lifecycle, campaigns, approve / FP / TP

Learn Modes

`approve_first` (admin must promote) or `auto` (hits + distinct sources); domain or global scope

Fuzzy Matching

SimHash near-match with configurable Hamming distance (default 3); up to 5000 signatures per domain with LRU eviction

Hot-Path Budget

Default 2ms deadline (`budget_ms`); fail-open allows on timeout/panic; fail-closed degrades to monitor

Fingerprint Ban

Configurable `block_time` (default 15m) after AI block

Exclude Paths

Skip dashboard, login, challenge, health, metrics, and custom prefixes

SOC Dashboard

`/waf-dashboard/ai-engine` - KPIs, recent decisions, Threat Learning tab, FP/TP feedback

ClickHouse Telemetry

Async `ai_decisions` / `ai_feedback` / signatures - never blocks Inspect

Config Block

`ai_engine { enabled on; mode monitor; payload on; behavioral on; learning on; … }` in domain conf

How CloFix WAF uses it

💡 How it works: On each request the AI Protection Engine builds a capped field map (path, query, body, headers), runs Module A payload scoring and Module B behavioral scoring under a hard millisecond budget, then applies CapAction so enforcement never exceeds the configured mode. When Threat Learning is on, high-confidence decisions create or hit IP-independent signatures (skeleton + SimHash for payloads, client fingerprints, behavior sequences). Matching active signatures can challenge or block without CRS. Decisions stream to ClickHouse asynchronously; the in-memory ring powers the Recent table on `/waf-dashboard/ai-engine`. Safe rollout: start at `mode monitor`, watch FP rate, raise to `challenge`, then `block`.

Canonical URL: https://clofix.com/features/clofix-waf/ai-protection-engine/