ExplainerBeginnerWeb application security

What Is a WAF (Web Application Firewall)? A Beginner's Guide

What a Web Application Firewall does, how it differs from a network firewall or IPS, and how to deploy one in minutes with ModSecurity and Docker.

Emanuel De AlmeidaAugust 31, 202618 min read

Level

Beginner

Reading time

18 min

Concept

Web Application Firewall (WAF)

Last reviewed

August 31, 2026

Every day, millions of websites and APIs are probed by automated bots looking for the smallest flaw. A Web Application Firewall (WAF) is the security layer built to filter that hostile traffic before it reaches your applications, inspecting HTTP requests in depth rather than just checking IP addresses and ports.

Key takeaways

  • A WAF inspects HTTP and HTTPS traffic at the application layer, unlike a network firewall which only sees IP addresses, ports, and protocols.
  • Most WAFs run as a reverse proxy, terminating TLS so they can inspect decrypted request content before forwarding it.
  • The OWASP Core Rule Set uses anomaly scoring, adding severity based points per matched rule rather than blocking on the first match.
  • Open source options like ModSecurity, Coraza, and BunkerWeb let teams deploy a WAF without licensing costs.
  • A WAF complements secure development and patching, it does not replace them.

Quick explanation

In simple terms

A WAF is a filter that sits between visitors to a website and the website itself, blocking harmful requests before they can cause damage.

Technical definition

A Web Application Firewall is a layer 7 security control that inspects HTTP and HTTPS traffic content, including URLs, headers, cookies, and parameters, to detect and block requests matching known or anomalous attack patterns.

Analogy

A network firewall is like a building's front desk checking ID badges. A WAF is like a security officer who also reads every visitor's stated purpose in detail before letting them past the desk.

Definition

A Web Application Firewall (WAF) is a security layer that inspects HTTP and HTTPS traffic at the application level to detect and block malicious requests aimed at web applications, such as SQL injection or cross site scripting.

A Web Application Firewall (WAF) is a security solution that analyzes HTTP and HTTPS traffic exchanged between clients, such as browsers, mobile apps, scripts, and bots, and a web application, in order to detect and block malicious requests. It is effectively a firewall specialized in protecting web applications rather than networks.

Unlike a traditional network firewall, which reasons in terms of IP addresses, ports, and protocols, a WAF operates at the application layer, layer 7 of the OSI model. This lets it understand the actual content of an HTTP request: the requested URL, headers, cookies, and parameters passed in the URL or request body. That depth of analysis is what allows a WAF to catch a SQL injection attempt hidden in a form field, where a network firewall would only see an ordinary packet destined for port 443.

A WAF can take several forms: a physical appliance installed in a data center, a virtual appliance or software module such as ModSecurity for Apache, or a cloud based WAF-as-a-Service offered by providers like Cloudflare, AWS, Azure, or Akamai. Regardless of the form factor, the WAF sits on the path of HTTP and HTTPS requests and acts as a filter.

Why it matters

Web applications and APIs are constantly probed by automated bots and attackers. A WAF blocks the most common web attacks before they reach the application, buys time against newly disclosed vulnerabilities through virtual patching, and generates logs that provide visibility into who is attacking what.

Core concepts

Negative security model (blocklist)

The practice of comparing incoming traffic against a fixed set of known attack signatures and blocking anything that matches.

The negative security model, also called a blocklist approach, lets all traffic through except requests matching known attack patterns. The OWASP Core Rule Set works this way: hundreds of rules describe the typical structure of SQL injection, cross site scripting, and other common attacks.

This model is fast to deploy since it needs no prior knowledge of how the protected application behaves. Its main weakness is that unknown or heavily obfuscated attacks can slip through if they do not match an existing signature. Most production WAF deployments rely primarily on this model.

Why it matters — It is the fastest way to get broad protection against known, widespread attack patterns without needing deep knowledge of the application.

Positive security model (allowlist)

A stricter filtering approach that blocks all traffic except requests explicitly defined as legitimate for a given application.

The positive security model, or allowlist approach, blocks everything by default and only permits traffic matching an explicit definition of legitimate behavior. For example, a rule might state that the id parameter on a product page can only contain a one to six digit number.

This model offers stronger protection since it does not depend on recognizing attack signatures, but it is far more costly to build and maintain. It requires a precise, ongoing understanding of how each part of the application is supposed to behave, which makes it less common than the negative security model in practice.

Why it matters — It closes the gap left by signature based detection, since it does not rely on recognizing a known attack pattern to block a request.

Anomaly scoring

A detection method in which each matched rule adds points to a request's score, and the request is blocked only once the total score crosses a threshold.

