Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared Managed Cloud India
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Best lists Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Security · Explainer

Cloudflare WAF Rules for WordPress

Short answer

Cloudflare WAF rules filter requests before they reach your WordPress site. Start with the managed rulesets included in your plan, then add custom rules that challenge the login and admin areas and a rate limiting rule for wp-login.php. Check the Security Events log after setup, and fix false positives with exceptions instead of turning the WAF off.

Key takeaways

  • The Cloudflare WAF checks requests at the edge and blocks or challenges bad traffic before it reaches WordPress.
  • The Free plan includes 5 custom rules and 1 rate limiting rule, as of November 2026.
  • The Free Managed Ruleset runs on all plans, while the full Cloudflare Managed Ruleset needs Pro or higher.
  • Managed rules carry a wordpress tag, so you can enable the rules that match your WordPress stack.
  • Rate limiting on the Free plan counts requests over 10 seconds and blocks for 10 seconds.
  • A WAF cannot patch plugins or fix weak passwords, so keep WordPress and its plugins updated.

What are Cloudflare WAF rules?

Cloudflare WAF rules are filters that inspect incoming requests and block, challenge, or allow them before they reach your WordPress site.

A WAF sits in front of your site and inspects HTTP traffic before it reaches WordPress. Cloudflare's WAF docs say the WAF checks incoming web and API requests and filters undesired traffic based on rulesets.

Each rule pairs a filter with an action. The filter says which requests match, using the Rules language, and the action says what happens next, such as Block or Managed Challenge. A ruleset is an ordered set of rules, and rules run in sequence until one with a terminating action stops the check.

How does the Cloudflare WAF check a request?

The WAF checks each request against its rulesets in a fixed order, and the first rule with a terminating action stops the check.

Cloudflare's WAF concepts page lists the order as IP Access rules first, then deprecated firewall rules, custom rules, rate limiting rules, and managed rules last. A Block in an early phase means later rules never see that request.

The WAF has two jobs: detection and mitigation. Detection scores traffic, and mitigation blocks, challenges, or throttles it. The same concepts page says attack score runs from 1, likely malicious, to 99, unlikely to be malicious, while bot score runs from 1, likely a bot, to 99, likely human.

You can use those scores inside your own rules. For example, a custom rule can challenge requests with a low bot score on the login page while letting normal visitors through.

What is the difference between managed rules and custom rules?

Managed rules are ready-made rulesets written by Cloudflare, while custom rules are filters you write yourself for your own site.

Managed rulesets cover known attacks and zero-day flaws, and Cloudflare updates them on a regular basis. The Managed Rules page says each rule has a default action that varies with its severity, and you can change the action for a single rule, a tag, or a whole ruleset.

Custom rules cover the needs that are specific to your site. The Custom rules page says a custom rule has an expression that matches traffic and an action that runs on a match, and rules run in order until a Block stops later rules.

Rule typeWho writes itBest use on WordPress
Managed rulesCloudflare security teamBlock known attacks and zero-day flaws
Custom rulesYouChallenge login and admin requests
Rate limiting rulesYouSlow down repeated login attempts

Which managed rulesets should a WordPress site turn on?

Turn on the Free Managed Ruleset on the Free plan, and the Cloudflare Managed Ruleset plus the OWASP Core Ruleset on Pro or higher.

The Managed Rules page lists the Free Managed Ruleset as available on all plans, with protection against high-impact and widely exploited flaws. The full Cloudflare Managed Ruleset and the OWASP Core Ruleset need Pro or higher, as of November 2026.

Managed rulesetFreeProBusinessEnterprise
Free Managed RulesetYesYesYesYes
Cloudflare Managed RulesetNoYesYesYes
Cloudflare OWASP Core RulesetNoYesYesYes
Sensitive Data DetectionNoNoNoYes

Rules in managed rulesets carry tags, and one of those tags is wordpress. The Cloudflare Managed Ruleset page recommends that you enable the rules whose tags match your stack, so a WordPress site should enable the rules tagged wordpress.

The OWASP Core Ruleset works differently from the others. It adds a score for each matching rule, and the WAF acts when the total passes a threshold, according to the Managed Rules page. The OWASP Top 10:2021 lists Broken Access Control as A01 and Injection as A03.

