CompareHostingOnline

Home / Guides / What is a web application firewall (WAF)? How it works and when you need one

Guide

What is a web application firewall (WAF)? How it works and when you need one

What a WAF blocks, how it differs from a network firewall, where hosts and CDNs offer one and how to avoid blocking real visitors.

By Muhammad Hamza, Founder & EditorUpdated Nov 30, 2026

Short answer

A web application firewall inspects web requests and blocks malicious ones, such as SQL injection and abusive bots, before they reach your site. It complements, but does not replace, updates and strong passwords.

Last verified Nov 28, 2026 · How we test
At a glance
  • What is a web application firewall?A WAF sits between visitors and a web application and examines each HTTP request.
  • How is a WAF different from a normal firewall?You need both.
  • What does a WAF protect against?Injection attacks such as SQL injection.

What is a web application firewall?

A WAF sits between visitors and a web application and examines each HTTP request. It compares requests to rules and blocks, challenges or logs the ones that look like attacks. OWASP describes a WAF as a filter that applies a set of rules to a conversation between a client and a web application, covering attacks such as cross-site scripting and SQL injection.

A WAF understands web traffic, unlike a traditional network firewall that decides by address and port. It can notice that a request to a login page contains a database command, or that a bot is trying thousands of passwords.

How is a WAF different from a normal firewall?

You need both. The server firewall is covered in how to secure a new VPS.

Network firewallWeb application firewall
Looks atIP addresses, ports, protocolsThe content of HTTP requests
StopsUnwanted connectionsMalicious requests to your site
Example ruleAllow only ports 80, 443 and 22Block requests with SQL syntax in a form field
Where it livesServer or network edgeIn front of the site: a CDN, a proxy, the server or a plugin

What does a WAF protect against?

  • Injection attacks such as SQL injection.
  • Cross-site scripting.
  • Brute-force logins and credential stuffing.
  • Scrapers and abusive bots.
  • Known exploits against popular CMS plugins, using virtual patches until you can update.
  • Some application-layer floods, which overlaps with [DDoS protection](/guides/what-is-ddos-protection/).

Where can you get a WAF?

OptionHow it worksNotes
CDN or reverse proxyTraffic passes through the provider firstCommon and easy; see what a CDN is
Host-providedBuilt into the hosting platformOften included on managed WordPress plans
Server moduleSoftware on your own serverNeeds setup and tuning
PluginRuns inside your application, such as a WordPress security pluginUses your server’s resources

Does a WAF slow your site down?

A cloud WAF adds a small processing step, but because it usually comes with a CDN and caching, most sites get faster overall. A plugin or server module uses your own CPU, which matters on small plans. Measure before and after using the method in what TTFB is.

What about false positives?

Rules can block legitimate requests, for example a form that contains code in a post, or an API client that looks like a bot. Start in log-only mode if the product supports it, review what would have been blocked and then enforce. Keep a way to whitelist a path or an IP address, and test your forms, checkout and admin pages after any rule change. Check logs after you turn it on; blocked real customers are lost sales.

Do you need a WAF?

Most public sites benefit, especially those with logins, forms and shops, and sites that run many plugins. Treat it as one layer. Update your software, use strong and unique passwords with two-factor login, keep backups as in website backups, and keep the origin server hardened. A WAF does not fix a vulnerable plugin; it only makes exploitation harder while you patch. See also ecommerce hosting checklist, where a WAF is part of the baseline.

A worked example: what a WAF does with three requests

Picture three requests arriving at an online shop. The first is a normal visitor asking for a product page. The firewall passes it through. The second is a request to the login page that includes a string such as a database command in the username field, a typical injection attempt. The firewall matches it to a rule and blocks it before the application ever sees it. The third is a script that tries two thousand passwords on the admin login in a minute. A rate-limiting rule notices the volume and starts to challenge or block that address.

None of this requires you to change the shop’s code. That is the main appeal. It is also why a firewall cannot fix a vulnerable plugin: if an attacker finds a request that the rules do not recognise, it passes through to the flaw.

How should you maintain a WAF over time?

  • Review the blocked requests each week at first, then monthly, to see false positives and real attacks.
  • Keep rules updated; managed rule sets from your provider update automatically, but custom rules need care.
  • Add exceptions narrowly: allow a specific path or parameter, not a whole class of requests.
  • Test your login, checkout and API after any rule change.
  • Combine it with updates and backups; see website backups.

What types of rules does a WAF use?

Start with managed rules and rate limiting. Add custom rules only for problems you can see in your logs, and document each one so you know why it exists.

Rule typeWhat it doesExample
Managed rule setsMaintained signatures for known attacks and common softwareBlocks known WordPress plugin exploits
Custom rulesRules you write for your siteBlock a path or country, or allow only your office to reach /admin
Rate limitingLimits requests per address or per pathMax five login attempts a minute
Bot managementScores and challenges automated clientsChallenge a client that behaves like a scraper
Positive security modelAllows only requests that match a known good patternAccept only expected parameters on an API

What is the difference between detection and blocking mode?

Most WAFs can run in a monitoring mode that logs what would be blocked without blocking it, and in a blocking mode that enforces the rules. The safe way to roll one out is to run in monitoring mode for a week or two, review what it flagged, add exceptions for legitimate traffic such as your checkout, payment callbacks and API clients, and then switch to blocking. Skipping this step is the usual cause of a firewall blocking real customers.

After you switch, keep watching: a plugin update or a new form can introduce requests that look suspicious to a rule. Keep a quick way to turn a rule off, and check the logs after every release. For online shops, see our ecommerce hosting checklist.

How do you choose a WAF?

  • Check whether it comes with your CDN or host before you buy a separate product.
  • Ask whether managed rules update automatically and who maintains them.
  • Look for a monitoring mode and good logs, so you can tune before you block.
  • Check limits on rules, requests and log retention on your plan.
  • Test the login, checkout and API after turning it on.

Sources and further reading

Common questions

What is a web application firewall?

A WAF inspects web requests and blocks the ones that match attack patterns, such as SQL injection and cross-site scripting, before they reach your site. It understands HTTP content, unlike a network firewall that looks only at addresses and ports.

Do I need a WAF for a small site?

It helps most public sites, especially ones with logins, forms or shops. It does not replace updates and strong passwords. Many CDNs include a basic WAF, so you can get one without much effort.

Can a WAF block real visitors?

Yes, if rules are too strict or an unusual request looks like an attack. Start in log-only mode if possible, review the blocks, then enforce, and test forms, checkout and admin pages after changes.

What is the difference between a WAF and a firewall?

A network firewall allows or denies traffic by address, port and protocol. A WAF reads the content of web requests and applies rules to them. A well-secured site uses both.

Does a WAF slow my website?

A cloud WAF adds a small step but usually comes with caching, so most sites get faster. A plugin or server module uses your own CPU and can slow a small plan. Test before and after.

Related

More guides

Esc

Use the arrow keys, then Enter.