Skip to content

Commit 9ac4e48

Browse files
[Various] Bots/Rules discoverability (#28931)
* bots / rules clarification * edits * edits * title * pm feedback * pcx feedback
1 parent 8e95d51 commit 9ac4e48

12 files changed

Lines changed: 185 additions & 17 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
---
2+
title: Custom rules
3+
pcx_content_type: concept
4+
sidebar:
5+
order: 7
6+
description: >-
7+
Understand when to use the built-in bot protection settings in Security
8+
Settings versus creating WAF custom rules for bot management.
9+
---
10+
11+
import { Render } from "~/components";
12+
13+
Bot protection on Cloudflare works through two complementary mechanisms: built-in settings configured through toggles in **Security Settings**, and [WAF custom rules](/waf/custom-rules/) that you write using [bot management fields](/bots/reference/bot-management-variables/). Understanding when to use each approach helps you avoid creating duplicate rules and simplifies your security configuration.
14+
15+
The following features are configured through toggles and dropdowns in [Security Settings](/security/settings/). They do not require you to write any rule expressions.
16+
17+
| Feature | What it does | Availability |
18+
| --- | --- | --- |
19+
| [Block AI bots](/bots/additional-configurations/block-ai-bots/) | Blocks AI crawlers (GPTBot, ClaudeBot, Bytespider, and others) using an auto-updating managed rule | All plans |
20+
| [AI Labyrinth](/bots/additional-configurations/ai-labyrinth/) | Feeds non-compliant AI crawlers into a maze of generated content | All plans |
21+
| [Managed robots.txt](/bots/additional-configurations/managed-robots-txt/) | Prepends AI crawler disallow directives to your `robots.txt` | All plans |
22+
| Super Bot Fight Mode > **Definitely automated** | Blocks or challenges traffic with a [bot score](/bots/concepts/bot-score/) of 1 | Pro, Business, Enterprise |
23+
| Super Bot Fight Mode > **Likely automated** | Blocks or challenges traffic with a bot score of 2-29 | Business, Enterprise |
24+
| [Verified bots](/bots/concepts/bot/verified-bots/) | Managed category of high-trust bots (Googlebot, Bingbot, and others) | Pro, Business, Enterprise |
25+
| [Static resource protection](/bots/additional-configurations/static-resources/) | Extends bot actions to cover static file types | Pro, Business, Enterprise |
26+
| [Optimize for WordPress](/bots/troubleshooting/wordpress-loopback-issue/) | Allows WordPress loopback requests through bot protection | Pro, Business, Enterprise |
27+
| [JavaScript detections](/cloudflare-challenges/challenge-types/javascript-detections/) | Injects a lightweight script to identify clients that cannot execute JavaScript | All plans (automatic on Free) |
28+
29+
Bot settings update automatically as Cloudflare identifies new bot signatures and AI crawlers, while custom rules require manual updates. They do not count toward your [custom rule limits](/waf/custom-rules/#availability), and apply uniformly across your domain without the risk of expression errors.
30+
31+
## Custom rules use cases
32+
33+
Custom rules are valuable when you need capabilities that built-in settings do not offer. The following scenarios require [WAF custom rules](/waf/custom-rules/) with [bot management fields](/bots/reference/bot-management-variables/). Bot management fields are available to customers with a [Bot Management](/bots/get-started/bot-management/) subscription.
34+
35+
### Path-specific protection
36+
37+
Since Bot settings apply to all traffic across your domain, you may need an alternative approach to bot handling for different paths using custom rules — for example, stricter protection on `/login/` than on `/public/`.
38+
39+
#### Example
40+
41+
Block likely automated traffic only on your login endpoint:
42+
43+
```txt
44+
(cf.bot_management.score lt 30 and not cf.bot_management.verified_bot and http.request.uri.path eq "/login")
45+
```
46+
47+
### Custom score thresholds
48+
49+
The **Definitely automated** and **Likely automated** settings in Super Bot Fight Mode use fixed bot score groupings (1 and 2-29). If you need a different threshold, for example, challenging all traffic with a score below 20, you need a custom rule.
50+
51+
### Conditional logic
52+
53+
If you need to combine bot score with other request fields, such as country, ASN, URI path, JA3/JA4 fingerprint, or user agent, you need custom rules. Bot settings do not support compound conditions.
54+
55+
#### Example
56+
57+
Challenge likely automated traffic only from specific ASNs:
58+
59+
```txt
60+
(cf.bot_management.score lt 30 and not cf.bot_management.verified_bot and ip.src.asnum in {64496 65536})
61+
```
62+
63+
### Custom actions
64+
65+
Bot settings offer **Block**, **Managed Challenge**, and **Allow** as actions.
66+
67+
If you need other actions, such as **Log** (for testing rules before enforcement), **Interactive Challenge**, or **Skip** (to bypass other rules), you need custom rules.
68+
69+
### Detection ID targeting
70+
71+
To act on specific bot heuristic detections, such as [account takeover](/bots/additional-configurations/detection-ids/account-takeover-detections/) or [scraping](/bots/additional-configurations/detection-ids/scraping-detections/) patterns, you need custom rules using the `cf.bot_management.detection_ids` field. Bot settings do not expose individual detection IDs.
72+
73+
### Forwarding bot data to origin
74+
75+
To send bot scores, verified bot status, or JA3/JA4 fingerprints to your origin server, use [Transform Rules](/rules/transform/) (including [Managed Transforms](/rules/transform/managed-transforms/)) or [Snippets](/rules/snippets/). These are not part of the built-in bot settings.
76+
77+
## Execution order
78+
79+
Custom rules execute before Super Bot Fight Mode managed rules. If a custom rule takes a terminating action (such as **Block** or **Managed Challenge**), the request does not reach bot settings.
80+
81+
Refer to [Security features interoperability](/waf/feature-interoperability/) for more information.

src/content/docs/bots/additional-configurations/managed-robots-txt.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pcx_content_type: reference
33
title: robots.txt setting
44
sidebar:
5-
order: 7
5+
order: 8
66
label: robots.txt setting
77
---
88

src/content/docs/bots/additional-configurations/static-resources.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
pcx_content_type: reference
33
title: Static resource protection
44
sidebar:
5-
order: 8
5+
order: 9
66
---
77

88
import {

src/content/docs/bots/concepts/bot/index.mdx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,7 @@ This behavior remains the same if the setting for verified, definitely automated
6666

6767
For self-serve non-Bot Management customers, all rules for verified, definitely automated, and likely bots run in the phase following the AI bots rule.
6868

69-
```mermaid
70-
flowchart LR
71-
accTitle: AI bots rule phases diagram
72-
accDescr: This diagram details the phases in which AI bots rules run.
73-
A[Custom rules] --> B[Block AI bots<br>managed rule] --> C[Allow verified bots rule]
74-
```
69+
<Render file="execution-order" product="bots" />
7570

7671
This feature is available on all Cloudflare plans.
7772

src/content/docs/bots/get-started/bot-management.mdx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,15 @@ Refer to [Block AI bots](/bots/additional-configurations/block-ai-bots/).
7777
You can view blocked AI bot traffic via [Security Analytics](/waf/analytics/security-analytics/).
7878
:::
7979

80-
### Deploy default templates
80+
### Deploy custom rule templates
8181

82-
Cloudflare has [default templates](https://dash.cloudflare.com/?to=/:account/:zone/security/security-rules?template=bot_traffic) for definite bots, which have a [bot score](/bots/concepts/bot-score/) of 1, and likely bots which have a bot score of 2 to 29. In our templates, Cloudflare recommends to allow verified bots such as Google SEO Crawler and access to cached static resources.
82+
The **Security Settings** toggles you configured above already provide baseline protection against definitely automated and likely automated traffic.
83+
84+
If you need additional control, such as path-specific protection, custom score thresholds, or combining bot score with other fields, Cloudflare provides [rule templates](https://dash.cloudflare.com/?to=/:account/:zone/security/security-rules?template=bot_traffic) to get started.
85+
86+
:::note
87+
Custom rules created from these templates execute before the managed rules configured in **Security Settings**. For more details on this execution order, refer to [Security features interoperability](/waf/feature-interoperability/).
88+
:::
8389

8490
- [Definite Bots template](https://dash.cloudflare.com/?to=/:account/:zone:/security/security-rules/custom-rules/create?template=Definitely%20Bots): Targets malicious bot traffic while ignoring verified bots and routes delivering static content.
8591

@@ -93,7 +99,7 @@ Cloudflare has [default templates](https://dash.cloudflare.com/?to=/:account/:zo
9399
(cf.bot_management.score ge 2 and cf.bot_management.score le 29 and not cf.bot_management.verified_bot and not cf.bot_management.static_resource)
94100
```
95101

96-
- (Optional) [JavaScript detections template](https://dash.cloudflare.com/?to=/:account/:zone/security/security-rules/custom-rules/create?template=JavaScript%20Verified%20URLs): If you enabled JavaScript detections, then set up a [managed challenge](/cloudflare-challenges/challenge-types/challenge-pages/#managed-challenge), make sure to add a method and URI path. JavaScript detections improves security for URLs that should only expect JavaScript-enabled clients.
102+
- (Optional) [JavaScript detections template](https://dash.cloudflare.com/?to=/:account/:zone/security/security-rules/custom-rules/create?template=JavaScript%20Verified%20URLs): You must first enable JavaScript Detections from Security Settings, then set up a [managed challenge](/cloudflare-challenges/challenge-types/challenge-pages/#managed-challenge). Make sure to add a method and URI path. JavaScript detections improves security for URLs that should only expect JavaScript-enabled clients.
97103

98104
```txt wrap
99105
(not cf.bot_management.js_detection.passed and http.request.method eq "" and http.request.uri.path in {""})

src/content/docs/bots/plans/biz-and-ent.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ import { Render } from "~/components";
8484

8585
[^1]: When users purchase Bot Management for Enterprise, Cloudflare automatically replaces and disables other bot products to prevent overlap.
8686

87+
<Render file="bot-settings-vs-custom-rules" product="bots" />
88+
8789
## How do I get started?
8890

8991
<Render file="plan-get-started" product="bots" />

src/content/docs/bots/plans/bm-subscription.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,24 @@ import { Render } from "~/components";
9999
Zones that have [Enterprise Bot Management](/bots/get-started/bot-management/) enabled will not see Bot Fight Mode or Super Bot Fight Mode under **Security** > **Bots**.
100100
:::
101101

102+
## Bot settings vs. custom rules
103+
104+
Bot Management customers have both bot settings (configured in **Security Settings**) and the ability to create custom rules using bot score fields. Start with the bot settings for baseline protection, then add custom rules only when you need additional control.
105+
106+
| Feature | Handled by bot settings | When to use custom rules instead |
107+
| --- | --- | --- |
108+
| Block or challenge definitely automated traffic | No | Path-specific rules, custom thresholds, or combining with other fields |
109+
| Block or challenge likely automated traffic | No | Path-specific rules, custom thresholds, or combining with other fields |
110+
| Allow or block verified bots | No | Granular control by verified bot category |
111+
| Block AI crawlers | Yes | Target individual AI crawlers using detection IDs |
112+
| Protect static resources | No | Exclude static resources from specific rules |
113+
| Optimize for WordPress | No | No |
114+
| Forward bot data to origin | No | Use [Transform Rules](/rules/transform/) or [Snippets](/rules/snippets/) |
115+
| Detection ID targeting | No | Use `cf.bot_management.detection_ids` in [custom rules](/waf/custom-rules/) |
116+
| JA3/JA4 fingerprint rules | No | Use `cf.bot_management.ja3_hash` or `cf.bot_management.ja4` in [custom rules](/waf/custom-rules/) |
117+
118+
For more details on when custom rules are needed, refer to [custom rules](/bots/additional-configurations/custom-rules/).
119+
102120
## How do I get started?
103121

104122
<Render file="plan-get-started" product="bots" />

src/content/docs/bots/plans/pro.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ import { Render } from "~/components";
8080
</tbody>
8181
</table>
8282

83+
<Render file="bot-settings-vs-custom-rules" product="bots" />
84+
8385
## How do I get started?
8486

8587
<Render file="plan-get-started" product="bots" />

src/content/docs/waf/custom-rules/use-cases/challenge-bad-bots.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@ Cloudflare's Bot Management feature scores the likelihood that a request origina
99
Access to [Bot Management](/bots/plans/bm-subscription/) requires a Cloudflare Enterprise plan with Bot Management enabled.
1010
:::
1111

12+
## Bot settings
13+
14+
Before creating custom rules for bot protection, review the settings on your [Security Settings](/security/) page under **Bot traffic**. Built-in features auto-update with new bot signatures, do not count toward your custom rule limits, and are simpler to manage.
15+
16+
| Use case | Bot setting |
17+
| --- | --- |
18+
| Block AI crawlers (GPTBot, ClaudeBot, etc.) | **Block AI bots** |
19+
| Block definitely automated traffic (bot score of 1) | **Definitely automated** |
20+
| Challenge likely automated traffic (bot score 2-29) | **Likely automated** |
21+
| Allow verified bots (Googlebot, Bingbot, etc.) | **Verified bots** |
22+
| Extend bot protection to static resources | **Static resource protection** | **Security Settings** > **Bot traffic** |
23+
| Allow WordPress loopback requests | **Optimize for WordPress** | **Security Settings** > **Bot traffic** |
24+
25+
Custom rules are still valuable when you need path-specific protection (different handling for `/api/` vs. `/login/`), custom score thresholds (for example, score below 20 instead of 30), conditional logic combining bot score with other fields, or custom actions not available in the built-in settings.
26+
1227
Bot score ranges from 1 through 99. A low score indicates the request comes from a script, API service, or an automated agent. A high score indicates that a human issued the request from a standard desktop or mobile web browser.
1328

1429
These examples use:
@@ -28,6 +43,10 @@ Your rules may also vary based on the [nature of your site](/bots/get-started/bo
2843

2944
### General protection
3045

46+
:::note
47+
Custom rules execute before [Super Bot Fight Mode](/bots/get-started/super-bot-fight-mode/#waf-custom-rules). If you already configured actions for **Definitely automated** and **Likely automated** traffic in **Security Settings**, deploying these custom rules creates additional rules that take priority over those settings on matching traffic.
48+
:::
49+
3150
The following three custom rules provide baseline protection against malicious bots:
3251

3352
**Rule 1:**

src/content/docs/waf/get-started.mdx

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,30 @@ If you are an Enterprise customer, do the following:
109109

110110
If you are on a Business plan, create a custom rule as mentioned above but use the [WAF Attack Score Class](/waf/detections/attack-score/#available-scores) field instead. For example, you could use the following rule expression: `WAF Attack Score Class equals Attack`.
111111

112-
## 3. Create custom rule based on bot score
112+
## 3. Configure bot protection
113113

114114
:::note
115-
Bot score is only available to Enterprise customers with [Bot Management](/bots/get-started/bot-management/). Customers on Pro and Business plans may enable [Super Bot Fight mode](/bots/get-started/super-bot-fight-mode/) instead.
115+
Bot score is only available to Enterprise customers with [Bot Management](/bots/get-started/bot-management/). Customers on Pro and Business plans should turn on [Super Bot Fight Mode](/bots/get-started/super-bot-fight-mode/) instead, which provides built-in bot protection without creating custom rules.
116116
:::
117117

118-
Customers with access to [Bot Management](/bots/get-started/bot-management/) can block automated traffic (for example, from [bots scraping online content](https://www.cloudflare.com/learning/bots/what-is-content-scraping/)) using a custom rule with bot score, preventing this traffic from hitting your application.
118+
Enterprise customers with Bot Management should first configure bot protection using **Security Settings**, which provide baseline protection without creating custom rules:
119119

120-
[Create a custom rule](/waf/custom-rules/create-dashboard/) using the <GlossaryTooltip term="bot score">Bot Score</GlossaryTooltip> and <GlossaryTooltip term="verified bot">Verified Bot</GlossaryTooltip> fields:
120+
<Steps>
121+
122+
1. In the Cloudflare dashboard, go to the **Security Settings** page and filter by **Bot traffic**.
123+
124+
<DashButton url="/?to=/:account/:zone/security/settings" />
125+
126+
2. Configure the **Definitely automated**, **Likely automated**, and **Verified bots** settings according to your needs.
127+
3. Turn on **Block AI bots** if you want to block AI crawlers.
128+
129+
</Steps>
130+
131+
These built-in settings auto-update with new bot signatures and do not count toward your custom rule limits. For more details, refer to [Bot Management](/bots/get-started/bot-management/).
132+
133+
### Create a custom rule for additional control
134+
135+
Optionally, if you need more granular control — for example, a different score threshold or rules that combine bot score with other fields — [create a custom rule](/waf/custom-rules/create-dashboard/) using the <GlossaryTooltip term="bot score">Bot Score</GlossaryTooltip> and <GlossaryTooltip term="verified bot">Verified Bot</GlossaryTooltip> fields:
121136

122137
- **When incoming requests match**:
123138

@@ -128,11 +143,13 @@ Customers with access to [Bot Management](/bots/get-started/bot-management/) can
128143

129144
- **Choose action**: Managed Challenge
130145

131-
For a more comprehensive example of a baseline protection against malicious bots, refer to [Challenge bad bots](/waf/custom-rules/use-cases/challenge-bad-bots/#general-protection).
146+
This rule uses a threshold of 20 (instead of the default threshold of 30 used by the settings), providing stricter protection for traffic in the 20-29 score range.
147+
148+
For a more comprehensive example of baseline protection against malicious bots, refer to [Challenge bad bots](/waf/custom-rules/use-cases/challenge-bad-bots/#general-protection).
132149

133150
For more information about the bot-related fields you can use in expressions, refer to [Bot Management variables](/bots/reference/bot-management-variables/).
134151

135-
Once you have deployed the Cloudflare Managed Ruleset and rules based on attack score and bot score you will have achieved substantial protection, limiting the chance of false positives.
152+
Once you have deployed the Cloudflare Managed Ruleset and rules based on attack score and bot score, you will have achieved substantial protection, limiting the chance of false positives.
136153

137154
## 4. Optional - Deploy the Cloudflare OWASP Core Ruleset
138155

0 commit comments

Comments
 (0)