Skip to content

Commit c95996e

Browse files
feedback
1 parent 9795d10 commit c95996e

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

src/content/docs/cloudflare-challenges/challenge-types/javascript-detections.mdx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ Refer to the [WAF documentation](/waf/custom-rules/create-dashboard/) for more i
3333

3434
## API
3535

36-
Use JavaScript Detections API for more granular control over when and where JavaScript Detections are injected on your website, as well as an option for callback handling (for logging or other additional actions).
36+
If you enable JavaScript Detections via the dashboard, Cloudflare will insert a script tag in all HTML pages served on your website. If you would prefer to limit where JavaScript Detections are served, you can do so with the JavaScript Detections API script.
37+
38+
The JavaScript Detections API allows you more granular control over when and where JavaScript Detections are injected on your website, as well as an option for callback handling (for logging or other additional actions).
3739

3840
You can explicitly add a script reference to `jsd/api.js` and your own code calling `window.cloudflare.jsd.executeOnce` on specific HTML pages of your website.
3941

@@ -60,9 +62,10 @@ function jsdOnload(){
6062
6163
## Considerations
6264
63-
- While JavaScript Detections further refine the [bot score](/bots/concepts/bot-score/), it is not a very significant effect.
64-
- If the JavaScript Detections injection or execution fails and `cf.bot_management.js_detection.passed` = `false`, a separate Bot Management heuristic can still yield a 1 or higher bot score, independent of JavaScript Detections.
65-
- Even if JavaScript Detections pass, the final bot score may still be 1 due to other detection heuristics (for example, known malicious IP, signature detection, and more), resulting in `js_detection.passed` = `true`, but `score` = 1.
65+
JavaScript Detections do not guarantee a specific bot score.
66+
67+
- If the JavaScript Detections injection or execution fails and `cf.bot_management.js_detection.passed` = `false`, a separate Bot Management heuristic can still yield a 1 or higher bot score, independent of JavaScript Detections.
68+
- If the JavaScript Detections pass, the final bot score may still be 1 due to other detection heuristics (for example, known malicious IP, signature detection, and more), resulting in `js_detection.passed` = `true`, but `score` = 1.
6669
6770
## Limitations
6871

src/content/partials/cloudflare-challenges/javascript-detections-implementation.mdx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
---
55

6+
import { Tabs, TabItem } from "~/components";
7+
68
Once you enable JavaScript detections, you must use the `cf.bot_management.js_detection.passed` field to create [WAF custom rules](/waf/custom-rules/) (or the `request.cf.botManagement.jsDetection.passed` variable in [Workers](/workers/)).
79

810
When adding this field to WAF custom rules, it is used on endpoints expecting browser traffic (avoiding native mobile applications or websocket endpoints), after a user's first request to your application (Cloudflare needs at least one HTML request before injecting JavaScript detection), and with the Managed Challenge action, because there are legitimate reasons a user might not have passed a JavaScript Detection challenge (network issues, ad blockers, disabled JavaScript in browser, native mobile applications).
@@ -18,10 +20,20 @@ When adding this field to WAF custom rules, it is used on endpoints expecting br
1820

1921
The `cf.bot_management.js_detection.passed` field should never be used in a WAF custom rule that matches a visitor's first request to a site. It is necessary to have at least one HTML request before Cloudflare can inject JavaScript detection.
2022

21-
```js title="Example"
22-
"botManagement": {
23-
"jsDetection": {
24-
"passed": false
25-
}
26-
}
27-
```
23+
<Tabs>
24+
<TabItem label="WAF rule example">
25+
```txt wrap
26+
(http.request.uri.path eq "/api/v4/user/create" and http.request.method eq "POST" and not cf.bot_management.verified_bot)
27+
and (cf.bot_management.score lt 30 or !cf.bot_management.js_detection.passed)
28+
```
29+
</TabItem>
30+
<TabItem label="Workers example">
31+
```js
32+
"botManagement": {
33+
"jsDetection": {
34+
"passed": false
35+
}
36+
}
37+
```
38+
</TabItem>
39+
</Tabs>

0 commit comments

Comments
 (0)