Add-ons
Posted By Nick —

Cloudflare Add-On 3.0


Version 3.0 introduces two major changes to the Cloudflare add-on for WP Cerber. The add-on now supports scoped Cloudflare API Tokens as an alternative to the Global API Key and can manage IP Access Rules within a specific Cloudflare zone. We recommend both for new installations.

This release also introduces a breaking change for websites that use a proxy server for outgoing connections. This is why we are releasing it as version 3.0. Version 2.6 was never released, and all changes planned for it are included in 3.0.

Key Highlights

  • The add-on authenticates with a Cloudflare API Token, so the Global API Key no longer has to be stored in WordPress.
  • A Zone ID limits the add-on’s IP Access Rules to a specific Cloudflare zone. This is now the configuration we recommend.
  • Most existing installations continue to work after the update without changes to their settings or rules.
  • Websites that use a proxy server for outgoing connections need to check that it allows api.cloudflare.com.
  • A rule removed manually in the Cloudflare dashboard no longer stops the add-on from creating a new rule for the same IP address or range.
  • The requirements are unchanged: WP Cerber 9.8.3 or newer and PHP 7.4 or newer.

New Features

API Token authentication

Until now the add-on could authenticate only with the Global API Key. If exposed through a compromised WordPress database or backup, the Global API Key could give an attacker broad access to Cloudflare resources, including DNS records and zone settings. We now consider the Global API Key a legacy authentication method.

Version 3.0 adds a Cloudflare API Token section to the add-on settings. An API Token has only the permissions you grant it, so a token limited to what the add-on needs exposes far less than the key. The add-on documentation lists the single permission the token needs and walks through creating it.

Once an API Token is configured, it is the only credential the add-on uses. If Cloudflare rejects the token, the add-on reports the failure and does not fall back to the Global API Key.

Two points matter if your installation already uses the Global API Key:

  • Switching to a token does not touch your existing rules. Nothing is deleted or recreated, and the add-on continues to manage every rule it has created.
  • Create the token as the same Cloudflare user the Global API Key belongs to. A token created by another Cloudflare user passes the credential check, yet it cannot reach the rules created earlier, and they remain in Cloudflare but are no longer managed by the add-on. See Switch an existing installation to an API Token.

Zone-level IP Access Rules

Earlier versions created IP Access Rules at the user level. Such a rule applies to every zone owned by the Cloudflare user, so a lockout on one website blocked the IP address in all of that user’s zones, and an allowed address was allowed in all of them.

The new Zone ID setting limits the rule scope to one Cloudflare zone, the zone that serves your website. We recommend this configuration, because the rules then apply within that zone and nowhere else.

How to adopt it depends on your installation:

  • New installations. Enter the Zone ID together with the authentication credentials. There are no rules to move.
  • Existing installations. Nothing changes with the update, and the add-on keeps creating user-level rules. Configuring a Zone ID later is a separate and optional step. The add-on then deletes its user-level rules and recreates them at the zone level, and until that has completed your website has no Cloudflare rules from the add-on. Update first, confirm that synchronization works, and move the rules when it is convenient for you.

Leave the Zone ID empty if you run websites in several zones under one Cloudflare user and want a lockout on one of them to protect the others. Leave it empty as well on a multisite network whose sites use separate domain names rather than subdomains of one domain, since such a network spans several zones.

Configuring Cloudflare zones explains where to find the Zone ID, which API Token permission is required, and what a move involves.

Breaking Changes

Cloudflare requests follow the proxy settings of WP Cerber

Earlier versions always connected to Cloudflare directly, even on websites where WP Cerber was configured to use a proxy server for outgoing connections. Version 3.0 sends its Cloudflare API requests through that proxy.

This affects your website only if both conditions are met: the Use WordPress proxy settings option of WP Cerber is enabled, and the WP_PROXY_HOST and WP_PROXY_PORT constants are defined in wp-config.php. In that case, make sure the proxy server allows connections to api.cloudflare.com before you update. Otherwise the Cloudflare requests fail and synchronization stops. WP Cerber keeps enforcing its lockouts and IP Access Lists on your server either way.

Security Changes

A scoped API Token narrows what an attacker gains from a compromised WordPress database or backup. An exposed Global API Key could give broad access to Cloudflare resources. An exposed API Token gives only the permissions granted to it, and a token created for one zone cannot reach your other zones.

Zone-level rules also limit the scope of Cloudflare Allow rules created from WP Cerber’s Allowed IP Access List. A Cloudflare Allow rule can bypass several Cloudflare security controls, including WAF Managed Rules and Rate Limiting Rules. At the user level such a rule applied to every zone of the Cloudflare user. With a Zone ID configured it applies to one.

Admin Experience

The credential check that runs when you save the settings now explains what was verified. A successful check reads, for example, “The Cloudflare API Token is valid and can manage IP Access Rules in the Cloudflare zone …”. A failed check names the credential, the scope of the credential check, and the error returned by Cloudflare.

When Cloudflare returns a generic authentication error (code 10000), the add-on now provides additional context to help identify the cause. It names the scope of the failed request, as in “The Cloudflare API Token may lack the permission to manage the IP Access Rules at user level.”

For each rule creation request, the Diagnostic Log now includes both the original WP Cerber entry and the corresponding IP address or range sent to Cloudflare. An IP Access List entry 198.51.100.*, for example, is logged together with its Cloudflare target 198.51.100.0/24. If you parse these log entries with your own tools, note that their format has changed.

Reliability Improvements

Manually removing an IP Access Rule in the Cloudflare dashboard could leave the add-on with a stale record of that rule. In version 2.5, this prevented the add-on from creating a new rule for the same IP address or range, contrary to the behavior described in our documentation.

Version 3.0 correctly handles Cloudflare’s response when attempting to delete a rule that no longer exists. The add-on removes the stale record and can create a new rule the next time the IP address is locked out or the entry is added to an IP Access List.

Bugfixes

  • Fixed a bug that prevented the add-on from recognizing verified Google crawlers with User-Agent strings beginning with Googlebot, such as Googlebot-Image/1.0. The add-on no longer creates Cloudflare Block rules for these crawlers.
  • With Block subnet enabled in WP Cerber, an IPv6 lockout now creates a Cloudflare rule for the individual IP address, regardless of which supported version of WP Cerber is installed.

Updating to 3.0

The update requires no action on most websites. An installation configured with the Global API Key keeps using it, keeps its user-level rules, and continues to synchronize as before. The exception is a website that uses a proxy server for outgoing connections, as described under Breaking Changes.

If you update from version 1.3 or older, the one-time rebuild of the rule set starts with any working authentication credentials, the Global API Key or an API Token.

Before downgrading from 3.0, clear the Zone ID if configured and wait for the rules to move back to the user level. If you use an API Token, restore your Global API Key and Cloudflare account email, clear the API Token field, and confirm that the credential check passes before downgrading. Earlier versions support neither API Token authentication nor zone-level rules. See Before downgrading the add-on.

Have any questions?

If you have a question regarding WordPress security or WP Cerber, ask it in the comments below or find answers on the community forum.

Spotted a bug or glitch?

We’d love to fix it! Share your bug discoveries with us here: Bug Report.


I'm a software engineer and team lead at Cerber Tech. I started coding in 1993 on IBM System/370 and today software engineering at Cerber Tech is how I make my living.

View Comments
There are currently no comments.