Cloud & app security

What Is a Web Application Firewall? How a WAF Protects Your Site

A WAF reads the web requests your network firewall cannot see — and blocks the malicious ones before they reach your application.

Cysoro Security TeamPublished · 9 min read
CLOUD & APP SECURITYWeb appfirewallBlocks web attacks at layer 7.
Quick answer

A web application firewall (WAF) is a security filter that sits in front of a web application or API and inspects every HTTP and HTTPS request before it reaches the server. It blocks requests carrying SQL injection, cross-site scripting, path traversal and other web attacks, using managed rules, signatures and allowlists, while letting legitimate traffic through.

Key takeaways

  • A WAF works at layer 7, inspecting HTTP requests — URLs, headers, bodies and cookies — that a network firewall never reads.
  • It is strongest against injection, cross-site scripting and known OWASP Top 10 attacks, but it cannot fix broken access control or bad code.
  • Cloud WAFs start free with Cloudflare and from $5 per web ACL on AWS WAF; PCI DSS v4.0 requires a WAF or equivalent for public-facing card-handling apps.

A network firewall sees a connection to port 443 and waves it through. It has no idea what is inside the request. A web application firewall does — and that difference is what stops the attacks that actually break websites.

What is a web application firewall?

A web application firewall (WAF) is a security filter that sits in front of a web application or API and inspects every HTTP and HTTPS request before it reaches the server. It blocks requests that match known attack patterns and lets legitimate traffic through.

OWASP defines a WAF as a security solution on the web application level which, from a technical point of view, does not depend on the application itself. In practice it is usually deployed as a reverse proxy: traffic flows through the WAF first, the WAF parses each request, checks it against its rules, and decides to forward, block, challenge or log it.

It works at OSI layer 7, the application layer. That is what separates it from a network firewall, which works at layers 3 and 4 and only sees IP addresses and ports. Cloudflare explains how a WAF reads the URL, headers, cookies and body — the parts where web attacks actually live.

The term is often written as "web application firewall" in full, and the question people ask is usually "what is a web application firewall" when they first meet the term. The short answer is the same either way: it is the layer that understands web traffic.

How does a WAF work?

A WAF terminates the connection, parses the HTTP request into structured fields, and runs those fields through an ordered set of rules. A request that matches a malicious pattern is blocked or challenged; everything else is forwarded to your application.

How a request flows through a WAFVisitorbrowser / bot /API clientWAFparses request,checks rulesAllowedforwarded toyour appBlocked403, challengeor loggedInspected: method, URL, headers, cookies, query strings, bodyDecisions: allow, block, challenge with CAPTCHA, rate-limit, or log and alert
A WAF sits between visitors and your application as a reverse proxy. Illustration by Cysoro.

Most WAFs combine two approaches. A negative security model blocks known-bad patterns: SQL injection strings, cross-site scripting payloads, path traversal sequences and signatures for known exploits. A positive security model does the opposite: it allows only traffic that matches a defined picture of what the application legitimately accepts.

Managed rulesets do most of the work in practice. The OWASP Core Rule Set (CRS) is the open, community-maintained set of generic attack detection rules used by ModSecurity and offered as managed rule groups by Cloudflare, AWS WAF and Google Cloud Armor. CRS 4.0, released in January 2024, uses paranoia levels 1 to 4 — higher means stricter, and more false positives.

Modern cloud WAFs also add rate limiting, bot scoring and machine-learning anomaly detection. Those help against credential stuffing and layer-7 denial of service, where no single request looks malicious but the pattern across thousands of requests does.

WAF vs network firewall: what is the difference?

A network firewall decides whether a connection is allowed based on IP address, port and protocol. A WAF decides whether a specific web request is safe based on its contents. You need both, because they see different things.

Network firewallWeb application firewall
LayerLayers 3–4 (network, transport)Layer 7 (application)
SeesIP addresses, ports, protocolsURLs, headers, cookies, bodies, parameters
BlocksUnwanted ports, bad IPs, floodsSQL injection, XSS, path traversal, bad bots
Typical placeNetwork edge, host firewallIn front of the web app, as a reverse proxy
Blind spotAttacks inside allowed HTTPS trafficNetwork-layer floods, non-HTTP attacks

Take a real example. A request to /search?q=<script>document.cookie</script> arrives over port 443, which your network firewall allows. Only the WAF reads the query string, recognizes the cross-site scripting payload, and blocks it.

A WAF is also different from an intrusion prevention system (IPS). An IPS is signature-based and broad, operating mainly at layers 3 and 4 across all traffic. A WAF is specialized for HTTP and understands the structure of web requests, which is why it catches application attacks an IPS misses.

