WAF attack score
The attack score traffic detection classifies each request using a machine learning algorithm, assigning a score from 1 to 99 based on the likelihood that the request is malicious. This detection complements WAF Managed Rules.
Managed Rules match requests against known attack signatures — specific patterns of established attack vectors. They have a very low rate of false positives. However, attackers can modify known payloads, for example by using fuzzing techniques (a testing technique that sends modified inputs to find vulnerabilities), to evade exact signature matches.
Attack score addresses this gap. You can use the score to identify potentially malicious traffic that is not an exact match to any of the rules in WAF Managed Rules.
To maximize protection, Cloudflare recommends that you use both Managed Rules and attack score.
The Cloudflare WAF provides the following attack score fields:
| Field | Description | Required plan |
|---|---|---|
WAF Attack Score cf.waf.score Number | A global score from 1–99 that combines the score of each WAF attack vector into a single score. | Enterprise |
WAF SQLi Attack Score cf.waf.score.sqli Number | A score from 1–99 classifying the SQL injection ↗ (SQLi) attack vector. | Enterprise |
WAF XSS Attack Score cf.waf.score.xss Number | A score from 1–99 classifying the cross-site scripting ↗ (XSS) attack vector. | Enterprise |
WAF RCE Attack Score cf.waf.score.rce Number | A score from 1–99 classifying the command injection or remote code execution ↗ (RCE) attack vector. | Enterprise |
WAF Attack Score Class cf.waf.score.class String | The attack score class of the current request, based on the WAF attack score. Possible values: attack, likely_attack, likely_clean, and clean. | Business or above |
You can use these fields in expressions of custom rules and rate limiting rules. Numeric score fields range from 1 to 99:
- A score of
1indicates that the request is almost certainly malicious. - A score of
99indicates that the request is likely clean.
A score of 100 means the request reached the WAF attack score system, but the system decided not to score it.
In Logpush data, a score of 0 means the request did not reach the attack score stage — for example, because a previous rule or protection system already mitigated it. The value 0 does not appear in the Cloudflare dashboard.
The global WAF Attack Score is mathematically derived from individual attack scores (for example, from SQLi Attack Score and XSS Attack Score), reflecting their interdependence. However, the global score is not a sum of individual scores. A low global score usually indicates medium to low individual scores, while a high global score suggests higher individual scores.
The WAF Attack Score Class field can have one of the following values, depending on the calculated request attack score:
| Dashboard label | Field value | Description |
|---|---|---|
| Attack | attack | Attack score between 1 and 20. |
| Likely attack | likely_attack | Attack score between 21 and 50. |
| Likely clean | likely_clean | Attack score between 51 and 80. |
| Clean | clean | Attack score between 81 and 99. |
Requests with the special attack score 100 will show a WAF Attack Score Class of Unscored in the Cloudflare dashboard, but you cannot use this class value in rule expressions.
Attack score automatically detects and decodes Base64, JavaScript (Unicode escape sequences), and URL encoded content anywhere in the request: URL, headers, and body.
Blocking traffic solely based on attack score for all values below 50 is not recommended. The Likely attack range (scores 21–50) can include legitimate requests incorrectly flagged as malicious (false positives). If you want to block traffic based on attack score, do one of the following:
-
Use a more strict WAF Attack Score value in your expression. For example, block traffic with a WAF attack score below
20or below15(you may need to adjust the exact threshold). -
Combine a higher WAF Attack Score threshold with additional filters when blocking incoming traffic. For example, include a check for a specific URI path in your expression or use bot score as part of your criteria.
Enterprise customers can create a custom rule that blocks requests with a WAF Attack Score less than or equal to 20 (recommended initial threshold). For example:
| Field | Operator | Value |
|---|---|---|
| WAF Attack Score | less than or equal to | 20 |
- Equivalent rule expression:
cf.waf.score le 20 - Action: Block
Business customers must create a custom rule with the WAF Attack Score Class field instead. For example, use this field to block incoming requests with a score class of Attack:
| Field | Operator | Value |
|---|---|---|
| WAF Attack Score Class | equals | Attack |
- Equivalent rule expression:
cf.waf.score.class eq "attack" - Action: Block
Monitor the rule you created, especially in the first few days, to make sure you entered an appropriate threshold (or class) for your traffic. Update the rule if required.
If you are an Enterprise customer and you created a rule with Log action, change the rule action to a more severe one, like Managed Challenge or Block.
WAF attack score and bot score serve different purposes. Attack score identifies variations of attacks that WAF Managed Rules do not catch. Bot score identifies whether a request comes from automated traffic.