If you compare plans first, our Cloudflare Free vs Pro guide explains which WAF features each plan includes. Managed rules also have a size limit: they inspect request bodies up to 1 MB on the Free plan and up to 128 KB on Enterprise, as of November 2026.

What custom rules help a WordPress site most?

The most useful custom rules for WordPress challenge or block requests to the login and admin areas and to sensitive files.

The login page is a prime target because attackers guess passwords there. WordPress.org's Hardening WordPress guide says the most common attacks are crafted HTTP requests with exploit payloads and brute-force password guessing, so the login area deserves its own rules.

Plan limits shape how many rules you can write. The Custom rules page gives 5 custom rules on Free, 20 on Pro, 100 on Business, and 1,000 on Enterprise, as of November 2026. Regex matching needs Business or higher, and the Log action needs Enterprise.

Use Managed Challenge, not Block, for the login and admin areas at first. A challenge lets a real person through while it stops simple bots, and you can switch to Block later if the events log shows only attacks.

A rule can match on the request path, so a filter such as http.request.uri.path eq "/wp-login.php" targets the login page alone. You can pair that with a challenge action, or use Cloudflare Turnstile on the login form as an extra check for real visitors.

How do rate limiting rules protect wp-login.php?

A rate limiting rule counts requests to the login page from one IP and blocks or challenges that IP when the count passes your limit.

Rate limiting rules exist to stop abuse of a login endpoint or an API, and the Rate limiting rules page names brute-force attacks on a login endpoint as the main example. A rule needs a counting method, a period, a requests-per-period limit, and a mitigation timeout.

The Free plan is strict: 1 rate limiting rule, with a 10 second counting period and a 10 second mitigation timeout. Pro allows 2 rules with counting up to 1 minute and mitigation up to 1 hour, while Business allows 5 rules with counting up to 10 minutes, as of November 2026.

Free plan rules can only match on the path and on verified bot status. Business adds the method, source IP, and user agent as match fields, so a Business rule can count only POST requests to the login page instead of every load of the form.

Do not treat rate limiting as a precise counter. Cloudflare says there can be a delay of up to a few seconds before counters update, so extra requests can still reach your origin before the block starts.

How do you set up Cloudflare WAF rules for WordPress?

Open the Security settings in the Cloudflare dashboard, turn on the managed ruleset for your plan, then add custom and rate limiting rules.

To deploy the Cloudflare Managed Ruleset, the Cloudflare Managed Ruleset page gives these steps:

  1. Go to the Security Settings page in the Cloudflare dashboard.
  2. Filter by Web application exploits if you want a shorter list.
  3. Turn on Cloudflare managed ruleset.
  4. Review the deployment settings and edit the scope if you only want it on part of your traffic.
  5. Select Save.

Next, add your custom rules under Security rules. Give each rule a clear name, such as “Challenge wp-login”, so the events log stays easy to read. Then add one rate limiting rule for wp-login.php and set its action to Block or Managed Challenge.

Check your encryption mode while you are in the dashboard, as described in our Cloudflare SSL settings guide. The WAF filters traffic, but it does not fix a weak link between Cloudflare and your origin server.

How do you check whether your WAF rules are working?

Check the Security Analytics dashboard and the Security Events log for blocked and challenged requests after you deploy a rule.

Detection scores feed Security Analytics, where you can study your security posture before you pick a mitigation. The WAF concepts page says scores from enabled detections appear there, so you can see which rules fire most and whether real visitors are caught.

When a rule blocks a real visitor, that is a false positive. The Managed Rules page says managed rulesets are updated to cut false positives, but new rules can still clash with a plugin or a form on your site.

Fix a false positive with an exception or an override, not by turning the whole ruleset off. Exceptions skip rules for set requests, overrides change a rule action or turn a rule off, and exceptions have priority over overrides, according to the same page.

What can Cloudflare WAF rules not do?

WAF rules cannot fix vulnerable plugins, weak passwords, or outdated WordPress core, so they are one layer of defence, not a full security plan.

The WAF only sees requests as they arrive, so it cannot fix code that is already on your server. A flaw in a plugin stays open until you update the plugin, no matter how many rules you add.