What attacks does a WAF block?

A WAF is strongest against the application-layer attacks in the OWASP Top 10, the consensus list of the most critical web application security risks. The current edition, OWASP Top 10:2025, leads with broken access control and injection.

  • Injection (A05:2025) — SQL injection, NoSQL injection, command injection and LDAP injection, where attacker input is interpreted as code or a database command.
  • Cross-site scripting (XSS) — scripts injected into pages that run in other users' browsers and steal sessions or deface the site.
  • Path traversal and file inclusion — requests such as ../../etc/passwd that try to read files outside the web root.
  • Security misconfiguration — blocking access to exposed files such as .env, .git/config and backup copies of configuration files.
  • Vulnerable components — virtual patching: blocking exploit patterns for a known CVE in a plugin or library before you can update it.
  • Bad bots and credential stuffing — automated login attempts, scraping and layer-7 denial of service, usually with rate limiting and bot scoring.

What it does not fix matters just as much. A WAF cannot fix broken access control in your code, business-logic flaws such as buying an item for $0, weak passwords, or an attacker logging in with stolen credentials. Those need secure design, patching and strong authentication.

What are the main types of WAF?

WAFs are usually grouped by where they run. The right choice depends on where your application lives and how much operational work you want to take on.

TypeHow it worksBest forTrade-off
Cloud WAFTraffic routed through the provider's edge by DNS changeMost websites and SaaS appsTrust the provider with TLS termination
Host-based WAFSoftware on the web server itself, e.g. ModSecuritySingle servers, custom controlYou maintain rules and updates
Network / appliance WAFHardware or virtual appliance in front of the appOn-premises data centersCost, capacity planning, hardware

Cloud WAFs dominate new deployments in 2026 because setup is a DNS change, not a hardware purchase. Cloudflare, AWS WAF, Azure WAF and Google Cloud Armor all work this way, and many teams now buy them as part of a WAAP bundle with bot management and API security.

Host-based WAFs still make sense when you need full control or your application cannot be proxied. ModSecurity, the open-source engine formed in 2002, remains the best-known option here, usually paired with the OWASP Core Rule Set.

How do you deploy a WAF?

Most cloud WAFs deploy in an afternoon. You point your DNS at the provider, traffic flows through its filters, and your origin server only accepts connections from the provider. That last step matters: if attackers can reach your origin directly, they can bypass the WAF entirely.

Start in log-only or monitoring mode. The WAF records what it would have blocked without blocking anything, so you can see false positives — legitimate requests that match a rule by accident — before they break checkout or logins.

Then move to blocking mode in stages: enable the managed OWASP ruleset first, add custom rules for your own endpoints, and tune the rules that fire on real traffic. Set up alerts for blocked requests and review them weekly at first; a sudden spike often means a new scanner or a new attack campaign, not a misconfiguration.

Keep the WAF's TLS and origin settings tight. Use a full, strict TLS mode so traffic between the WAF and your origin is encrypted, and restrict origin access to the WAF provider's IP ranges. A WAF that only protects the front door is useless if the back door is open.

How much does a WAF cost?

Pricing splits two ways: flat plan prices, and consumption pricing that grows with traffic. The cheapest published path to managed OWASP rules in 2026 is Cloudflare Pro at $20 a month billed annually ($25 monthly), with Business at $200 a month billed annually ($250 monthly). Cloudflare's free plan includes a WAF with a free managed ruleset.

AWS WAF is pay-as-you-go: $5 per web ACL per month, $1 per rule per month, and $0.60 per million requests. That is cheap at low volume and can surprise you at high volume, especially with managed rule groups and extra body inspection, which AWS charges at $0.30 per million requests for each extra 16 KB beyond the default.

Akamai, Imperva, F5 and Fastly are quote-based for enterprise deployments. When comparing quotes, ask what is included: managed rules, bot management, API protection, log retention and support are often separate line items. Cysoro's website security platform covers the monitoring that sits alongside a WAF.

What are the limits and common mistakes?

The most common mistake is treating a WAF as a replacement for secure code. It is a shield, not a fix. If your application has an SQL injection flaw, the WAF hides it from casual scanners — but one bypass, one new payload variant, or one endpoint the WAF does not cover, and the flaw is exposed again.

A WAF stops a lot — but not everythingA WAF helps withSQL injection and XSS payloadsKnown CVE exploit patternsBad bots and credential stuffingExposed config and backup filesLayer-7 denial of serviceA WAF cannot fixBroken access control in codeBusiness-logic flawsStolen credentials used to log inUnpatched code, only hides itAttacks that bypass the WAF
Know what a WAF covers before you rely on it alone. Illustration by Cysoro.

