Skip to content
AnswerWell geo Documentation

Research · 8 min read · Answerwell

Ruleset Engine Phases, Rule Execution Order, and WAF Actions

How Cloudflare request phases run in order, when Block and Skip stop evaluation, and how custom rules interact with WAF and Page Rules.

This page summarizes Cloudflare Ruleset Engine documentation on how rules, rulesets, and phases fit together, how incoming HTTP requests pass through those phases, and how actions such as block, managed_challenge, and skip change what runs next. It focuses on application-layer security and Rules products; network-only topics in the cluster (for example load-balancer or programmable flow protection scope) are out of scope unless they share the same ordering ideas.

The Ruleset Engine is the shared framework behind many Cloudflare products. Configuration uses the Rules language (syntax inspired by Wireshark display filters).

The Cloudflare Ruleset Engine allows you to create and deploy rules and rulesets. The engine syntax, inspired by the Wireshark Display Filter language, is defined by the Rules language. Cloudflare uses the Ruleset Engine in different products, allowing you to configure several products using the same basic syntax.

— Cloudflare, About

Three elements work together:

Element Role
Phase A fixed stage in the life of a request where rulesets run
Ruleset A versioned, ordered set of rules deployed to a phase
Rule A filter expression plus an action; execute can run another ruleset

A rule defines a filter and an action to perform on the incoming requests that match the filter.

— Cloudflare, Rules

Phases are defined by Cloudflare and cannot be renamed or reordered globally. The same phase name can hold rules at account level and zone level; for a given phase, account rules run before zone rules (Phases, WAF phases). Account-level phases require an Enterprise plan (Phases).

Request phases: what runs before the origin

Section titled “Request phases: what runs before the origin”

Application-layer request phases execute in the order listed in the Phases list. That order is not something you configure rule-by-rule; it is the pipeline every proxied request walks through.

Early request phases include redirects and transforms, then configuration and origin routing, then security and caching. The security-related slice (after HTTP DDoS configuration) is especially important when you wonder why a custom rule never sees traffic or why Managed Rules never run:

Phase Product / feature
ddos_l7 HTTP DDoS Attack Protection (configuration; rules not executed at this stage as listed)
http_request_firewall_custom WAF custom rules
http_ratelimit Rate limiting rules
http_request_firewall_managed WAF Managed Rules
http_request_sbfm Super Bot Fight Mode

Cloudflare documents the same ordering in Security features interoperability. Managed Rules run only after custom rules and rate limiting in their respective phases (Managed Rules).

Features not powered by the Ruleset Engine—IP Access Rules, Zone Lockdown, User Agent Blocking, Browser Integrity Check, Hotlink Protection, Security Level—are evaluated on their own and do not follow that phase list (Security features interoperability).

Among Rules products (Single Redirects, URL Rewrite Rules, Configuration Rules, Origin Rules, Bulk Redirects, and others), execution follows a fixed product order; those products take precedence over Page Rules when both match (Configuration Rules, Page Rules migration guide).

Page Rules use first matching rule wins for a URL pattern, with highest priority (top of the list) taking effect (Page Rules). Modern Rules are stackable within a phase: multiple matches can apply, and for non-terminating actions the last change in that phase often wins (Page Rules migration guide).

Terminating actions: when rule evaluation stops

Section titled “Terminating actions: when rule evaluation stops”

Some actions end further evaluation in the current ruleset or stop the request from reaching later phases.

Some actions like Block, called terminating actions, will stop the evaluation of the remaining rules. The Skip action will skip the evaluation of some rules when there is a match, but the exact behavior will depend on the rule configuration.

— Cloudflare, Supported actions

Within a ruleset, rules are evaluated in order; the first matching rule with a terminating action such as Block, Challenge, or Redirect stops further rules in that ruleset for that request (Rules and rulesets).

Cloudflare evaluates different types of rules when processing incoming requests. The first rule with a terminating action (such as Block, Managed Challenge, or Redirect) stops all further evaluation. For example, an IP Access rule that blocks a request prevents custom rules from running.

— Cloudflare, Rule execution order

For non-terminating actions in the same phase, later rules can overwrite earlier changes. For terminating actions, evaluation stops and the action runs immediately (Rule evaluation). Example: if several redirect rules match, the first matching redirect applies; if you use both Single Redirects and Bulk Redirects, the product that runs earlier in the phase pipeline wins when both match (Configuration Rules).

WAF custom rules: ordered list, no firewall “precedence”

Section titled “WAF custom rules: ordered list, no firewall “precedence””

WAF custom rules are expressions in the Rules language plus an action (block, managed_challenge, skip, log, and others depending on phase).

Custom rules are evaluated in order, and some actions like Block will stop the evaluation of other rules. This means that if an earlier rule blocks a request, later rules will not run for that request.

