Skip to main content
Security guideReviewed

Web application firewall (WAF): what it does, whether you need one, and how to change its rules safely

A web application firewall reads each request on its way to your website and blocks or records the ones that match its rules.

This guide answers whether one is worth having for your business, what it cannot do, how to change its rules without blocking real customers, and how to test that it behaves the way you think. The worksheet on this page turns that into a record your team can fill in.

WAF rule-change worksheet, staging tests and evidence template

Part A records each rule change: its purpose, the requests it should and must not affect, its starting mode, size limits, approver, rollback and what is watched afterwards. Part B is a set of staging test cases in four groups: false positives, variants of one harmless marker, content types and body size, and direct origin access.

How to use it

Part C is an evidence sheet for matching edge and application logs, and part D is an invented worked example of a small shop moving a rule set from log-only to blocking.

web-application-firewall.txt

Introduction3 lines

WAF RULE-CHANGE WORKSHEET, STAGING TEST CASES AND EVIDENCE TEMPLATE (VERSION 1) For a WAF and a staging site you own or are authorised in writing to test, within your WAF provider's and your host's testing terms. The test cases use one harmless marker string and your own ordinary requests. They contain no attack payloads and are not a method for testing anyone else's WAF. How to use it: fill in part A once for each change, pick the cases from part B that the change could affect, and keep one part C sheet for each test request you send. Part D shows a completed example.

What a web application firewall is

A web application firewall, or WAF, sits between your visitors and your website and reads each web request before your application does.

It checks the request against a set of rules, and a request that matches can be blocked, challenged or simply recorded, depending on how the rule is set. OWASP's own page puts it in one line: a WAF is an application firewall for HTTP applications that applies a set of rules to an HTTP conversation, and those rules generally cover common attacks such as cross-site scripting and SQL injection.

OWASP adds that a WAF is deployed to protect a specific web application or set of applications, can be considered a reverse proxy, and may come as an appliance, a server plugin or a filter.

For a business website those forms turn up in three places: a service in front of the whole site, such as Cloudflare or Amazon CloudFront with AWS WAF, the two hosted examples this page draws on; a load balancer or gateway your host runs; or an engine inside the web server or the application, such as ModSecurity or OWASP Coraza running the OWASP Core Rule Set (CRS).

The rules have two sources. Managed rule sets are written and kept up to date by someone else: Cloudflare says its managed rulesets are regularly updated, AWS describes managed rule groups as predefined rules that AWS and AWS Marketplace sellers write and maintain, and OWASP describes the goal of the Core Rule Set as a pluggable set of generic attack detection rules that give a base level of protection to any web application.

Custom rules are the ones your own team writes for your own site, such as refusing requests to an admin path from outside the office.

Four neighbouring topics have guides of their own in this library. Rate limiting, which some WAF products include as a rule type, decides how many requests a client may send. Security misconfiguration covers the settings around the WAF, such as debug output and default accounts.

Security logging and monitoring covers turning WAF and application events into alerts someone acts on. The Cloudflare guide covers that provider's WAF, bot and origin settings in detail.

This page stays with what a WAF is and is not, how to decide whether one is worth having, how to change its rules without breaking the site, and how to test it.

Do you need a web application firewall?

The short answer for a business owner: a WAF is worth having when your site accepts input that matters, such as logins, payments, file uploads or forms that reach a database, or when it runs plugins and components you cannot always update the day a fix ships, and when someone will read what the WAF records.

For a static brochure site with no logins and nothing to submit, keeping the platform, theme and plugins updated comes first, and a WAF can follow. Either way it is a layer in front of your application, not a repair inside it.

Four questions settle it for a particular site.

What does the site accept?

List every input a customer or partner can send: logins, checkout, uploads, search, contact and quote forms, and any API your front end or a partner calls. Those are what WAF rules inspect, and they are also where false positives will appear, so the same list feeds the test cases in the worksheet.

How quickly can you patch?

If a plugin, theme or framework update takes days to test and release, a managed rule set may give you something in front of the known flaw in the meantime. Cloudflare describes its managed ruleset as covering known attack techniques and zero-day vulnerabilities and as updated frequently to address new threats and reduce false positives.

AWS says many AWS and AWS Marketplace sellers update their managed rule groups automatically and provide new versions when new vulnerabilities and threats emerge. The update to your own code is still the fix.

Who will look after it?

A WAF needs an owner. OWASP notes that customising a WAF to an application can take significant effort and has to be maintained as the application changes, and the CRS documentation warns that, depending on the application and the paranoia level, writing rule exclusions can be a substantial amount of work.

