# WAF

> WAF (Web Application Firewall): firewall that inspects HTTP/HTTPS traffic before it reaches the app and blocks SQL injection, XSS and other common attacks.

- **Category**: Technical
- **URL**: https://www.romaindelfosse.fr/en/glossary/waf/

---

A **WAF** (Web Application Firewall) is a specialized firewall that inspects the HTTP/HTTPS traffic headed for a web application and blocks requests that match known attack patterns. Unlike a classic network firewall, which filters IP packets by source and destination, a WAF understands the HTTP protocol: it reads URLs, headers, cookies, GET and POST parameters, and applies rules to detect attempts at SQL injection, cross-site scripting, path traversal, command injection or attacks on business logic.

## Technical definition

### How a WAF works

A WAF sits inline between the client (browser or bot) and the application server. Each incoming HTTP request is analyzed in real time: its components are broken down (URL, method, headers, body), normalized (URL decoding, base64 decoding, encoding conversion) and compared against a list of signatures or rules. If the request matches a known attack pattern, the WAF blocks it (returning a 403 or 404), logs it, and may forward it to a SIEM for correlation.

Rules typically come from two sources: **signatures** provided by the WAF vendor (updated regularly to cover new CVEs), and **custom rules** written by the security team to address the application's specifics (for example: block any request to `/admin` that does not come from a corporate IP).

### Deployment modes

- **Managed cloud WAF** (Cloudflare, AWS WAF, Akamai): placed in front of the site at the CDN level. Pros: can be deployed in minutes, updates handled by the vendor, built-in DDoS protection. Cons: traffic passes through a third party, rules are sometimes opaque, and costs can climb with volume.
- **Reverse proxy WAF** (ModSecurity on Nginx or Apache, Coraza on Envoy): deployed on your own infrastructure, upstream of the application server. Pros: full control over the rules, no third party in the request path, open source and free. Cons: requires expertise to configure and maintain, no built-in DDoS protection.
- **Application WAF** (a WordPress plugin such as Wordfence, PHP/Node middleware): built into the application code. Pros: access to business context for precise rules. Major drawback: it kicks in after the server has already allocated resources to the request, so it is costly in performance and vulnerable to attacks that exploit the loading path itself.

{% figureInteractive "waf", "Send a legitimate request, then a SQL injection: the WAF parses, normalizes, matches the rules and blocks with a 403 before the server, with a log entry." %}

## Current challenges

### False positives, the enemy of deployment

The main practical challenge of a WAF is managing **false positives**: legitimate requests that accidentally match a security rule. A URL containing the word "SELECT" can be mistaken for a SQL injection attempt. A user comment that includes HTML code can trigger an XSS alert. Without a tuning phase, a WAF can block 20% of legitimate traffic, which makes it unusable in production.

The recommended strategy is to deploy the WAF in **detection mode** first (observing without blocking), analyze the hits for several weeks, create exceptions for each false positive identified, then switch to blocking mode once you have statistical proof that the noise is under control.

### Nano-WAFs and lightweight edge filtering

At the opposite end from complex managed WAFs, there is a "nano-WAF" approach: a few hundred lines of code that perform basic perimeter filtering (unusual HTTP methods, User-Agents of known scanners, classic attack paths). This approach does not replace a real WAF against sophisticated attacks, but it closes the most obvious vectors for free and greatly reduces the noise in the logs. This is what I experiment with in [my article on securing WordPress without plugins](/en/blog/securiser-wordpress-sans-plugins-infrastructure-as-code/), where a lightweight mu-plugin combines an allowlist of legitimate User-Agents, a blocklist of scanners and a stealth 404.

## Practical applications

The most effective combination is to stack several WAFs at different levels: a managed cloud WAF (Cloudflare, AWS WAF) to absorb the massive noise and provide DDoS protection, a reverse proxy with ModSecurity or an application-level nano-WAF for application-specific rules, and application-level validation for business cases. Each layer complements the others: it is the classic application of [Defense in Depth](/en/glossary/defense-in-depth/).



## Frequently Asked Questions

### What is the difference between a classic firewall and a WAF?

A classic firewall works at layers 3-4 of the OSI model: it filters IP packets according to rules on source/destination addresses, ports and protocols. It does not read the content of HTTP requests and does not understand what they do. A WAF works at layer 7 (application): it inspects the full content of HTTP requests (URL, headers, cookies, GET/POST parameters, JSON body) and applies rules specific to web attacks. It can detect a SQL injection attempt in a form field, an XSS payload in a URL parameter, or a path traversal attempt targeting /etc/passwd.

### Which WAFs are most widely used?

Managed cloud options: Cloudflare WAF, AWS WAF, Akamai Kona, Azure Application Gateway WAF, Google Cloud Armor. Open source: ModSecurity (the de facto standard, now carried forward by OWASP as Coraza for Go), with the OWASP CRS (Core Rule Set) rules covering the OWASP Top 10 attacks. At the application level: some frameworks and WordPress plugins (Wordfence, Sucuri) implement a mini-WAF in PHP, with all the drawbacks of a late control.

### Is a WAF enough to secure an application?

No. A WAF is one layer of defense, not a complete solution. It blocks known patterns but can be bypassed by targeted attacks or application-specific vulnerabilities. A poorly configured WAF also produces lots of false positives that frustrate legitimate users. It should be part of a Defense in Depth strategy: input validation in the application, prepared statements in the database, strong authentication, encryption and monitoring. The WAF filters out the noise, but the application remains responsible for its own security.



## Resources

- [OWASP ModSecurity Core Rule Set (CRS)](https://coreruleset.org/?utm_source=romaindelfosse&amp;utm_medium=glossaire&amp;utm_campaign=waf) — OWASP

- [Cloudflare WAF — Documentation](https://developers.cloudflare.com/waf/?utm_source=romaindelfosse&amp;utm_medium=glossaire&amp;utm_campaign=waf) — Cloudflare

- [Coraza — open source WAF in Go](https://coraza.io/?utm_source=romaindelfosse&amp;utm_medium=glossaire&amp;utm_campaign=waf) — OWASP Coraza

