WAF rules explained: what they match and what they miss

A rule looks for a pattern in a request and acts when it finds one. That is the entire mechanism, and both its usefulness and its limits follow from it: a rule catches what somebody knew to describe in advance, and it is blind in the same proportion to anything nobody thought to write down.

Section Rules Updated Reads with rate limiting

What a rule actually does

It examines a request and decides whether some part of it matches a description. The description might concern the address requested, the headers, the parameters, the body, or a combination.

What matters is that the decision is made on the request alone. A rule knows nothing about who is asking, what they asked for previously, whether they are signed in, or what your application does with the value once it arrives. It sees text and compares it against a description of text that somebody believed indicates trouble.

This is why rules pair naturally with rate limiting: one judges the content of a single request, the other judges the volume across many, and neither can do the other's work.

Where rule sets come from

Almost nobody writes a rule set from nothing, and understanding what you are inheriting matters more than the rules themselves.

Public rule sets are maintained by security communities and describe patterns associated with well-known classes of attack. They exist because those classes recur across every application, so the same descriptions are useful to everybody, and because keeping them current is more work than any one team should repeat.

The trade is visible from the start. A shared rule set knows nothing about your application, so it is written for the general case and errs toward catching things. What is normal traffic for your site may be exactly what somebody else's rule was written to stop, and neither party is wrong.

Why matches are scored rather than absolute

Treating every match as proof produces a system nobody can run, so mature rule sets do something more careful.

A single suspicious pattern is weak evidence. Text that resembles an injection attempt appears legitimately in search boxes, in support tickets, in code samples, and in any field where people write about software. Acting on one match would refuse all of that, constantly.

The alternative is to treat matches as contributions to a total, and to act only when enough of them accumulate on the same request. That converts a binary question into a threshold you can move, which is what makes a shared rule set usable on a real site without rewriting it. It also means the threshold, rather than the rules, is where most of your tuning happens.

A SUPPORT TICKET CONTAINING CODE TWO MATCHES SERVED A REQUEST THAT IS ACTUALLY AN ATTACK FOUR MATCHES REFUSED THRESHOLD // the threshold, rather than the rules, is where most of your tuning happens
// a single suspicious pattern is weak evidence

The two ways a rule set fails

Both are inevitable and they are not equally expensive, which decides how to set everything above.

It refuses something legitimate. A customer, a partner integration, or your own automation is stopped by a rule written about somebody else's threat. This failure is silent from your side: the person does not report it, they leave, and the log entry looks like a successful defence.

It misses something. An attack passes because nobody described that pattern, or because it was spread thin enough to stay below the threshold. This failure is visible eventually and can be responded to.

The asymmetry is the whole argument for caution. One failure mode you find out about and one you do not, which means an unwatched rule set drifts toward confident, invisible harm.

What rules cannot reach

Three categories, and no threshold setting brings them into range.

Authorisation. Whether this person may see this record is a question about your data and your permissions. The request asking for it is entirely well formed, and nothing in it distinguishes the legitimate reader from somebody who changed a number in the address.

Business logic. Ordering at a price that should not exist, or using a workflow in an order nobody anticipated, produces requests that are valid individually and wrong in sequence. A rule sees one request.

Design decisions. A missing check, an operation that can be replayed, a secret in a place it should not be. These are properties of the application, and a filtering layer in front of it cannot supply what was never built.

Knowing this is not an argument against rules. It is what stops a rule set being treated as a substitute for the work it cannot do.

ONE REQUEST EVERYTHING A RULE SEES OUT OF REACH — NO THRESHOLD BRINGS THEM IN AUTHORISATION NEEDS: WHO IS ASKING BUSINESS LOGIC NEEDS: THE SEQUENCE DESIGN DECISIONS NEEDS: THE APPLICATION ITSELF // a rule sees one request — that is the strength and the whole of the limit
// knowing this is what stops a rule set standing in for work it cannot do

Watch before you enforce

The same discipline the whole layer rests on, and it matters most here because rule matches are the hardest to predict.

Run a shared rule set in observation first, against your own real traffic, for long enough to include the unusual days. What you are looking for is not attacks; it is the requests your own site generates that happen to resemble somebody else's threat. Every one of those is a customer you would have refused, and you can only find them before enforcement, never after.

What this section covers

The pages below work through the reference material a rule set is built from: the widely used community list of application security risks and the positions on it a filtering layer can genuinely address, the maintained rule set built around those risks and how its scoring and severity settings behave in practice, and the equivalent list for interfaces used by other software rather than by people, which fails differently and is covered on API abuse.

Questions

What are WAF rules?

Descriptions of patterns in a request, together with what to do when one matches. The mechanism examines the request alone, so a rule knows nothing about who is asking or what your application will do with the value, which is both why it is fast and why it misses whole categories of problem.

Should I write my own rules or use a public set?

Start with a maintained public set, because the classes of attack it describes recur everywhere and keeping the descriptions current is continuous work. Write your own only for something specific to your application that no general set could know about.

Why does a rule set block legitimate traffic?

Because it was written for the general case and knows nothing about your site. Text that looks like an attack appears legitimately in search boxes, support tickets, and anything discussing software, so a set tuned for everybody refuses some of what is normal for you.

Do rules stop every attack?

No, and three categories are entirely out of reach: whether somebody is allowed to see what they asked for, whether a sequence of valid requests adds up to something wrong, and anything that follows from how the application was built rather than from what a request contains.

What is the difference between rules and rate limiting?

A rule judges the content of one request; a limit judges how many requests arrived. Neither substitutes for the other, and the failures they address barely overlap, which is why a filtering layer that offers only one of them leaves an obvious gap.

Where the platform sits

A rule set you have not watched against your own traffic is a set of guesses about which of your requests resemble somebody else's threat.

off

No rule is evaluated. Traffic reaches your origin as it otherwise would.

monitor

Rules run and matches are recorded. Nothing is refused while you read the record.

block

Matching requests are refused rather than forwarded, and still recorded.