Anomaly scoring means a WAF does not block a request the instant a single rule fires. Instead, every matching rule contributes points based on its assigned severity, and the cumulative score is compared against a threshold at the end of the evaluation.

In the OWASP Core Rule Set, severities map to fixed point values: CRITICAL rules add 5 points, ERROR rules add 4, WARNING rules add 3, and NOTICE rules add 2. With the CRS default threshold of 5, a single CRITICAL match, such as a confirmed SQL injection signature, is already enough on its own to block the request in prevention mode, per CRS documentation on anomaly scoring.

Example

A request matching one CRITICAL SQL injection rule (5 points) and one WARNING rule for a suspicious header (3 points) reaches a combined score of 8, which exceeds the default threshold of 5 and gets blocked.

Why it matters — It reduces false positives compared to blocking on the first rule match, since a single minor anomaly rarely reaches the blocking threshold on its own.

How it works

1

The client's request reaches the WAF first

In the most common deployment, the WAF sits between clients and the origin server as a reverse proxy. It receives every request in place of the backend, terminates the TLS connection, and only then decides whether to forward the request onward.

Client to WAF

Example — A browser sending a request to a public website actually connects to the WAF's IP address, not the origin server's.

2

The request is decoded and inspected

The WAF decodes the request, normalizing encodings such as URL encoding or Base64 so that obfuscated attack payloads cannot slip past detection simply by being encoded differently. It then inspects the URL, headers, cookies, and body parameters against its active ruleset.

Inspection

Example — A payload like %27%20OR%20%271%27=%271 is decoded back to ' OR '1'='1 before rule matching runs.

3

Matching rules add to an anomaly score

Each rule that matches the request adds points to a cumulative anomaly score based on its assigned severity. Under the OWASP Core Rule Set, CRITICAL matches add 5 points, ERROR adds 4, WARNING adds 3, and NOTICE adds 2.

Scoring

Example — One CRITICAL SQL injection match and one WARNING header anomaly together produce a score of 8.

4

The WAF decides whether to block or forward

Once inspection finishes, the WAF compares the cumulative score to a configured blocking threshold, 5 by default in the Core Rule Set. If the score meets or exceeds the threshold, the WAF blocks the request instead of forwarding it.

Decision

Example — A score of 8 against a threshold of 5 results in an HTTP 403 response instead of the backend's normal reply.

5

The WAF enforces its decision

If the request is blocked, the WAF can return an error code, redirect the client, present a challenge such as a CAPTCHA, or temporarily ban the source IP address, depending on configuration. If the request passes, the WAF relays it to the backend and returns the backend's response to the client.

Response

Example — A blocked SQL injection attempt returns HTTP 403 directly from the WAF, without the backend ever processing it.

Use cases

Protecting a public-facing CMS or website

IT admins hosting a public WordPress site or CMS

A WAF filters malicious requests targeting known CMS and plugin vulnerabilities, reducing the exposure window between a disclosed flaw and an applied patch.

A WAF rule set updated shortly after a critical vulnerability disclosure blocks exploitation attempts against unpatched instances, a practice known as virtual patching.

Benefit — Blocks common exploitation attempts targeting plugins and core CMS vulnerabilities before they reach the application.

Filtering traffic to a REST API

Developers and platform teams exposing REST APIs to mobile or third-party clients

Since APIs run over HTTP, a WAF filters malicious payloads in API requests the same way it does for a website, and some solutions add OpenAPI schema validation on top.

A REST API rejects malformed or attack laden JSON payloads at the WAF before they reach the application's business logic.

Benefit — Extends the same HTTP layer protection to API traffic, with optional schema validation for tighter control.

Virtual patching after a vulnerability disclosure

Security and IT teams responding to a newly disclosed vulnerability

When a vulnerability is disclosed in an application component, a WAF rule can block known exploitation attempts while the team prepares and tests an official fix.

Following disclosure of a critical vulnerability, WAF rule maintainers publish detection signatures that block exploitation attempts within hours, ahead of most organizations applying the official patch.

Benefit — Reduces the exposure window for a known vulnerability without requiring an emergency code change.

Limitations

False positives

Medium

A WAF can block legitimate requests that happen to resemble an attack pattern, such as a blog post whose URL contains security related keywords.

Workaround — Run the WAF in detection only mode first, review logs, and add targeted exclusion rules before switching to blocking mode.

Evasion techniques

Medium

Attackers use multiple layers of encoding, request fragmentation, or syntactic variation to disguise payloads and slip past signature based rules.

