Worried that attackers will probe your site’s forms and logins? A web application firewall sits in front of your site, reads each HTTP request, and blocks attacks such as SQL injection before they reach your code. It helps, but it does not replace patching.
This guide is one part of our wider coverage of website security.
| Item | Value |
|---|---|
| ModSecurity open-source WAF engine, in protection use since | 2002 |
| Release the CRS install guide recommends for production | v4.25.0 |
| Rule ID that switches off CRS response rules | 900500 |
| First CRS version with that switch | 4.10.0 |
| CRS licence | Apache License 2.0 |
These figures come from the OWASP WAF Projects page and the CRS documentation. They can change, so check the source before you rely on them.
What a web application firewall does
A WAF is a specific form of application firewall that filters, monitors, and blocks HTTP traffic to and from a web service, as Wikipedia’s overview puts it. It is deployed in front of web applications and analyzes web traffic in both directions, detecting and blocking anything malicious.
Red Hat’s primer for Linux sysadmins describes the job simply: inspect all HTTP traffic bound for a web server, discard the bad requests, and pass the good ones on. The same primer notes that the first device built and named as a firewall came from DEC in the 1980s.
Dedicated WAF tooling is younger than that. The open-source engine ModSecurity has been protecting web applications since 2002, according to the OWASP WAF Projects page.
What does a WAF block?
By inspecting HTTP traffic, a WAF can prevent attacks that exploit a web application’s known weaknesses. Wikipedia lists these examples:
- SQL injection
- Cross-site scripting (XSS)
- File inclusion
- Improper system configuration
Rule sets aim wider than that list. Red Hat says the Core Rule Set includes signatures for all of the OWASP Top Ten web application security risks, plus a wide variety of other attacks (Red Hat).
A WAF also buys you time. When a flaw is found in your code and a fix will take a while, a custom policy can act as a virtual patch, a temporary but immediate fix, per Wikipedia.
How a WAF decides what to block
Early WAF products work much like antivirus software: you give them a list of what to block. Red Hat calls this signature-based detection. A simple signature looks for telltale fragments of an attack inside a GET or POST request and drops the request on a match (Red Hat).
The catch is upkeep. Signatures work well but need a lot of maintenance so that false positives stay low, and writing them means matching an attack pattern without catching legitimate traffic.
Wikipedia adds that WAFs typically follow a positive security model, a negative one, or a mix, as the SANS Institute describes (Wikipedia). In plain terms, a negative model blocks known-bad patterns, while a positive model allows only known-good ones.

Where the WAF sits: deployment options
WAFs are deployed inline in three ways, according to NSS Labs as summarized by Wikipedia:
- Transparent bridge: the WAF sits in the traffic path without the client or server noticing.
- Transparent reverse proxy: traffic goes straight to the web application, so the WAF stays invisible between client and server.
- Reverse proxy: the client’s traffic goes to the WAF, which then separately sends filtered traffic on to the web application.
The reverse proxy mode can give extra benefits such as IP masking. It may also add performance latency, so test response times after switching it on (Wikipedia).
Open-source engines and rule sets
If you run your own server, you can build a WAF from free parts. The OWASP WAF Projects page lists ModSecurity as the original open-source engine and Coraza as a next-generation engine built from the ground up in Go for cloud-native environments.
Both engines need rules, and the usual choice is OWASP CRS. The CRS documentation describes it as a free, open-source collection of rules that work with ModSecurity and compatible WAFs, designed to give generic attack detection with a minimum of false positives.
Plan to tune it anyway. Red Hat warns that anyone deploying the CRS will inevitably need to tweak the rules, which takes some grasp of the rule language and of HTTP (Red Hat).
One default deserves a test before launch. The CRS install guide says response rules are on by default, and that an attacker who can get input echoed back in a response might make the WAF block that response for all clients. Since CRS 4.10.0 you can disable them by uncommenting rule ID 900500 in the setup file.
When comparing products, OWASP’s WAFEC project offers a vendor-neutral framework for evaluating, testing, and comparing WAF capabilities, though the same page admits it has not been updated in many years.
Where a WAF fits in your wider defenses
A WAF is not a complete answer. Wikipedia says WAFs are meant to work alongside network firewalls and intrusion prevention systems as part of a holistic defense (Wikipedia).
Before you choose one, check these points:
- Whether it covers the OWASP Top Ten risks at a minimum.
- How you will tune it and who watches the false positives.
- Whether your hosting setup lets you run it in front of the site.
- How you will test it after each rule change.
If your site runs on WordPress, our wordpress security guide covers the platform-specific side. For attacks meant to knock a site over rather than break into it, see our guide to ddos protection.
Frequently asked questions
Does a WAF replace fixing vulnerable code?
Show answer
No. It filters requests and can cover a gap for a while, but the flaw stays in the application until you correct it.
Can a WAF block real visitors by mistake?
Show answer
Yes. Rules that are too broad can flag normal requests as attacks, which is why rule sets need tuning and monitoring after you turn them on.
Is there a free WAF I can try?
Show answer
Open-source options exist. ModSecurity and Coraza are free engines, and OWASP CRS supplies free rules for them, as listed by OWASP.
Does a WAF only protect websites I host myself?
Show answer
A WAF can be a software or hardware appliance, or part of other network components, per the PCI DSS definition quoted on Wikipedia. What matters is that it sits between the web application and the client.



