skip to content

In Cloudflare's WAF managed rulesets, how does an override differ from an exception (a skip rule), and which wins when both apply?

level: middleimportance: should knowfreq 40%

answer

  1. change the rule versus skip it
  2. ruleset, tag and rule levels
  3. future rules inherit some overrides
  4. skip rules act only on later rules

basics

~20 s

An override changes how managed rules behave for every request the deployment covers: their action or whether they are enabled. An exception is a separate skip rule that bypasses chosen rules or rulesets only for matching requests. Exceptions take priority over overrides.

solid answer

~40 s

An **override** lives in the `overrides` of the Execute rule that deploys a managed ruleset. It can apply at three levels. A ruleset override covers every rule, a tag override covers rules with a tag, and a rule override targets rule IDs; the more specific level wins. It changes `action` or `enabled` for every request in the deployment's scope. Ruleset and tag overrides also apply to rules Cloudflare adds later. An **exception** is its own rule with the `skip` action in the `http_request_firewall_managed` entry point ruleset. Its expression says which requests it covers, and it skips all remaining rules, whole rulesets or specific rule IDs. It only affects Execute rules listed after it, so it must come first. When both apply, the exception wins.

code

json · 13 lines
json
{
  "description": "Skip one Cloudflare Managed Ruleset rule for product saves",
  "expression": "(http.host eq \"api.example.com\" and starts_with(http.request.uri.path, \"/api/admin/products\") and http.request.method in {\"POST\" \"PUT\"})",
  "action": "skip",
  "action_parameters": {
    "rules": {
      "efb7b8c949ac4650a09736fc376e9aee": ["<RULE_ID>"]
    }
  },
  "position": {
    "before": "<EXECUTE_RULE_ID>"
  }
}

go deeper

for a junior

Remember the split: an override changes a rule for the whole deployment, an exception skips rules only for requests its expression matches.

for a middle

Explain the three override levels and their precedence, the three exception types, and why a skip rule must sit before the Execute rule.

for a senior

Show you fix a one-endpoint false positive with a narrow exception, never a zone-wide override, and that you know ruleset and tag overrides reach future rules.

for a principal

Set the team rule for when an override is acceptable versus an exception, and how temporary overrides get a removal date.

## Two tuning tools with different shapes A Cloudflare managed ruleset arrives with Cloudflare's defaults: an action per rule, and some rules turned off. You change that behaviour in two ways, and choosing the wrong one is how a narrow false-positive fix turns into a zone-wide hole. - An **override** edits the ruleset's behaviour *for the whole deployment*. - An **exception** (also called a **skip rule**) leaves the ruleset alone and *bypasses part of it for some requests*. ## Overrides: changing what the rules do An override sits in the `action_parameters.overrides` of the Execute rule that deploys the managed ruleset. In the dashboard you reach the same settings by opening that deployment on the **Security rules** page. There are three levels: 1. **Ruleset override**: applies to every rule, for example setting `action` to `log` while you evaluate the ruleset. 2. **Tag override** (`categories` in the API): applies to rules with a tag, for example enabling every rule tagged for your CMS. If a rule has several overridden tags, the last tag's override applies. 3. **Rule override** (`rules`): applies to rule IDs, for example disabling one rule that misfires. The general properties are `action` and `enabled`. Some rulesets accept more; the OWASP Core Ruleset's last rule takes `score_threshold`. More specific levels win: rule over tag, tag over ruleset. Two consequences matter in production: - **Ruleset and tag overrides apply to future rules too**, including rules Cloudflare ships in an emergency release. Only rule overrides are pinned to the rules that exist today. - An override has no request condition of its own. It applies wherever the Execute rule runs. Disabling a rule by override disables it for every path in the deployment's scope. ## Exceptions: skipping rules for matching requests An exception is a separate rule with the `skip` action in the same `http_request_firewall_managed` entry point ruleset. Its expression picks the requests. Its `action_parameters` pick what is skipped, listed here from highest to lowest priority: | Exception type | API form | Effect | | --- | --- | --- | | Skip all remaining rules | `"ruleset": "current"` | Every later rule in this entry point ruleset is skipped | | Skip managed rulesets | `"rulesets": [ids]` | Whole rulesets are skipped | | Skip specific rules | `"rules": {rulesetId: [ruleIds]}` | Only those rules are skipped; the rest of the ruleset still runs | Rules to know: - **Order is everything.** A skip rule only affects Execute rules listed *after* it. An exception added at the end of the list skips nothing, so place it with the `position` object (for example `before` the Execute rule's ID). - **Context is separate.** A zone-level exception skips only zone-level rules, and an account-level one skips only account-level rules. Account-level rulesets run first in each phase. - When several exceptions match one request, the highest-priority type applies. - In the dashboard, **Log matching requests** stays on unless you turn it off, so skipped requests remain visible in Security Events. A WAF custom rule with the *Skip* action can also skip the managed rules phase, but it does so in the custom rules phase and in coarser units. Managed-rule exceptions are the tool for skipping one rule on one path. Writing the expressions themselves is covered in the lesson on custom rules and the Rules language. ## Which wins **Exceptions have priority over overrides.** If one rule is overridden to Block and an exception skips it for `/api/admin/products`, requests to that path skip it, and every other path still blocks. There is also a difference in how much work is done. An exception that skips all remaining rules means those rules' expressions are not evaluated at all. An exception that skips one rule still runs the rest of the managed ruleset and bypasses only that rule. ## Choosing between them - A rule that is wrong for your whole application (it targets a stack you do not run, or it fires on normal traffic everywhere): use a **rule override** to disable it or change its action. - A rule that is right in general but wrong for one endpoint or field: use an **exception** scoped to that host, path and method, and keep the rule everywhere else. - A temporary rollout setting such as Log on every rule: use a **ruleset override**, and give it a removal date, because it will also catch rules added next month.

  • Why can an override that sets every Cloudflare Managed Ruleset rule to Block still leave rules unused?
    An override that only sets `action` changes the action of enabled rules. Rules that Cloudflare ships disabled stay disabled until an override also sets `enabled` to true. That is deliberate, because those rules carry a higher false-positive risk, and the docs advise against enabling them all outside a proof of concept.
  • An account-level deployment of the Cloudflare Managed Ruleset still blocks a path that a zone-level exception skips; why?
    Exceptions apply only in their own context. A zone-level skip rule bypasses zone-level Execute rules, and the account-level ruleset runs first in the phase and is untouched by it. The exception has to be added at the account level (an Enterprise feature) with the account rule's required `cf.zone.plan eq "ENT"` condition.

  • An exception at the end of the list still applies to every rule.
  • Overrides only affect the managed rules that exist today.
  • An override can be limited to one URL path by itself.
  • When an override and an exception conflict, the override wins.
  • A zone-level exception also skips account-level managed rules.