Workaround — Keep rulesets updated and combine signature detection with anomaly scoring or machine learning based approaches for defense in depth.

Business logic flaws

High

A WAF cannot detect flawed authorization logic, such as a user being able to view another customer's invoices through an otherwise well formed, legitimate looking request.

Workaround — Address these through secure application design, code review, and access control testing rather than WAF rules.

Ongoing maintenance

Low

Keeping a WAF effective requires ongoing effort: updating rules, reviewing logs, and adjusting exclusions as the protected application changes.

Workaround — Assign clear ownership for rule tuning and log review as part of standard security operations.

Architecture

Most WAFs run as a reverse proxy positioned in front of one or more backend web servers. The client's connection ends at the WAF, which means the WAF terminates TLS and can inspect the decrypted content of every request before deciding whether to forward it.

Other deployment modes exist, including a transparent bridge mode and an embedded module built directly into the web server, such as ModSecurity running as an Apache module. The reverse proxy model remains the most common approach, especially for cloud based WAF services.

Reverse proxy

Receives client requests on behalf of the web server, inspects them, then forwards or blocks them.

ModSecurity terminating TLS in front of an Nginx backend

Rule engine and ruleset

Applies detection logic to each request and assigns severity scores to matches.

The OWASP Core Rule Set running on the ModSecurity engine

Enforcement action

Decides what happens to a request once its anomaly score crosses the threshold.

A 403 response, a CAPTCHA challenge, or a temporary IP ban

Data flow

A client request first reaches the WAF instead of the origin server. The WAF terminates the TLS connection, decodes and normalizes the request, and checks its URL, headers, cookies, and body against the active ruleset.

Each matched rule adds points to the request's anomaly score based on its severity. If the cumulative score reaches the configured threshold, the WAF blocks the request and returns an error such as HTTP 403 instead of forwarding it to the backend. If the score stays below the threshold, the WAF relays the request to the origin server and returns its response to the client.

Integrations: Apache (native module), Nginx (via connector or embedded build), Caddy and Envoy-based proxies (Coraza), Traefik and HAProxy (Coraza plugins), SIEM platforms (via WAF logs)

Architecture limitations

A WAF only sees HTTP and HTTPS traffic. It cannot detect business logic flaws, and overly strict rules can block legitimate requests as false positives.

Examples

Deploying a minimal ModSecurity

Deploying a minimal ModSecurity and OWASP Core Rule Set lab with Docker to observe blocking behavior firsthand.

In a Docker Compose lab, a WAF container built on owasp/modsecurity-crs:nginx sits in front of a demo backend. Setting MODSEC_RULE_ENGINE to On enables blocking, while PARANOIA controls how many Core Rule Set rules are active, starting at level 1 for the fewest false positives.

A legitimate request to the WAF's exposed port returns an HTTP 200 from the backend. A request carrying a classic SQL injection payload in a URL parameter, such as ?id=1' OR '1'='1, instead returns an HTTP 403, and the backend never sees it.

OutcomeThe malicious request is blocked before it reaches the application, and the WAF logs record which rules matched and the resulting anomaly score.

Myths, corrected

Myth

A WAF makes an application fully secure against every type of attack.

Correction

A WAF blocks web layer attacks such as SQL injection and cross site scripting. It does not stop phishing, endpoint malware, business logic flaws, or attacks against other protocols. It is one control within a defense in depth strategy, not a replacement for secure development.

Why it happens: Vendors market WAFs as comprehensive protection, and the word firewall implies a broad security boundary similar to a network firewall.

Myth

Once a WAF is deployed, the underlying application no longer needs security patches.

Correction

Virtual patching through WAF rules can reduce exposure to a known vulnerability while a fix is pending, but it does not remove the vulnerability itself. The application still needs the official patch as soon as it becomes available.

Why it happens: Virtual patching is sometimes described informally as patching, which suggests the underlying flaw has been resolved rather than temporarily mitigated.

Myth

A WAF and a network firewall do the same job, so having one makes the other redundant.

Correction

A network firewall filters by IP address, port, and protocol at layers 3 and 4. A WAF inspects HTTP content at layer 7. Both play complementary roles in a layered security architecture, alongside an IDS or IPS.

Why it happens: Both tools share the word firewall, which suggests overlapping rather than complementary functions.

Practical implications

For admins

System administrators need to plan a detection only tuning period before enabling blocking, to avoid disrupting legitimate traffic with false positives.

For MSPs

MSPs managing multiple client web applications can standardize on a shared WAF ruleset such as the OWASP Core Rule Set, then apply per client exclusions as needed.

For business

