Hybrid Web Application Firewall (Hybrid WAF)
Seven graduated filtering layers plus an LLM arbitration layer.
Project Summary
A hybrid architecture that reconciles accuracy with performance through a cheapest-first principle. Seven graduated layers resolve clear cases cheaply, invoking large models only on ambiguous ones.
The Problem
Rule-based firewalls fail against obfuscated payloads; raising sensitivity multiplies false positives until the site is broken for its users; and sending every request to an LLM is too slow and expensive for production.
The project addresses all three with one principle: lowest cost first — cheap layers settle the obvious cases, and large models are only invoked for grey areas.
Key Features
Seven layers
Protocol, reputation, rate-limit, signatures, semantic, behavioral, AI.
Gray-area AI
Models invoked only when needed.
Structured output
Allow/block, confidence, attack class.
Dual-model cross-check
Compared outputs for higher confidence.
Cumulative scoring
Aggregate risk signals across layers.
Feedback loop
Log arbitration decisions to improve rules.
Technical Challenges & Design Decisions
- Judging grey areas: the first six layers either produce a clear decision or nothing. The seventh (LLM arbitration) is invoked only on uncertainty — which is what makes the system production-viable rather than a research demo.
- Structured output is a prerequisite: you cannot automate a decision built on free text. Prompt engineering forces the model to return an analysable decision (allow/block, confidence, attack class), and the second model acts as a cross-check on critical cases.
- Camouflaged payloads: surface inspection is fooled by repeated encoding. Payloads are therefore decoded in multiple stages and normalised before signature matching.
- Continuous feedback: every arbitration decision is logged so it can become a static rule later, moving the system from "a model called often" towards "a model called rarely".
Technical Architecture
Testing Methodology
- OWASP Top 10 payload classes including obfuscated SQLi, XSS and SSRF, to verify layer-4 signatures still fire after normalisation.
- Measured false positives before and after enabling the AI arbitration layer.
- Measured response latency and the share of requests that actually reach arbitration — the metric that proves the lowest-cost-first principle works.
- Re-tested attack scenarios after every change to the layer map.
Outcome & Impact
- Obvious cases settled by cheap layers, so the normal path sees no noticeable latency.
- Large-model calls are bounded to grey-area cases rather than every request.
- A feedback loop: each grey case becomes a rule, so reliance on inference falls over time.
Full detail of the seven layers and the methodology is in the case study. Status: being prepared for public open-source release.