GUIDE · ARCHITECTURE · UPDATED 2026-08-29

WAF vs application middleware: where should your security boundary live?

This is usually argued as edge versus application. The more useful question is what information each layer has at the moment it decides — because that determines which attacks it can possibly catch.

What each layer cannot see

The comparison is usually framed as edge versus application. The useful framing is what information each layer has when it decides.

Edge WAFApplication middleware
Runs before your computeYes — bad traffic never costs youNo — you pay for every request it rejects
Sees who the user isNo — no session, no role, no planYes
Sees whether the request is meaningfulNo — a valid-looking request for someone else's data looks fineYes
Absorbs volumetric floodsYes, at provider scaleNo — the flood reaches your origin
Rules you can read and reproduceUsually not — vendor rule sets are opaqueYes — code in version control
Deploys with your applicationNo — separate console, separate change processYes — same pipeline, same review, same rollback
Survives a provider migrationNo — rules are provider-specificYes, if the policy is portable

The asymmetry that decides most designs: a WAF cannot tell the difference between user A requesting their own invoice and user A requesting user B's invoice. Both are well-formed GETs to the same route shape. Authorization is application knowledge — no edge rule set will ever cover it.

What a WAF is genuinely good at

What only middleware can do

When running both is worth the cost

They are not alternatives. The question is whether you need both layers now.

SituationRecommendation
Static site or brochure, no user accountsEdge headers and bot rules are enough
SaaS with accounts, no unusual traffic volumeMiddleware first; it covers the risks that actually apply to you
Public API with paying customersBoth — edge for volume, middleware for per-key budgets and authorization
Consumer product at scale, or a known targetBoth, non-negotiable
Compliance requires documented WAFBoth, and keep the middleware rules as the ones you actually reason about

Running both introduces one recurring failure mode worth naming: double enforcement with different verdicts. When the edge rate limits at 100/min and middleware limits at 60/min, users hit the tighter limit but your dashboards show the looser one, and nobody can explain the support tickets. Decide which layer owns each control, and let the other one stay out of it.

The portability question

WAF rules are written in a provider's rule language and stay with that provider. If your security posture lives entirely in one vendor's console, changing providers means re-deriving it from scratch — and in the meantime nobody can tell you exactly what is being enforced, because the rule set is opaque by design.

Middleware rules move with the code. That is worth something when the same organisation runs sites on static hosting, a Node service and an edge runtime, and wants one answer to "what is our policy?" rather than three consoles to reconcile.

Where TJ Sentinel sits

TJ Sentinel is the middleware layer, deliberately. It does not try to be a WAF and cannot absorb a volumetric flood — that is stated plainly because a tool that overstates its coverage causes worse decisions than one that does not exist. What it provides is the portable half: one policy file, adapters for static hosting, Express, Next.js and Cloudflare Workers, and identical verdicts with the same reason codes across all of them. Run it behind whatever edge protection you already have.

Generate a policy for your site → · Read the stated limits →