If nobody will read the logs or deal with a blocked customer, start at the lowest sensitivity: the CRS project describes its paranoia level 1 as baseline security with a minimal need to tune away false positives, meant for everybody running an HTTP server on the internet.

Does a standard you are assessed against ask for one?

PCI DSS is one standard where this question comes up, and the Council's own description of the relevant control does not name a WAF. The PCI Security Standards Council's FAQ 1593, dated March 2025, describes PCI DSS v4.x requirement 6.4.2, effective as of 31 March 2025, as deploying an automated technical solution to detect and prevent web-based attacks for public-facing web applications.

It supersedes requirement 6.4.1, which allowed either a review of public-facing web applications with application vulnerability security assessment tools or methods, or such a solution. The FAQ refers readers to the standard for the exact wording.

Whether your set-up meets it is a question for whoever assesses you against the standard. Qualified Security Assessor companies are qualified by the Council to validate an entity's adherence to PCI DSS. Clever Ops is not a Qualified Security Assessor or an Approved Scanning Vendor, so that question goes to an assessor.

What a WAF does not do

A dashboard full of blocked requests is reassuring, which is exactly why the limits are worth knowing before you rely on one.

It does not fix the flaw behind it

A rule that blocks a known attack pattern leaves the vulnerable code where it was. MITRE's entry for SQL injection, CWE-89, rates an application firewall as a mitigation of moderate effectiveness and notes that it might not cover all possible input vectors and that attack techniques might be available to bypass it.

OWASP's Top 10:2025 says the best way to prevent injection is to keep data separate from commands and queries. A WAF rule added because of a specific finding is interim, and should be recorded that way.

It cannot see who should be allowed to do what

A request for another customer's invoice can look exactly like a request for your own: the same path, the same format, a different number. Nothing in it resembles an attack, so a rule that reads requests for attack patterns has nothing to match.

The CRS documentation says a fresh deployment has no awareness of the web services running behind it, and OWASP's Top 10:2025 says access control is only effective when it is implemented in trusted server-side code or serverless APIs, where the attacker cannot modify the access control check or metadata.

Broken access control, and business logic flaws such as a checkout step that can be skipped, are found by testing the application signed in as each role.

It only guards the route it stands on

If the server behind the WAF answers requests sent straight to its own address, anyone who finds that address can leave the WAF out of the path entirely. Cloudflare's guidance on protecting an origin server and AWS's guidance on restricting a load balancer to CloudFront both exist to close that route, and the origin server protection section below sets out what they document.

It reads only part of a large request

Inspection stops at documented limits. AWS WAF inspects the first 8 KB of a request body behind an Application Load Balancer and, by default, the first 16 KB behind CloudFront, which can be raised in steps to 64 KB; when it lets a request through, the whole request goes on to your server, including the part it could not inspect.

Cloudflare says its managed rules inspect the body up to a maximum size that varies by plan and that content beyond the limit may not be fully analysed.

ModSecurity rejects a body over its configured limit by default, but in detection-only mode it inspects the part that fits and lets the rest through. Know your product's limit and what it does with a request that goes over it.

It does not watch itself

A WAF writes events; somebody has to decide what they mean. OWASP's Top 10:2025 lists application and API logs that are not monitored for suspicious activity, and penetration tests and DAST scans that do not trigger alerts, among security logging and alerting failures. The security logging and monitoring guide covers alerting. This page covers the WAF's half of the evidence.

Web application firewall rules: how they decide

Four settings shape what a WAF does with a request: which rules run, how sensitive they are, what happens on a match, and what text a rule compares.

Managed rule sets change underneath you

A provider's update is a rule change you did not write. 1 min read

Scoring: when one match is enough

The Core Rule Set does not block on the first rule that matches. 1 min read

Sensitivity: paranoia levels and their equivalents

Sensitivity is set separately, and the CRS documentation is careful to keep the two apart: the paranoia level controls how many rules run, while the threshold controls how many can match before a block. 1 min read

What a match does: log first, then block

Each product on this page has a way to record a match without acting on it, and that is where a change should start. 1 min read

Transformations: what text a rule actually compares

A rule compares text, so it matters which version of the text it sees. 1 min read

WAF false positives and how to tune them away

A false positive is a genuine request that a rule matches in error.

The CRS documentation explains why they happen: a generic rule set knows nothing about the application behind it, so ordinary traffic that resembles an attack pattern gets flagged. Its own example is a WordPress post containing an HTML heading, which a cross-site scripting rule at paranoia level 2 matches because of the tags, even though WordPress has its own rules for which tags are allowed.