— Cloudflare, Custom rules

Deprecated Firewall Rules resolved conflicts between rules at the same priority using action precedence (for example Allow over Block). Custom rules do not use that model—order in the list is what matters (Firewall rules upgrade). The upgrade doc’s Block-then-Skip example shows that an earlier block wins even if a later rule would skip remaining rules.

Custom rules run before Super Bot Fight Mode; a terminating custom rule means bot settings in http_request_sbfm do not run for that request (Custom rules (bots), Super Bot Fight Mode).

Actions you are likely to configure on traffic

Section titled “Actions you are likely to configure on traffic”

Available actions depend on the phase and product (Supported actions). The table below highlights security-related actions people search for when hardening or debugging zones.

Action (API) Typical use Terminating?
managed_challenge Human/bot check chosen dynamically Yes
challenge Interactive challenge Yes
js_challenge Non-interactive challenge Yes
block Deny access (often 403; rate limit may use 429) Yes
skip Skip rules, rulesets, phases, or some non–Ruleset Engine products (options vary) No (but may skip other rules)
log Log match (Enterprise) No
execute Run another ruleset No

skip at account level only affects account-level rules/phases; to skip zone-level rules you need a zone-level skip rule (Supported actions). Zone-level custom rules can skip all remaining rules in http_request_firewall_custom with the phase option current (Available skip options).

Skip can bypass later security phases—for example rate limiting, Super Bot Fight Mode, or Managed Rules—when configured for those targets (Security features interoperability). Bot Fight Mode is outside the Ruleset Engine and cannot be skipped with custom rules; Super Bot Fight Mode or Bot Management is the path documented for finer control (Security features interoperability).

For testing before blocking, Enterprise customers can use log on custom rules (Supported actions); Use attack signatures in Security Rules describes comparing Log custom rules with Managed Rules blocks in Security Events.

Ordering rules for API, mobile, and browser traffic

Section titled “Ordering rules for API, mobile, and browser traffic”

When one hostname serves APIs, apps, and browsers, Cloudflare’s bot challenge example recommends API rules first, then mobile, then browser (Challenge bad bots), so terminatin g actions on API paths fire before broader browser rules.

Phase interactions that break “obvious” expressions

Section titled “Phase interactions that break “obvious” expressions”

A rule that looks correct in isolation may fail after another product changes the request.

Cloudflare applies URL Rewrite Rules before custom rules.

— Cloudflare, Rule phase interactions

A custom rule matching the visitor’s path may not fire after a rewrite; a rule on the rewritten path may fire even though the client asked for something else (Rule phase interactions). Within the http_request_transform phase, later rules still evaluate filters against original field values, not changes from earlier rules in that same phase (Field values during rule evaluation, URL Rewrite Rules). After that phase, http.request.uri.* reflects rewrites—which can break Origin Rules that still match on /downloads/ while the path was rewritten to / (Troubleshoot Rules). The documented fix is to use raw fields such as raw.http.request.uri.path, which stay unchanged for the whole workflow (Troubleshoot Rules).

An IP Access rule with Allow runs before WAF custom rules and prevents custom rules from evaluating that request (Rule phase interactions). Workers routes can disable some Page Rule behavior; modern Rules features are not suppressed the same way (Page Rules migration guide, Workers with Page Rules).

  • Assuming firewall-rule precedence on custom rules — reorder rules instead of relying on Allow-over-Block precedence (Firewall rules upgrade).
  • Expecting Managed Rules to run after a custom block — terminating actions in http_request_firewall_custom or http_ratelimit stop the request before http_request_firewall_managed (Managed Rules).
  • Matching paths without accounting for rewrites — use raw fields or match post-rewrite paths intentionally (Rule phase interactions).
  • Placing broad browser challenges above API allow/skip rules — put API-specific rules first (Challenge bad bots).
  • Trying to skip Bot Fight Mode with Skip — not supported; plan around Bot Fight Mode or use products that integrate with the Ruleset Engine (Security features interoperability).
  • Migrating Page Rules without retesting stackable cache behavior — Cache Rules may enable cache differently than Page Rules (Page Rules migration guide).
  1. In the Cloudflare dashboard, open Security rules (zone) or WAF custom rulesets (account) and confirm rule order matches your intent—earlier terminating rules win.

  2. Send a test request that should match a rule and open Security Events; custom rule events appear with Custom Rules as the source (Firewall rules upgrade).

  3. For path or rewrite issues, compare expressions using http.request.uri.path versus raw.http.request.uri.path against the behavior described in Rule phase interactions.

  4. Run Use Cloudflare Trace on a sample request and confirm which Ruleset Engine phases and Page Rules executed.

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about, and we will look into it.