A filter in front of your app that reads HTTP requests and blocks known attack patterns.
A Web Application Firewall (WAF) sits in front of a web app and reads every HTTP request. It blocks the ones that look like attacks (SQL injection, XSS, path traversal, bad bots) before they reach your code.
A normal firewall asks "is this machine allowed to talk to that port?" A WAF asks "does this request, once I read it, look like an attack?" To do that it must see inside the request, so it sits where TLS has already been removed: on a reverse proxy, on a CDN edge, in a cloud load balancer, or as a module inside the web server.
Each request is checked against a rule set. A widely used free set is the OWASP Core Rule Set. Rules look for suspicious patterns: SQL keywords in a search box, script tags in a form field, ../ in a file name, a known bad user agent. Many WAFs do not block on one match. They add up points (anomaly scoring) and block only when the total passes a limit. A lower limit means more safety and more false alarms.
| Feature | What it does | Example |
|---|---|---|
| Signature rules | Match known attack patterns | SQL keywords with a quote in a query parameter |
| Anomaly scoring | Add up points from many weak signs, block above a limit | Odd header + encoded characters + long value |
| Allow and deny lists | Always allow or always block certain sources or paths | Allow your office range to /admin, deny a known bad range |
| Rate rules | Limit requests per client or per path | No more than 5 logins a minute from one address |
| Bot management | Tell humans from scripts | Challenge pages, reputation, behaviour |
| Virtual patching | A targeted rule for one known hole | Block the exploit path of a new library bug |
| Schema checks (for APIs) | Reject requests that do not match the API definition | Wrong field type, unknown field, huge body |
The scores are made up for the demo and fixed, so the page looks the same every time. Real WAFs add up points from many rules (for example the OWASP Core Rule Set) and block when the total passes a limit.
| Term | Meaning in easy words |
|---|---|
| WAF | Web Application Firewall: a layer 7 filter in front of a web app |
| Layer 7 | The application layer, where HTTP lives |
| Rule set | A bundle of rules, such as the OWASP Core Rule Set |
| Anomaly scoring | Adding points for suspicious signs and blocking above a limit |
| False positive | A legitimate request that is blocked by mistake |
| False negative | An attack that is not caught |
| Detect mode | The WAF logs what it would block, but lets traffic through |
| Virtual patching | A WAF rule that blocks an exploit until the code is fixed |
| Normalisation | Decoding and cleaning a request so tricks in encoding do not hide an attack |
| Origin | Your real servers behind the WAF |
| Bot management | Telling real users from automated scripts |
| ModSecurity | A well-known open source WAF engine |
| Choice | We gain | We lose |
|---|---|---|
| High sensitivity | More attacks caught | More real users blocked |
| Low sensitivity | Smooth experience | More attacks reach the app |
| Block mode | Real protection | Mistakes are visible to users |
| Detect mode | Safe learning | No protection yet |
| Managed cloud WAF | Easy setup, updated rules | Less control, per-request cost |
| Self-hosted WAF | Full control | You tune and update everything |