On a business site, start with the requests your own staff, customers and partners send that do not look like ordinary form fields: product descriptions and posts from a rich-text editor, code samples pasted into support forms, very long free-text fields, file uploads, JSON from your own front end, callbacks from payment and shipping providers, and names and addresses with apostrophes, ampersands and slashes.

The CRS documentation gives three reasons to fix them rather than live with them. When a system is prone to false alarms, its alerts may be ignored and real attacks overlooked. A false-positive alert can copy sensitive data into a log, such as a password that happens to contain a string a rule looks for. And when real customers are blocked, the pressure builds to switch the WAF off altogether.

Write the narrowest exception that works

Tuning means adding an exception, not editing the rule. The CRS documentation strongly discourages changing rule files directly, because the next rule set update undoes the change, and it describes exceptions at several widths. Its examples use the wide ones only where the application does not use what the rules protect, and the narrow one where removing the rule entirely is unacceptable.

  • Widest:remove a whole category of rules, such as every SQL injection rule. The CRS example does this only where no web service behind the WAF uses SQL.
  • Wide:remove one rule everywhere, as in the CRS example of a PHP rule in front of an application that uses no PHP.
  • Narrower:remove one rule, or one category, for one path only.
  • Narrowest:exclude one field from one rule on one path, so the rule keeps checking every other field and page.

Record it so it can be reviewed

Products name exceptions differently. Cloudflare's exceptions skip managed rules for requests that match an expression, and only skip the managed rulesets listed after them, so their position in the list matters. AWS documents overriding a managed rule's action to count.

Whatever the name, record the rule ID, the field, the path and the reason, so the exception is reviewed when the form changes or the rule set is updated. Part D of the worksheet shows one written up in full.

Changing WAF rules without breaking the site

Every change should follow the same path, whether it is turning on a managed rule set, raising its sensitivity, adding a custom rule, adding an exception, moving from log-only to blocking or accepting a provider's new version.

The worksheet on this page is that path written down.

  • Say what the change is for and which requests it should touch. A rule meant to protect the login form should name the login path; one that also catches checkout is a different change.
  • Name the approver. Someone who can judge the cost of a blocked order or enquiry signs off, as well as the person who wrote the rule.
  • Start in a recording mode where the product offers one, and on staging before production.
  • Run the staging cases, starting with your own ordinary requests, then watch production in recording mode and read every match. A match on a request you recognise as normal is a false positive to tune. A match on something you do not recognise needs a closer look before you decide.
  • Switch to blocking, then confirm the change is in effect everywhere before judging it. AWS notes that changes take time to propagate, and that during propagation a changed rule action can show the old action in some places and the new one in others.
  • Watch the same signals afterwards: blocks by rule and path, customers or staff reporting forms that fail, and the application's own error and order counts.
  • Keep the rollback written down: the exact setting, who can change it outside business hours, and how you will know it took effect.

Raising sensitivity on a site that already works

Raising the paranoia level of a working Core Rule Set installation is very likely to bring new false positives, by the CRS documentation's own account. It calls the shortcut of raising the anomaly threshold for a while simple but risky, because it lets through attacks that were blocked before.

Its alternative is an executing paranoia level set above the blocking one: the higher level's rules run and log but never count towards the blocking score, the new false positives are tuned away, and then the blocking level is raised to match.

Where a product does not expose this setting, the nearest equivalent is to add the stricter rules in its log-only mode first, if it has one.

WAF testing: checking it does what you think

A WAF test asks two questions: does the rule stop what it is meant to stop, and does it leave your customers alone?

Both are answered on a staging copy behind the same WAF configuration as production, using requests you control. Test only a WAF and a site you own or are authorised in writing to test, and read your WAF provider's and host's testing terms first. Nothing on this page is a method for getting past someone else's WAF.

For false positives, the test cases are your own traffic: a real product description with headings and links, a support message with a code sample, the longest form field the site allows, each type of upload, and the JSON your front end and partners send. Each one should pass the edge and reach the application unchanged.

