What Is a WAF? Web Application Firewalls Explained
A WAF is a filter sitting in front of a web app that inspects HTTP traffic for attack patterns like SQL injection and blocks malicious requests.
A WAF, or web application firewall, is a filter that sits between clients and a web application, inspecting HTTP and HTTPS requests for known attack patterns and blocking or flagging the malicious ones before they reach application code. It operates at a different layer than a traditional network firewall — instead of filtering by IP address and port, a WAF reads the actual contents of requests: URL paths, headers, query strings, form bodies, and cookies.
What it actually inspects
A traditional firewall answers “should this packet reach this port.” A WAF answers a much more specific question: “does the content of this HTTP request look like an attack.” It does this by matching requests against a ruleset — either a curated set of signatures for known attack classes, or behavioral rules tuned to a specific application.
Common patterns a WAF looks for:
- SQL injection attempts — request parameters containing SQL syntax fragments like
' OR 1=1--that suggest an attempt to manipulate a backend query. - Cross-site scripting payloads —
<script>tags or event handler attributes injected into fields that will later be rendered as HTML. - Path traversal —
../../etc/passwd-style sequences trying to escape an intended directory. - Abnormal request rates or sizes — a flood of requests from one source, or a request body far larger than the endpoint should ever receive.
- Known bad IP ranges or bot signatures — traffic matching fingerprints of scanning tools or previously identified malicious sources.
When a request matches a rule, the WAF can block it outright, log it for review, or challenge it (with something like a CAPTCHA), depending on configuration.
Where it sits in the request path
A WAF is typically deployed as a reverse proxy in front of the application, or as a module bolted onto one — every request passes through the WAF before it reaches the origin server. This is the same position in the request path as a reverse proxy or the edge of a CDN, and in practice the three are often bundled together: a CDN provider inspects and filters traffic at the same edge locations where it’s already caching and routing requests, so WAF rules run before a request ever travels to origin infrastructure. Some deployments layer a WAF behind a load balancer instead, filtering traffic after it’s been distributed across backend instances.
WAF vs application-level input validation
A WAF is not a replacement for validating input inside your application — it’s a second layer that catches classes of attack that slip past app-level mistakes, or that never reach app code that would have handled them correctly. Rate limiting, CSRF tokens, CORS policies, and a well-configured Content Security Policy all address specific, narrower threats inside the application itself; a WAF is a broader net sitting in front of all of that. Relying on a WAF alone as the only defense is a common mistake — WAF rules are pattern-based and can be bypassed by encoding or obfuscating a payload in a way the signature doesn’t recognize, whereas fixing the underlying vulnerability (parameterized queries instead of string-concatenated SQL, for example) closes the hole regardless of how the payload is disguised.
| Application-level validation | WAF | |
|---|---|---|
| Runs where | Inside app code | In front of the app, at the network edge |
| Catches | What developers explicitly coded for | Broad, pattern-matched attack classes |
| Update cycle | Requires a code deploy | Rules can update independently |
| Bypassable by | Logic bugs the code didn’t anticipate | Obfuscated or encoded payloads evading signatures |
| Best used | As the primary defense | As a second layer, not a substitute |
Signature-based vs behavioral rules
Signature-based rules match known attack strings and are effective against well-documented, widely used exploit patterns, but they lag behind novel attacks until a new signature is written and deployed. Behavioral or anomaly-based rules instead build a baseline of what “normal” traffic to a specific application looks like — typical request rates, typical parameter shapes — and flag deviations from that baseline. Most production WAFs combine both: signatures for known, high-confidence attack patterns, and rate- or anomaly-based rules to catch unusual traffic that doesn’t match a signature but still looks wrong.
Where it fits in a broader security posture
A WAF is one control among several in a defense-in-depth strategy, alongside practices like zero-trust network segmentation, supply chain security for the dependencies your application ships with, and correct authentication for any REST API endpoints it exposes. None of these substitute for the others — a WAF blocks malicious HTTP traffic at the edge, but it does nothing for a compromised dependency shipped inside your own build, or for an API endpoint with no authentication check at all.
The takeaway
A WAF inspects the content of HTTP requests for known and anomalous attack patterns and sits in front of an application, usually as part of a reverse proxy or CDN layer, to block malicious traffic before it reaches origin servers. It’s a valuable second layer of defense, not a substitute for fixing the underlying vulnerabilities in application code — pair it with proper input validation, parameterized queries, and the narrower, purpose-built protections like CSRF tokens and CSP that address specific attack vectors a signature-based filter can’t fully cover.
Tagged
Keep reading
Chisato · · 5 min read IDS vs IPS: Intrusion Detection vs Prevention
An IDS watches network traffic and alerts on threats; an IPS sits inline and blocks them automatically. How the two compare and when to use each.
Chisato · · 4 min read What Is Clickjacking? UI Redress Attacks Explained
Clickjacking tricks a user into clicking something they can't see, hidden inside an invisible iframe. How the attack works and how to stop it.
Chisato · · 4 min read What Is Subresource Integrity (SRI)?
Subresource Integrity lets a browser verify a fetched script or stylesheet matches an expected hash, blocking a tampered CDN asset from running.