Other mistakes are operational. Deploying in blocking mode on day one breaks legitimate traffic. Never tuning the rules leaves you either drowning in false positives or silently allowing attacks. Forgetting to lock down the origin lets attackers bypass the WAF. And logging without anyone reading the logs means you miss the attack campaign the WAF already spotted.

Finally, remember that a WAF inspects the body only up to a limit. Large uploads and unusual request shapes may pass partially inspected, depending on the plan. Check your provider's body inspection limits before you assume full coverage.

Test before you blockRun any new WAF in log-only mode for at least a week, and run your checkout, login and API flows through it. A false positive on the payment page costs more than the attack it would have stopped.

How do you choose a WAF?

Choose by where your application lives first. If you are on AWS, AWS WAF integrates natively with CloudFront, Application Load Balancer and API Gateway. If you are on Azure or Google Cloud, their native WAFs do the same. If your stack is mixed, a cloud-edge WAF such as Cloudflare protects everything behind one DNS change.

Next, check the managed rules: OWASP Core Ruleset coverage, how fast the vendor ships emergency rules for new CVEs, and how easy it is to write custom rules for your own endpoints. Then check the extras you will actually need — bot management, API protection, rate limiting and log retention — because those are where the price often doubles.

For a small site, start free. Cloudflare's free WAF with its free managed ruleset is a genuine improvement over nothing, and you can upgrade to Pro for the full OWASP ruleset when the site starts taking payments. For an enterprise app, run a short proof of concept with real traffic and measure false positives, not just blocked attacks.

Whatever you choose, pair it with the basics: keep your application patched, enforce strong authentication, and check your site's headers and TLS with our free security headers checker.

OWASP's WAF guidance is the best place to check which rules your chosen WAF should cover.

The bottom line

A web application firewall is the layer that understands your web traffic. It reads the requests your network firewall waves through, blocks the injection, cross-site scripting and bot attacks hiding inside them, and buys your team time to patch properly.

It is not a substitute for secure code, and it is not a set-and-forget box. Deploy it in front of every public-facing application, tune it against real traffic, and lock down the origin behind it. You can start by checking how your own site looks from the outside with the free security headers checker.

Frequently asked questions

What is a web application firewall in simple terms?

It is a filter in front of your website that reads each web request and blocks the ones that look like attacks, such as SQL injection or cross-site scripting, before they reach your application.

What is the difference between a WAF and a firewall?

A network firewall filters traffic by IP address and port. A WAF works at the application layer and reads the HTTP request itself — the URL, headers, body and cookies — so it can stop attacks that look like normal web traffic.

Do I need a WAF for a small website?

If your site takes logins, payments, form submissions or API calls, yes. Automated scanners probe every public site, and a free Cloudflare WAF blocks much of that traffic with a DNS change and no code changes.

What attacks does a WAF block?

It blocks SQL injection, cross-site scripting, path traversal, file inclusion, remote code execution attempts, credential stuffing, and many bad bots. It is less effective against broken access control, business-logic abuse and attacks that use valid credentials.

What is the difference between a WAF and a WAAP?

A WAAP, web application and API protection, is a WAF plus bot management, API security, layer-7 DDoS protection and often account-takeover defenses in one platform. Most cloud WAFs sold in 2026 are really WAAP products.

Can a WAF block all attacks?

No. A WAF is one layer. It cannot fix insecure code, broken authentication, misconfigured servers or leaked credentials. It works best alongside secure coding, patching, strong authentication and monitoring.

How much does a WAF cost?

Cloudflare includes a WAF with a free managed ruleset on its free plan, and fuller rules start at $20 a month on Pro. AWS WAF charges $5 per web ACL per month plus $1 per rule and $0.60 per million requests. Enterprise WAFs from Akamai and Imperva are priced on request.

Is a WAF required for PCI DSS?

PCI DSS v4.0 Requirement 6.4.2, mandatory since 31 March 2025, requires an automated technical solution such as a WAF in front of public-facing web applications that handle cardholder data, or a manual code review process instead.

Sources

  1. OWASP — Web Application Firewall
  2. Cisco — What is a Web Application Firewall (WAF)?
  3. Cloudflare — What is a WAF?
  4. TechPlained — Best WAF 2026: Cloudflare vs AWS vs Akamai vs Imperva
  5. CyberDefenders — What Is a Web Application Firewall (WAF)?
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against OWASP's WAF definition and OWASP Top 10:2025, Cisco and Cloudflare WAF documentation, and vendor pricing pages checked in October 2026.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free