For coverage, use a harmless marker instead of attack strings. On staging, add a temporary custom rule that blocks one made-up string no real request contains, such as wafcheck-7c41, then send that marker in different forms and places. Each request either reaches the rule or slips past it, and the pattern tells you what your WAF inspects and how it reads what it inspects, without sending anything that could harm the application. Remove the rule when you finish.

  • Encodings of the same marker: plain, in mixed case, URL-encoded, and URL-encoded twice. Whether each is caught depends on the transformations the rule applies, and the result to look for is agreement with how your application decodes the same value.
  • Body formats and content types: the marker as a query parameter, a form field, a JSON value, a multipart field and an uploaded file name, then the same JSON sent with a content type that does not match it. The CRS documentation says ModSecurity and Coraza rely on the Content-Type to parse a request body, and warns that allowing an extra content type without the matching body parser may result in a complete bypass of the WAF. AWS documents that when JSON parsing fails, its default is to evaluate the body only up to the parsing error.
  • Placement: the marker in a header, a cookie and a path segment instead of a parameter. AWS WAF reads at most the first 8 KB and first 200 headers when a rule inspects all headers, and a single named header in full, and each AWS rule statement inspects one part of the request, so covering several parts takes several statements.
  • Size: the marker placed after enough harmless padding to push the body past your product's documented inspection limit. The right result depends on your oversize setting. AWS WAF can continue with what fits, treat the request as a match, or treat it as no match, and outside its console the default is to continue. Cloudflare provides a field, http.request.body.truncated, that custom rules can use to act on bodies that were not fully inspected, where the plan includes body fields.
  • Direct origin access: the same marker sent to the origin server's own address, skipping the edge. The expected result is a refusal before the application handles it.

Keep the tests and run them again

Save the cases and rerun them after every rule change and every provider update. OWASP's Top 10:2025 recommends an automated process to verify the effectiveness of configurations in all environments, and a staging run of these cases is a practical version of that for a WAF.

Check, too, that the test requests appear where your team will see them: OWASP lists penetration tests and DAST scans that trigger no alerts among its logging and alerting failures.

Origin server protection: make the WAF the only way in

A WAF at the edge only sees requests that come through the edge.

If the origin, the server behind it, accepts connections from anywhere, the WAF is a front door beside an open side gate. Cloudflare and AWS both document how to close the gate, and their approaches fall into three groups.

Keep the address out of view

Cloudflare advises proxying DNS records so the origin's address is not published, checking DNS-only records such as SPF and TXT for origin addresses, not hosting mail on the same server where possible because bounced mail reveals its address, and rotating origin addresses after moving behind Cloudflare because historical DNS records are kept.

Hiding an address helps, but an address that has leaked once stays known, so treat this as the first step rather than the control.

Remove the public address

Cloudflare Tunnel connects the origin to Cloudflare through outbound-only connections, with no publicly routable address. AWS documents CloudFront VPC origins, which serve content from applications in private subnets without exposing them to the public internet.

Accept only requests that prove they came through the edge

AWS documents CloudFront adding a secret custom header to origin requests, with the load balancer forwarding only requests that carry it and answering everything else with a fixed 403. It says the approach only works while the header name and value stay secret, recommends HTTPS to the origin and rotating the header, and documents an optional AWS-managed prefix list that lets the load balancer's security group refuse traffic that does not come from CloudFront.

Cloudflare documents the same header approach, rated moderately secure, and allow-listing its IP ranges, also rated moderately secure and noted as vulnerable to IP spoofing.

Its Authenticated Origin Pulls has the origin check a client certificate; Cloudflare notes that its own certificate only shows a request came from the Cloudflare network, and says to upload your own certificate for stricter checking.

Whichever route you take, test it from outside: request the origin directly, with and without the expected header or certificate, on every port and hostname it answers, and expect a refusal each time. Group B4 of the worksheet lists those requests. The Cloudflare guide covers that provider's settings step by step.

Matching WAF events to application logs

A WAF log cannot say on its own what happened next.

Did a blocked request still reach the application by another route? Did a request that matched a counting rule fail inside the application? To answer either, you need one identifier present on both sides.

  • Cloudflare sends a Cf-Ray header, its Ray ID, to the origin, and says to add it to origin server logs so requests through Cloudflare can be matched to requests in your server logs. It notes that with Argo Smart Routing or Argo Tiered Caching, the three-letter location code in the header sent to the origin names the data centre connecting to the origin rather than the one that first received the request.
  • CloudFront adds an X-Amz-Cf-Id header to each request it forwards to a custom origin, containing an encrypted string that uniquely identifies the request. AWS WAF logs a requestId generated by the AWS service it is attached to, which for an Application Load Balancer is the trace ID. Confirm on staging which identifier lines up with which before you depend on it.
  • On a server running ModSecurity, the example log line in the CRS documentation carries a unique_id value beside the rule ID, the matched data and the requested URI. If your own proxy sets a request ID header, log it at the WAF and in the application, and the two records join on that value.

What each side should record

OWASP ASVS 5.0 requirement 16.2.1, at Level 2, asks that each log entry includes the necessary metadata, such as when, where, who and what, that would allow a detailed investigation of the timeline. For WAF evidence, that means the time, the shared identifier, the method and path, the rule ID and action at the edge, and the status code and outcome in the application. Part C of the worksheet is laid out that way.

