WAF managed rules upgrade·续1

B) If you are using the new security dashboard: 1. Go to the Security rules page. Go to Security rules ↗ 2. Select Go to upgrade your Managed rules.

If you are an Enterprise customer, the dashboard will show the following banner:The upgrade banner displayed to Enterprise customers. If you are a Professional/Business customer, the dashboard will show the following banner: The upgrade banner displayed to Pro/Business customers. 3. In the upgrade banner, select Review configuration. This banner is only displayed in eligible zones. 4. Review the proposed WAF configuration. You can adjust configuration, like editing the WAF Managed Rules configuration or creating exceptions to skip the execution of rulesets or specific rules. 5. When you are done reviewing, select Deploy to deploy the new WAF Managed Rules configuration.

If you are a Professional/Business customer, Cloudflare will deploy the new WAF configuration and then disable the previous WAF version. The upgrade process may take a couple of minutes.

If you are an Enterprise customer, both WAF implementations will be enabled simultaneously when you select Deploy, so that you can validate your new configuration. Refer to the steps in the next section for additional guidance.

Validate your new WAF configuration and finish the upgrade (Enterprise customers only)

If you are an Enterprise customer, after deploying your new WAF configuration both WAF implementations will be enabled simultaneously. During this stage (called validation mode), you can access both implementations of WAF Managed Rules in the Cloudflare dashboard, which will keep showing the upgrade banner until you finish upgrading. The new WAF Managed Rules will run before the previous version.

  1. Use the current validation mode to check the behavior of the new WAF configuration in Security Events. For more information, refer to Analyzing the new WAF behavior in Security Events.
  2. When you are done reviewing your configuration with both WAFs enabled, select Ready to update in the upgrade banner, and then select Turn off previous version. This operation will complete the upgrade and disable the previous WAF version.

When the upgrade finishes, the dashboard will show all of your upgraded rules in:

  • Old dashboard: Security > WAF > Managed rules tab
  • New dashboard: Security > Security rules

To check if the upgrade has finished, refresh the dashboard.

Note

The upgrade process can take up to an hour. During this period you may observe security events from both versions of WAF managed rules.

Using the API

  1. Use the Check WAF update compatibility operation to determine if the zone can update to the new WAF, given its current configuration:

bash curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/waf_migration/check?phase_two=1" \ --header "Authorization: Bearer <API_TOKEN>"

Example response:

json { "result": { "compatible": true, "migration_state": "start" }, "success": true, "errors": [], "messages": [] }

If the response includes "compatible": true, this means that the zone can update to the new WAF and you can proceed with the upgrade process. If the response includes "compatible": false, this means that your zone is not eligible for the upgrade, given its current configuration. Refer to Eligible zones for details. 2. To get the new WAF configuration corresponding to your current configuration, use the Get new WAF configuration operation:

bash curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/waf_migration/config?phase_two=1" \ --header "Authorization: Bearer <API_TOKEN>"

Example response:

json { "result": { "name": "default", "rules": [ { "id": "", "version": "", "action": "execute", "expression": "true", "description": "", "ref": "", "enabled": true, "action_parameters": { "id": "efb7b8c949ac4650a09736fc376e9aee", "overrides": { "rules": [ { "id": "23ee7cebe6e8443e99ecf932ab579455", "action": "log", "enabled": false } ] } } } ] }, "success": true, "errors": [], "messages": [] }

The returned configuration in the example above, which would match the existing configuration for the previous WAF version, contains:

  • A rule that executes the Cloudflare Managed Ruleset (ruleset ID efb7b8c949ac4650a09736fc376e9aee).
  • A single override for the rule Apache Struts - Open Redirect - CVE:CVE-2013-2248 (rule ID 23ee7cebe6e8443e99ecf932ab579455) in the same ruleset, setting the action to log and disabling the rule.

  • (Optional, for Enterprise customers only) If you are upgrading an Enterprise zone to WAF Managed Rules, you can enter validation mode before finishing the upgrade. In this mode, both WAF implementations will be enabled. Use the Update a zone entry point ruleset operation, making sure you include the waf_migration=validation&phase_two=1 query string parameters:

bash curl --request PUT \ "https://api.cloudflare.com/client/v4/zones/{zone_id}/rulesets/phases/http_request_firewall_managed/entrypoint?waf_migration=validation&phase_two=1" \ --header "Authorization: Bearer <API_TOKEN>" \ --header "Content-Type: application/json" \ --data '{ "name": "default", "rules": [ { "action": "execute", "expression": "true", "description": "", "enabled": true, "action_parameters": { "id": "efb7b8c949ac4650a09736fc376e9aee", "overrides": { "rules": [ { "id": "23ee7cebe6e8443e99ecf932ab579455", "action": "log", "enabled": false } ] } } } ] }'

After invoking this API endpoint, both WAF managed rules and WAF Managed Rules will be enabled. Check sampled logs in Security Events for any legitimate traffic getting blocked, and perform any required adjustments to the WAF Managed Rules configuration. For example, you can add an override for a single rule that disables it or changes its action. 4. To finish the upgrade and disable WAF managed rules, set the configuration for the new WAF using the settings you obtained in step 2 and possibly adjusted in step 3. Make sure you include the waf_migration=pending&phase_two=1 query string parameters.

bash curl --request PUT \ "https://api.cloudflare.com/client/v4/zones/{zone_id}/rulesets/phases/http_request_firewall_managed/entrypoint?waf_migration=pending&phase_two=1" \ --header "Authorization: Bearer <API_TOKEN>" \ --header "Content-Type: application/json" \ --data '{ "name": "default", "rules": [ { "id": "", "version": "", "action": "execute", "expression": "true", "description": "", "ref": "", "enabled": true, "action_parameters": { "id": "efb7b8c949ac4650a09736fc376e9aee", "overrides": { "rules": [ { "id": "23ee7cebe6e8443e99ecf932ab579455", "action": "log", "enabled": false } ] } } } ] }'

Once the provided configuration is saved and the new WAF Managed Rules are enabled, the previous version of the WAF managed rules will be automatically disabled, due to the presence of the waf_migration=pending&phase_two=1 parameters. This will make sure that your zone stays protected by one of the WAF versions during the update process.

Note

Pro and Business customers, which do not have access to the validation mode described in step 3, can update the rules (and overrides) in their zone entry point ruleset without triggering the upgrade by omitting the waf_migration=pending&phase_two=1 parameters. However, all the rules in their configuration must be disabled ("enabled": false). Only Enterprise customers can configure (enabled) rules deploying Managed Rulesets without triggering the upgrade.


Analyzing the new WAF behavior in Security Events

For Enterprise customers

If you are an Enterprise customer, use the validation mode of the WAF upgrade process to check the behavior of the new WAF Managed Rules configuration. Cloudflare enables validation mode after you deploy the new WAF configuration. In this mode, the previous WAF version is still enabled, so that you can validate the behavior of your new configuration during the upgrade process. The new WAF Managed Rules will run before the previous version.

Go to sampled logs in Security Events during validation mode and check the following:

  • Look for any requests allowed by the new WAF that are being handled by the previous WAF version (for example, by a challenge or block action). If this happens, consider writing a firewall rule or a WAF custom rule to handle the requests you previously identified.
  • Look for legitimate requests being blocked by the new WAF. In this situation, edit the WAF managed rule that is blocking these requests, changing the performed action or disabling the rule. For more information, refer to Configure a managed ruleset.

For Business/Professional customers

Business and Professional customers do not have access to validation mode, which means that they will be able to check the new WAF behavior after they upgrade to the new WAF Managed Rules.

In the days following the upgrade, check sampled logs in Security Events looking for any legitimate requests being blocked by WAF Managed Rules. If you identify any incorrectly blocked requests, adjust the corresponding WAF rule action to Log. For more information on changing the action of a managed ruleset rule, refer to Configure individual rules of a managed ruleset.

Additionally, check for requests that should have been blocked. In this situation, consider creating a firewall rule or a WAF custom rule to block these requests.