Configure via API
To enable the Cloudflare OWASP Core Ruleset for a given zone using the API, create a rule with execute
action in the entry point ruleset for the http_request_firewall_managed
phase. For more information on deploying a managed ruleset, refer to Deploy a managed ruleset.
To configure the Cloudflare OWASP Core Ruleset using the API, create overrides using the Rulesets API. You can perform the following configurations:
- Set the paranoia level.
- Configure the score threshold.
- Specify the action to perform when the threat score is greater than the threshold.
You can also disable specific rules in the managed ruleset using rule overrides.
To enable all the rules up to a specific paranoia level, create tag overrides that disable all the rules associated with higher paranoia levels.
The tags associated with the different paranoia levels are the following:
paranoia-level-1
paranoia-level-2
paranoia-level-3
paranoia-level-4
For example, to enable all the rules associated with Paranoia Level 2 (PL2), disable the rules associated with tags paranoia-level-3
and paranoia-level-4
. All rules associated with paranoia levels up to the desired paranoia level will be enabled (in this example, all the rules associated with PL1 and PL2).
This example sets the Cloudflare OWASP Core Ruleset’s paranoia level for a zone to PL2. To perform this configuration, you must disable the tags associated with levels PL3 and PL4 (paranoia-level-3
and paranoia-level-4
) using tag overrides.
- Get the ID of the Cloudflare OWASP Core Ruleset using the List account rulesets method, since WAF’s managed rulesets exist at the account level. Alternatively, use the following ruleset ID directly:
...c25d2f1f
.
Request
Response
- Get the ID of the rule that deploys the OWASP ruleset to your zone using the Get a zone entry point ruleset. Search for a rule with
"action": "execute"
configured with the OWASP ruleset’s ID in theaction_parameters
object. This rule will only exist if you have already deployed the OWASP ruleset.
Request
Response
- Update the rule you identified using the Update a zone ruleset rule operation, adding tag overrides that disable the rules with tags
paranoia-level-3
andparanoia-level-4
.
Request
For more information on creating overrides, refer to Override a managed ruleset.
To define the score threshold, or to specify the action to perform when the threat score is greater than the threshold, create a rule override for the last rule in the managed ruleset that:
- Specifies the action to take in the
action
property. The available actions are:block
(default),managed_challenge
,js_challenge
,log
, andchallenge
. - Defines the desired anomaly score threshold (an integer value) in the
score_threshold
property.
This example configures the managed ruleset score threshold and the performed action by creating a rule override for the last rule of the managed ruleset.
- Get the ID of the Cloudflare OWASP Core Ruleset using the List account rulesets method, since WAF’s managed rulesets exist at the account level. Alternatively, use the following ruleset ID directly:
...c25d2f1f
.
Request
Response
- Get the ID of the last rule in the Cloudflare OWASP Core Ruleset. Use the Get an account ruleset method to obtain the list of rules in the ruleset. Alternatively, use the following rule ID directly:
...843b323c
.
Request
Response
- Get the ID of the rule that deploys the OWASP ruleset to your zone using the Get a zone entry point ruleset (in this example,
<EXECUTE_RULE_ID>
). Search for a rule with"action": "execute"
configured with the OWASP ruleset’s ID in theaction_parameters
object. This rule will only exist if you have already deployed the OWASP ruleset.
Request
Response
-
Update the rule you identified in the entry point ruleset using the Update a zone ruleset rule operation, adding a rule override for the last rule in the OWASP ruleset (identified in step 2) with the following properties and values:
"score_threshold": 60
"action": "managed_challenge"
Request
For more API examples, refer to Managed ruleset override examples in the Ruleset Engine documentation.