A web application firewall (WAF) is a filter that sits in front of a website or web app, reads each incoming web request, and blocks or flags requests that match known attack patterns before they reach the application.
A WAF is one tool within application security, the wider topic covered in Application Security for Beginners. It is different from the network firewall described in Firewalls for Beginners: a network firewall mostly decides which connections are allowed, while a WAF looks inside the web traffic itself. This guide is for newcomers, website owners and managers with no security background.
By the end of this guide you will be able to:
- Explain what a WAF does and how it differs from a network firewall.
- Describe how a WAF decides whether to block a request.
- Identify what a WAF cannot fix, so it is not mistaken for a complete defence.
Key takeaways
- A WAF reads web requests, not just connections. It checks the content of each request, such as form fields and web addresses, against rules.
- It is best at common, well-known attacks. Rules typically target attacks such as SQL injection and cross-site scripting.
- It needs tuning. Generic rules sometimes block real customers, so new rules are usually watched in a log-only mode before blocking.
- It reduces risk; it does not fix your code. Flaws in logic or permissions usually pass straight through, so the application still needs fixing.
What it is, in plain English
Every time you load a web page, submit a form or log in, your browser sends a request to the website using a protocol called HTTP. Most requests are ordinary. Some are crafted by attackers to trick the application, for example by typing database commands into a search box. A web application firewall inspects these requests on the way in.
OWASP, the open community behind many web security standards, describes a WAF as an application firewall for HTTP applications that applies a set of rules to an HTTP conversation, with rules that cover common attacks such as cross-site scripting (XSS) and SQL injection.[1] It also notes that a WAF can be considered a reverse proxy, a server that receives traffic on behalf of the website, and that WAFs may come as an appliance, a server plug-in or a filter.[1] Many are also offered as cloud services.
Think of a mailroom that opens every parcel before it reaches the office and holds back anything that matches a list of known dangerous items. Where the analogy breaks down: the mailroom only knows the list it has been given. A harmless-looking letter asking accounts to pay a fake invoice will pass, just as a WAF usually passes a well-formed request that abuses the application's own rules. That is why a WAF matters as an outer layer, especially while a known flaw waits to be fixed, but cannot replace secure code.
How it works, step by step
- Traffic is routed through the WAF. The website's address points to the WAF, which receives each request first.
- The request is inspected. The WAF reads the web address, headers, cookies and any submitted data.
- Rules are checked. Each rule looks for a pattern linked to an attack. In the widely used OWASP CRS rule set, matching rules can add points to an anomaly score for the request rather than blocking on their own; if the total reaches a threshold (5 by default for incoming requests), the request is denied.[3]
- A decision is made. The request is allowed, blocked, or allowed and logged, depending on the rules and the mode the WAF is in.
- Everything is logged. Blocks and alerts are recorded so people can investigate attacks and spot mistakes.
- Rules are tuned. When a genuine request is blocked by mistake, a false positive, the team adds a narrow exception rather than switching protection off.[4]
Rules come from three main places: free open-source sets such as OWASP CRS, which describes itself as a collection of rules for ModSecurity and compatible WAFs aiming for generic attack detection with a minimum of false positives;[2] managed rule sets maintained by a WAF provider; and custom rules your team writes. A custom rule written to block attempts against one known weakness, while the code fix is prepared, is called a virtual patch. The OWASP Virtual Patching Cheat Sheet stresses that a virtual patch does not remove the underlying vulnerability, and suggests starting new virtual patches in a "Log Only" configuration.[5]
A worked example
Penrose Crafts is a fictional online shop run by four people. Its developer, Amir, learns from a security notice that the shop's plug-in for product reviews has a known SQL injection weakness. The fixed version will not be ready for a week.
The shop already uses a cloud WAF with an open-source rule set at a low strictness level. Amir adds a custom rule that targets requests to the review page carrying the suspicious pattern, and sets it to log only for a day. The log shows the rule would have blocked a handful of scanning attempts and no genuine reviews, so he switches it to blocking, with a note in the team's change log to remove it once the plug-in is updated.
A few days later, customers report that reviews with apostrophes, such as "it's lovely", are being rejected. That is a false positive from a general rule. Amir adds a narrow exception for the review text field only, rather than lowering protection for the whole site. When the plug-in update arrives, he installs it and retires his temporary rule. The WAF bought time and reduced exposure; the real fix was still the update.
Common mistakes
| Mistake | What to do instead |
|---|---|
| Leaving the WAF in log-only mode for good. | Use log-only mode for a short, agreed period, review the results, then switch to blocking with a date in the diary. |
| Turning the WAF off when it blocks a customer. | Add a narrow exception for the affected page or field. CRS advises that the correct answer to false positives is to tune them away.[4] |
| Treating a virtual patch as the fix. | Keep the virtual patch only until the code or vendor fix is installed, then remove it.[5] |
| Leaving the website reachable without going through the WAF. | We suggest allowing traffic to the web server only from the WAF, so attackers cannot go round it. |
| Expecting a WAF to catch every flaw. | Flaws such as broken access control and business logic flaws use normal-looking requests, so fix them in the application. |
| Never reading the logs. | Review blocks and alerts regularly; noisy, ignored alerts hide real attacks.[4] |
Key terms
- Web application firewall (WAF)
- A control that inspects web (HTTP) traffic and applies rules to detect or block malicious requests.
- Reverse proxy
- A server that receives incoming traffic on behalf of a website or service before passing it on.
- OWASP Core Rule Set
- A widely used, free set of WAF rules that detects common web attack patterns.
- False positive
- An alert or block triggered by activity that is actually harmless.
- Detection mode
- A setting in which rules observe and alert on suspicious traffic without blocking it, used to test rules first.
- Virtual patching
- A compensating control that blocks known exploit attempts without changing the vulnerable code.
- SQL injection
- A flaw where untrusted input is treated as part of a database query.
- Cross-site scripting (XSS)
- A flaw where untrusted input causes script to run in a visitor's browser.
First steps
Three things you can do this week:
- Find out if you already have one. Ask your hosting, website platform or content delivery provider whether a WAF is included and whether it is switched on.
- Check its mode. Confirm whether it is blocking or only logging, and who reviews its alerts.
- Agree how exceptions are handled. Decide who can add an exception, how it is recorded and when it is reviewed, so that any relaxation is controlled and time-limited.
Checklist
Checklist:
- Every public website and web app we run sits behind a WAF, or we have recorded why not.
- The WAF is in blocking mode for the main rule set.
- Our web servers accept traffic only via the WAF where the set-up allows it.
- Exceptions are narrow, written down and reviewed.
- Virtual patches have a removal date tied to the real fix.
- Someone reviews WAF logs and alerts regularly.
- We still patch and test our applications; the WAF is an extra layer.
Suggested learning pathway
- Start with the umbrella topic: Application Security for Beginners.
- For the network-level difference, read Firewalls for Beginners.
- For the risks WAFs target, read OWASP Top 10 for Beginners.
- For two common attacks in detail, read SQL Injection for Beginners and Cross-Site Scripting for Beginners.
- For deployment, tuning and rule sets in depth, see the Web Application Firewall Guide.
- For where a WAF ends and other tools begin, see Bot Management vs WAF and DDoS Protection vs WAF.
Standards and references
- Web Application Firewall. OWASP Community. https://community.owasp.org/Web_Application_Firewall, accessed 27 Nov 2026.
- OWASP CRS Documentation. OWASP CRS project. https://coreruleset.org/docs/, accessed 27 Nov 2026.
- Anomaly Scoring. OWASP CRS Documentation, OWASP CRS project. https://coreruleset.org/docs/2-how-crs-works/2-1-anomaly_scoring/index.html, accessed 27 Nov 2026.
- False Positives and Tuning. OWASP CRS Documentation, OWASP CRS project. https://coreruleset.org/docs/2-how-crs-works/2-3-false-positives-and-tuning/index.html, accessed 27 Nov 2026.
- Virtual Patching Cheat Sheet. OWASP Cheat Sheet Series. https://cheatsheetseries.owasp.org/cheatsheets/Virtual_Patching_Cheat_Sheet.html, accessed 27 Nov 2026.
Related NHI Mgmt Group resources: API Security for Beginners · DDoS Attacks for Beginners · Bot Management Guide