Read the edge side with its quirks in mind. Cloudflare's Security Events view shows security events, not requests, so one request can appear as several events, and its sampled logs may leave some events out when traffic is heavy. AWS WAF logs the rule that terminated the request, or Default_Action when none did, lists non-terminating matches such as count rules separately, and lists any inspected field that was over its size limit.

AWS adds that inspection stops at the first terminating match, so a request may contain other threats beyond the one logged.

Redact before you share

The CRS documentation warns that a false-positive alert can write sensitive data such as a password into the log, and ASVS 5.0 requirement 16.2.5 says some data, such as credentials or payment details, may not be allowed to be logged at all. Strip passwords, card details, session tokens and personal details from evidence sheets before they go into a ticket or an email.

Where an outside test fits

A WAF and a security test answer different questions.

The WAF filters requests at the edge; a test shows what the application does with the requests that get through. Clever Ops tests what customers reach through a browser or an API: websites, WordPress sites and WooCommerce stores, custom web applications and their APIs, apps made with AI builders, and AI chatbots and agents.

Its services do not include managed IT, round-the-clock monitoring or incident response, so watching WAF alerts stays with your team, your host or your provider.

A WAF shapes how a test is scoped. The scope records whether the WAF lets the tester's addresses through and in which environment: letting them through on staging tests the application itself, while leaving the WAF in place on production tests what an attacker meets, and the choice is written down because it changes what the report can say.

Requests stay under an agreed rate, and testing on a target pauses if a firewall starts blocking. If you switch on a WAF rule as an interim measure after a finding, it belongs in the fix note, and the retest runs under the original conditions so the result describes the application; if the rule is the remedy you have chosen, the outcome names it as the control that was tested.

For a site without customer logins, a website security audit is the external starting point: it reviews what anyone on the internet can examine without logging in, and the report states what an outside view cannot reach. If Clever Ops built or hosts your site, the work is a security review rather than an independent test, and the report says who built it and who hosts it.

Frequently asked questions

It reads each web request before your application does, compares it with a set of rules, and blocks, challenges or records the requests that match. OWASP describes those rules as generally covering common attacks such as cross-site scripting and SQL injection. It does not change your application's code, so a flaw a rule is covering is still there behind it.

No. A network firewall controls which connections can reach a server. A WAF works on the web requests inside the connections that are let through, which is where form fields, headers, cookies and JSON bodies are. OWASP describes it as an application firewall for HTTP applications. One does not replace the other.

The PCI Security Standards Council's FAQ 1593 describes PCI DSS v4.x requirement 6.4.2, effective as of 31 March 2025, as deploying an automated technical solution to detect and prevent web-based attacks for public-facing web applications, and refers readers to the standard for the exact wording. It does not name a product. A Qualified Security Assessor can say what meets it in your environment. Clever Ops is not a Qualified Security Assessor or an Approved Scanning Vendor.

A legitimate request that a rule matches as if it were an attack, such as a product description with HTML headings matching a cross-site scripting rule. Where the rule is still needed elsewhere, the Core Rule Set documentation's examples use a narrow exception: exclude the one field from the one rule on the one path, so the rule keeps checking everything else.

Start where you can see matches before customers feel them. AWS recommends testing on staging, then running rules in count mode on production traffic before enabling them, and Cloudflare recommends its Log action, where the plan includes it, for validating rules before a more severe action. The Core Rule Set documentation describes another common practice, blocking from the start with a very high threshold that is lowered step by step. Whichever you choose, read every match before you tighten it.

There are documented gaps a defender should test for. If the origin server answers requests that do not come through the WAF, the WAF can be left out entirely. Inspection stops at documented size limits. MITRE's CWE-89 notes that an application firewall might not cover all input vectors and that techniques might be available to bypass it. This page shows how to check your own WAF for those gaps on staging; it is not a guide to getting past anyone else's.

Ask four questions. Does it read web requests, or only filter connections? Which rules run, and who updates them? Is it blocking, or only recording? Can the server behind it be reached without going through it? The answers tell you what it covers, and the worksheet on this page gives you a way to check each one on staging.

It can, if it starts blocking the tester partway through, and testing on that target then pauses. Agree it in the scope instead: whether the WAF lets the tester's addresses through, and in which environment. Let through on staging, the test describes the application; left in place on production, it describes what an attacker meets.

Scope the right test for your application

Tell us what you have built, who uses it and when it needs to launch. You will get a plain-English recommendation: a website audit, a web application test or a referral to a specialist.