A WAF can satisfy compliance requirements that explicitly call for web application protection, and reduces the business impact of publicly disclosed vulnerabilities through virtual patching.

For security

Security teams gain a source of visibility into who is attacking which applications, since WAF logs capture attack attempts that would otherwise go unnoticed at the network layer.

Cost impact

Open source engines such as ModSecurity, Coraza, and BunkerWeb remove licensing costs, though commercial and cloud based WAF services charge based on traffic volume or requests.

Operational impact

Ongoing operational work includes reviewing logs, tuning paranoia levels, and maintaining exclusion rules as the protected application evolves.

Decision guide

Use when

  • Hosting a public-facing website, CMS, or REST API
  • Needing virtual patching while waiting for an official fix to a disclosed vulnerability
  • Required to demonstrate web application protection for a compliance framework

Avoid when

  • The exposed service does not use HTTP or HTTPS
  • The primary risk is a business logic flaw rather than a technical injection or scripting attack
  • There is no capacity to monitor logs and tune rules after deployment

Requirements

  • An HTTP or HTTPS service to protect
  • A reverse proxy position in front of the backend, or a compatible web server module
  • Time to run a detection-only tuning phase before enabling blocking

Alternatives

  • Network firewall alone, for traffic with no HTTP-specific attack surface
  • Runtime application self-protection (RASP), for inspection from inside the application process
  • API gateway with schema validation, for tightly specified APIs
A WAF is worth deploying for any internet-facing web application, API, or CMS, provided the team can commit to an initial tuning period in detection mode and ongoing rule maintenance afterward.

Related terms

IDS/IPS

An intrusion detection or prevention system that analyzes network traffic across multiple protocols for attack signatures.

Virtual patching

The practice of deploying a WAF rule to block exploitation of a known vulnerability while an official code fix is pending.

Reverse proxy

A proxy that terminates client connections and forwards requests to one or more backend servers, commonly used as a WAF's deployment mode.

OWASP Core Rule Set (CRS)

An open source, community maintained ruleset for ModSecurity, Coraza, and compatible WAF engines covering major web attack categories.

Frequently asked questions

What is a WAF in cybersecurity?

A WAF (Web Application Firewall) is a security tool that inspects HTTP and HTTPS traffic between clients and a web application to detect and block malicious requests, such as SQL injection or cross site scripting attacks.

What is the difference between a WAF and a regular firewall?

A network firewall filters traffic based on IP addresses, ports, and protocols at layers 3 and 4 of the OSI model. A WAF inspects the actual content of HTTP requests at the application layer, layer 7, including the URL, headers, cookies, and parameters.

Does a WAF protect against every cyberattack?

No. A WAF blocks web attacks aimed at applications, but it does not protect against phishing, endpoint malware, business logic flaws, or attacks targeting other protocols. It is one layer within a defense in depth strategy, not a complete security solution on its own.

What is the OWASP Core Rule Set (CRS)?

The OWASP Core Rule Set (CRS) is an open source, community maintained set of generic detection rules compatible with several WAF engines, including ModSecurity and Coraza. It covers major web attack categories such as SQL injection, cross site scripting, file inclusion, and command injection.

What is virtual patching?

Virtual patching means deploying a WAF rule that blocks exploitation of a known, disclosed vulnerability while the official fix is still pending. It narrows the exposure window without requiring any change to the application's code.

What is a WAF false positive?

A false positive is a legitimate request that a WAF blocks by mistake because it resembles an attack pattern. A common example is a blog post whose URL happens to contain security related keywords. False positives are usually fixed with targeted exclusion rules.

Can a WAF protect a REST API?

Yes. REST APIs run over HTTP, so they benefit from the same WAF filtering as websites. Some WAF solutions add OpenAPI schema validation on top, so only requests conforming to the API's defined schema are accepted.

Conclusion

A WAF is a specialized security layer that inspects HTTP and HTTPS traffic at the application layer to block attacks such as SQL injection and cross site scripting. It complements, rather than replaces, network firewalls, secure coding practices, and patch management.

Open source engines like ModSecurity, Coraza, and BunkerWeb make it possible to deploy a working WAF without licensing costs, and a simple Docker lab is enough to see anomaly scoring and rule based blocking in action firsthand.

Main takeaway

A WAF inspects HTTP traffic in depth and blocks common web attacks, but it works alongside secure development and patching, not instead of them.

Once comfortable with the basics, explore paranoia level tuning, false positive exclusion rules, and centralizing WAF logs into a SIEM for ongoing monitoring.

Reader reviews

Rate this articleBe the first to rate
No written reviews yetRate the article above, or be the first to share your experience.

Related articles