WordPress.org's Hardening WordPress guide says security is risk reduction, not risk elimination, and it tells you to keep WordPress updated because old versions are not maintained with security updates. A WAF rule cannot patch a flaw in a plugin you never updated.

Passwords matter just as much. The same guide says a strong password is hard to guess and hard for a brute-force attack to beat, and it suggests two-step authentication as an extra check. A WAF slows guessing, but a weak admin password still falls fast.

Cross-site scripting shows why layers help. A WAF can block known XSS payloads, and a strict Content Security Policy adds a browser-side check. The web.dev guide to strict CSP says a CSP based on nonces or hashes stops injected scripts from running even when an HTML injection flaw exists.

A plugin firewall at the origin adds another layer. Our Wordfence firewall setup guide covers a plugin that inspects traffic after it reaches WordPress, which catches what the edge rules miss.

What mistakes should you avoid?

Do not turn on every managed ruleset at once and set everything to Block without watching the events log.

Do not write a custom rule that blocks all of wp-admin without an exception for admin-ajax.php. WordPress.org's Hardening WordPress guide warns that locking down wp-admin can break the AJAX handler at wp-admin/admin-ajax.php, which many plugins need.

Do not forget the order rules run in. Custom rules run before rate limiting rules, and managed rules run last, so a Block in a custom rule means the managed rules never see that request.

Do not rely on rate limiting alone to guard the login page. Counters can lag by a few seconds, and the Free plan block lasts only 10 seconds, so pair it with a challenge rule and a login lockout at the origin.

Do not leave your cache rules fighting your security rules. Our Cloudflare cache rules guide explains how caching works at the edge, and a cached login page can hide the challenge your WAF rule should show.

Frequently asked questions

Does the Cloudflare Free plan include WAF rules?

Yes. The Free plan includes the Free Managed Ruleset, 5 custom rules, and 1 rate limiting rule, as of November 2026. The full Cloudflare Managed Ruleset and the OWASP Core Ruleset need Pro or higher, so Free plan sites get narrower coverage but still get protection against widely exploited flaws.

Will Cloudflare WAF rules block real visitors to my WordPress site?

They can, because a rule may match a normal request by mistake. That is called a false positive. Start login and admin rules on Managed Challenge instead of Block, watch the Security Events log, and add an exception or change the action for the rule that fires on real visitors.

Do I still need a WordPress security plugin if I use Cloudflare WAF rules?

Yes. The WAF works at the edge, before traffic reaches your server, while a plugin works at the origin, inside WordPress. The plugin can lock accounts after failed logins, scan files, and enforce two-step authentication. Use both layers instead of treating the WAF as a replacement for updates and strong passwords.

What should I do if a WAF rule blocks my own admin work?

Open the Security Events log and find the rule that fired. If one rule causes the problem, change its action to Managed Challenge or turn that single rule off. If only one page or one IP is affected, add an exception for that request. Do not turn off the whole managed ruleset, because that removes protection from every other page too.

Can Cloudflare WAF rules stop every WordPress attack?

No. WAF rules filter known attack patterns at the application layer, but they cannot fix a vulnerable plugin, a weak password, or an outdated WordPress install. Keep WordPress, themes, and plugins updated, use strong passwords with two-step authentication, and keep backups so you can recover if an attack still gets through.

How often should I review my Cloudflare WAF rules?

Review them right after you deploy a new rule and again after you install or update a plugin or theme, because new code can trip an old rule. Check the Security Events log for fresh blocks and false positives, and look at the WAF changelog when Cloudflare adds or changes managed rules.

Sources

  1. Concepts: Cloudflare Web Application Firewall Cloudflare Docs
  2. Managed Rules Cloudflare Docs
  3. Custom rules Cloudflare Docs
  4. Rate limiting rules Cloudflare Docs
  5. Cloudflare Managed Ruleset Cloudflare Docs
  6. Hardening WordPress WordPress Developer Resources
  7. OWASP Top 10 OWASP
  8. Mitigate cross-site scripting (XSS) with a strict Content Security Policy (CSP) web.dev

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

WPLegible editors

Researched from the primary sources listed above and checked against our editorial rules. About the site · How we test