All posts

Blog

What Is a Web Application Firewall (WAF) and Does Your Site Need One?

Illustrated cover for the Security & SSL guide "What Is a Web Application Firewall (WAF) and Does Your Site Need One?"

A regular firewall is like a fence around a building. It decides which roads lead in and blocks traffic on roads that shouldn't be open. But a website has to keep its front door open to the whole internet. Attackers walk right through that front door, dressed as ordinary visitors, carrying malicious requests.

A web application firewall (WAF) is the security guard standing at that front door, inspecting each request before it reaches your site. This guide explains what a WAF does, the different types, and how to decide whether your site needs one.

How a WAF is different from a network firewall

A traditional network firewall works at a lower level. It allows or blocks traffic based on things like IP addresses and ports. For example, it might allow web traffic on ports 80 and 443 and block everything else.

A WAF works at the application layer. It understands HTTP requests, the actual content your browser sends: URLs, form fields, cookies, headers and uploaded files. That lets it spot attacks hidden inside otherwise normal-looking web traffic.

What attacks does a WAF help block?

WAFs are designed to catch many common web attacks, including those listed in the OWASP Top 10, a widely used list of critical web application security risks. Examples:

  • SQL injection: sneaking database commands into form fields or URLs to read or change data.
  • Cross-site scripting (XSS): injecting malicious JavaScript that runs in other visitors' browsers.
  • File inclusion and path traversal: tricking a script into loading files it shouldn't, such as ../../etc/passwd.
  • Remote code execution attempts targeting known vulnerabilities in popular software.
  • Malicious file uploads, such as PHP shells disguised as images.
  • Bad bots and scanners probing thousands of sites for weaknesses.
  • Brute-force login attempts, when combined with rate limiting.

Many WAFs also offer virtual patching: rules that block exploitation of a newly disclosed vulnerability in, say, a popular WordPress plugin, protecting sites even before every owner has updated.

How a WAF decides what to block

WAFs use a mix of approaches:

  • Signature rules: patterns that match known attacks. The OWASP Core Rule Set (CRS) is a well-known open-source rule set used with ModSecurity and other WAF engines.
  • Anomaly scoring: each suspicious characteristic adds points, and a request is blocked when its score crosses a threshold.
  • Rate limiting: blocking or challenging clients that make too many requests too quickly.
  • Reputation data: blocking IPs or networks known for malicious activity.
  • Allowlists and custom rules: site-specific rules, such as restricting an admin area to certain countries or IPs.

Types of WAF

1. Server-based WAF (on your hosting server)

The WAF runs on the same server as your site, often as a web server module. ModSecurity is a widely used example, and it's commonly available on Apache, LiteSpeed and Nginx setups. Many hosting providers run a server-level WAF for all accounts, and control panels like cPanel may let you see whether ModSecurity is enabled for your domains.

Pros: no DNS changes, usually included with hosting, low latency. Cons: the attack traffic still reaches your server, so it doesn't help much with large traffic floods.

2. Cloud-based WAF (DNS or proxy level)

You point your domain's traffic through a provider's network, typically by changing nameservers or DNS records. The provider filters requests before forwarding clean traffic to your hosting server. Many CDN providers include WAF features.

Pros: blocks attacks before they hit your server, often bundled with a CDN and DDoS protection, managed rules updated by the provider. Cons: you rely on a third party, configuration lives outside your hosting account, and you need to make sure attackers can't bypass it by hitting your server's IP directly.

If you're curious about the CDN side, see our guide to what a CDN is, and for traffic floods, what a DDoS attack is.

3. Application-level WAF (plugins)

Some CMS security plugins include firewall features that run inside the application. For WordPress, several popular security plugins offer this.

Pros: easy to install, understands the application's context (for example, which user is logged in). Cons: runs inside PHP, so malicious requests still use server resources, and it only protects that one application.

Does your site need a WAF?

If your site is public, it is being probed by automated scanners, whether it's a huge store or a tiny portfolio. A WAF is worth having for most sites, and the question is really which layer and how much configuration.

Consider stronger WAF protection if:

  • You run WordPress, Joomla or another popular CMS with many plugins
  • You process logins, accounts or payments
  • You've been hacked before
  • You see heavy bot traffic or brute-force attempts in your logs
  • You can't always update plugins the moment a fix is released

For a simple static site with no forms or logins, the server-level WAF your host provides may be plenty.

What a WAF can't do

A WAF is one layer, not a magic shield. It won't:

  • Fix vulnerable code. If a plugin is broken, update or remove it.
  • Protect you if an attacker logs in with a stolen password.
  • Replace backups, as covered in the 3-2-1 backup rule.
  • Catch every attack, especially new or highly targeted ones.

Think of it as reducing risk and buying you time, not removing the need for good security habits like those in our WordPress security checklist.

Dealing with false positives

Occasionally a WAF blocks legitimate activity. Common examples include saving a page with code snippets, submitting a form containing unusual characters, or using a page builder that sends large requests. Symptoms include 403 Forbidden errors or a "Not Acceptable" message.

If that happens:

  1. Note the exact time, URL and action you were performing.
  2. Check your WAF or security plugin logs if available.
  3. Ask your host's support team to look up the rule that triggered. They can often whitelist a specific rule for a specific path rather than turning the whole WAF off.

Resist the temptation to disable the WAF completely to fix one form. Narrow exceptions keep the rest of your site protected.

Wrapping up

A web application firewall inspects incoming web requests and blocks those that look like attacks, such as SQL injection, XSS and malicious uploads. You can have one at the server level, in the cloud in front of your site, or inside your CMS, and layering them is common. A WAF doesn't replace updates, strong passwords and backups, but for most public websites it's a valuable and often low-effort layer of protection.