# 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.

Source: https://comparehostingonline.com/guides/what-is-a-web-application-firewall/

## 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](https://comparehostingonline.com/methodology/)

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](https://comparehostingonline.com/guides/how-to-secure-a-vps/).

|  | Network firewall | Web application firewall |
| --- | --- | --- |
| Looks at | IP addresses, ports, protocols | The content of HTTP requests |
| Stops | Unwanted connections | Malicious requests to your site |
| Example rule | Allow only ports 80, 443 and 22 | Block requests with SQL syntax in a form field |
| Where it lives | Server or network edge | In 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\](https://comparehostingonline.com/guides/what-is-ddos-protection/).**

## Where can you get a WAF?

| Option | How it works | Notes |
| --- | --- | --- |
| CDN or reverse proxy | Traffic passes through the provider first | Common and easy; see [what a CDN is](https://comparehostingonline.com/guides/what-is-a-cdn/) |
| Host-provided | Built into the hosting platform | Often included on managed WordPress plans |
| Server module | Software on your own server | Needs setup and tuning |
| Plugin | Runs inside your application, such as a WordPress security plugin | Uses 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](https://comparehostingonline.com/guides/what-is-time-to-first-byte/).

## 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](https://comparehostingonline.com/guides/website-backups-guide/), 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](https://comparehostingonline.com/guides/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](https://comparehostingonline.com/guides/website-backups-guide/).

## 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 type | What it does | Example |
| --- | --- | --- |
| Managed rule sets | Maintained signatures for known attacks and common software | Blocks known WordPress plugin exploits |
| Custom rules | Rules you write for your site | Block a path or country, or allow only your office to reach /admin |
| Rate limiting | Limits requests per address or per path | Max five login attempts a minute |
| Bot management | Scores and challenges automated clients | Challenge a client that behaves like a scraper |
| Positive security model | Allows only requests that match a known good pattern | Accept 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](https://comparehostingonline.com/guides/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

-   [OWASP: Web Application Firewall](https://owasp.org/www-community/Web_Application_Firewall)
-   [OWASP Top Ten](https://owasp.org/www-project-top-ten/)
-   [Cloudflare documentation](https://developers.cloudflare.com/ddos-protection/)

## 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

[What is DDoS protection?](https://comparehostingonline.com/guides/what-is-ddos-protection/) [Do you need Cloudflare?](https://comparehostingonline.com/guides/do-you-need-cloudflare/) [Security page](https://comparehostingonline.com/security/)

## More guides

[Bandwidth, storage and data transfer: what is the difference?](https://comparehostingonline.com/guides/bandwidth-vs-storage-vs-transfer/) [cPanel vs Plesk vs DirectAdmin: which hosting control panel?](https://comparehostingonline.com/guides/cpanel-vs-plesk-vs-directadmin/) [Ecommerce hosting checklist: what an online shop needs from a host](https://comparehostingonline.com/guides/ecommerce-hosting-checklist/) [Email hosting vs web hosting: should you keep email separate?](https://comparehostingonline.com/guides/email-hosting-vs-web-hosting/) [Hosting money-back guarantees: what is covered and how to claim](https://comparehostingonline.com/guides/hosting-money-back-guarantee/)

MH

**[Muhammad Hamza](https://comparehostingonline.com/team/muhammad-hamza/)** Founder & Editor

Writes and signs off every comparison, and runs the compliance reviews. Has worked on SOC 2 and HIPAA compliance programs for companies.

Our [editorial policy](https://comparehostingonline.com/editorial-policy/) and [testing method](https://comparehostingonline.com/methodology/) are public.
