What Is a WAF (Web Application Firewall)?
A WAF (Web Application Firewall) inspects the actual content of HTTP and HTTPS requests reaching a website, looking for patterns such as SQL injection, cross-site scripting and malicious bot traffic, and blocks or challenges the ones that match its rules. It works at the application layer, which is different from a network firewall that only checks ports, protocols and IP addresses.
How a WAF differs from a network firewall
A network firewall operates on IP addresses, ports and protocols and has no idea what is inside an HTTP request. A WAF sits a layer higher and reads the request itself: the URL, headers, cookies, form fields and request body, looking for signs of an attack. The two are complementary rather than competing; most hardened sites run both, with the network firewall blocking unwanted connections outright and the WAF inspecting the traffic that is allowed through.
What a WAF protects against
| Attack type | Example |
|---|---|
| SQL injection | A form field containing something like ' OR 1=1 -- to try to manipulate a database query |
| Cross-site scripting (XSS) | A <script> tag injected into a comment or input field |
| Malicious bots | Credential stuffing, content scraping, automated vulnerability scanning |
| Path traversal | Requests trying to read files outside the intended folder, such as ../../etc/passwd |
| Application-layer floods | Repeated requests aimed at a single page like a login or search form |
How WAF rules work
Most WAFs combine signature-based rules, which match known attack patterns much like antivirus software, with rate limiting and IP reputation lists that flag known bad sources. Many are run in a logging-only mode at first so administrators can see what would have been blocked before switching to active blocking, which helps catch false positives before they affect real visitors.
Where a WAF runs
- At the edge, built into many CDN services that sit in front of a site's traffic.
- As a reverse proxy appliance placed in front of the web server.
- As a server-level module, such as ModSecurity for Apache and Nginx, often using rule sets like the OWASP Core Rule Set.
- Built directly into some managed hosting plans as a feature you can enable without extra configuration.
Do you need one?
A WAF is most valuable once a site handles logins, contact forms, search boxes or payments, since these are the points attackers target first. Many hosts and CDNs include a basic WAF for free, so there is often little reason not to turn one on. The trade-off is that overly strict rules can occasionally block legitimate traffic, so a new WAF deployment is worth watching for a while and tuning if it flags real visitors.
Frequently asked questions
What does WAF stand for?
WAF stands for Web Application Firewall. It is a security layer that inspects the content of web requests rather than just the network connection carrying them.
Is a WAF the same as a regular firewall?
No. A network firewall filters traffic by IP address, port and protocol, while a WAF inspects the actual content of HTTP requests for application-layer attacks. They are usually deployed together rather than as a replacement for each other.
Does a WAF stop DDoS attacks?
It can absorb or filter some simple application-layer floods aimed at a specific page, but large-scale network-layer DDoS attacks typically require dedicated, higher-capacity mitigation beyond what a WAF alone provides.
Can a WAF block legitimate visitors by mistake?
Yes, this is called a false positive, where an overly strict rule flags normal input as an attack. Most WAFs let administrators review blocked requests and add exceptions once a false positive pattern is identified.
Is ModSecurity a WAF?
Yes. ModSecurity is a widely used open-source WAF module for Apache and Nginx, commonly run with rule sets such as the OWASP Core Rule Set to detect common web attacks.
Do I need a WAF if my site is small?
Even small sites get scanned by automated bots looking for known vulnerabilities, so a basic WAF, often available free through a CDN, is low effort and worth enabling, especially for any site with a login page or a form.
Related topics
- What Is a Firewall? Security & SSL
- What Is an SSL Certificate? Security & SSL
- What Is an IP Address? Networking & IP
- What Is a Database? Databases
- What Is a CDN (Content Delivery Network)? Performance & CDN