What it is
A web application firewall, usually shortened to WAF, sits between the internet and your website or API. Every request passes through it first. The WAF reads the request, compares it with a set of rules, and either lets it through or blocks it.
A network firewall decides which doors are open. A WAF looks at what people say once they walk through the open door. It understands web traffic: addresses, form fields, headers and the contents of requests.
What it catches
A WAF's rules are tuned to common web attacks. Typical targets include:
- SQL injection, where database commands are slipped into a form field.
- Cross-site scripting, where malicious script is planted in a page.
- Attempts to read files or folders the site never meant to expose.
- Floods of automated requests from bots, often paired with rate limiting.
Many WAFs also keep lists of known bad sources and let you write custom rules, such as "block any request to the admin page from outside our office."
Detection mode versus prevention mode
A WAF can run in two ways. In detection mode, it logs suspicious requests but lets them through. In prevention mode, it actually blocks them. Teams often start in detection mode to see what the rules would catch, then switch to prevention once they trust the results. A WAF left in detection mode watches an attack happen and does nothing about it.
What it cannot do
A WAF is a safety net, not a repair. If your app has a flaw, a WAF may block the common ways to reach it, but a determined attacker can try a new variation. Rules can also block legitimate users by mistake, which is why tuning matters.
It works best alongside fixes in the code itself, tight permissions (least privilege) and good secrets management.
Why it matters with AI-driven attacks
Automated attack tools, including AI agents used for penetration testing, can fire many varied requests per minute against a site. A WAF is one of the few defenses that works at that speed, because it makes the block decision for every request without waiting for a person.
It is also a stopgap. When a new flaw is announced and a patch is not ready, a WAF rule can shield the app in the meantime, a technique known as virtual patching.
When to look at yours
If you run anything on the internet, find out whether a WAF is in front of it, which mode it is in, and who reads its logs.