When a WordPress site behind Cloudflare suddenly has contact forms that error out, add-to-cart buttons that spin forever, and a page builder that fails to save, the usual culprit is a WAF rule blocking /wp-admin/admin-ajax.php. Despite the path, admin-ajax.php serves public traffic — themes and plugins POST to it for logged-out visitors all day long. The fix is not to weaken the WAF across the zone: pull the exact rule ID from Security > Events, then add an exception scoped to that one rule and that one path.
What’s happening
admin-ajax.php is WordPress’s original AJAX endpoint. It lives under /wp-admin/ for historical reasons, but WordPress deliberately exempts it from the logged-in requirement so front-end features can use it: Contact Form 7 and Gravity Forms submissions, WooCommerce cart fragments, Elementor popups and form widgets, wishlist, rating, and live-search plugins. All of them POST serialized payloads to this one URL.
Two Cloudflare behaviours collide with that design. First, custom rules written to protect the admin area — expressions like “URI path starts with /wp-admin/ then block or challenge” — catch admin-ajax.php as collateral damage. Second, the WAF managed rulesets, especially the OWASP Core Ruleset, score request bodies: a form payload containing quotes, HTML fragments, or SQL-looking text can push the anomaly score over the threshold on perfectly legitimate submissions.
Challenges make it worse than blocks. An XHR or fetch request cannot render or solve a Managed Challenge, so a challenge action on this path never shows the visitor anything — the request just fails, and in the browser it looks like a dead button rather than a security page.
What to check first
- Security > Events, filtered to path
/wp-admin/admin-ajax.php, last 24 hours. Note which service fired: WAF managed rules, a custom rule, rate limiting, or Bot Fight Mode. - Whether logged-out and logged-in users are both affected — a path-based custom rule hits everyone; an OWASP score hit is payload-dependent and intermittent.
- What changed recently: OWASP enabled, paranoia level raised, a new custom rule, or Under Attack Mode toggled on.
- Plan context: on the Free plan there is no configurable managed ruleset, so the blocker is almost always your own custom rule or Bot Fight Mode. OWASP and managed-rule exceptions start at Pro.
How to verify
Probe the endpoint the way a plugin would. WordPress answers 400 with body 0 for an unknown action — that response is good news, it means the request reached PHP:
# 400 = reached WordPress. 403 plus a cf-mitigated header = Cloudflare stopped it.
curl -s -o /dev/null -D - -X POST \
-d 'action=sh_probe' \
https://www.example.com/wp-admin/admin-ajax.php | grep -iE '^HTTP/|cf-mitigated|cf-ray'
Read the result: 403 with cf-mitigated: block is a WAF block; 403 with cf-mitigated: challenge is a challenge no AJAX call can ever pass. In browser devtools, the Console shows failed XHR/fetch calls and the Network tab shows Cloudflare’s HTML interstitial where the plugin expected JSON.
Then match it in the dashboard: Security > Events, open a sample event, and record the Rule ID and the ruleset it belongs to — a Cloudflare managed rule, an OWASP rule, or the name of your own custom rule.
The fix
- Identify the exact rule from the event log. Do not guess. The event detail gives you the rule ID, the action taken, and the matched expression.
- If it is your own custom rule, tighten the expression instead of deleting the rule:
http.request.uri.path contains "/wp-admin/" and not http.request.uri.path eq "/wp-admin/admin-ajax.php". The rest of the admin area stays protected. - If it is a specific managed rule, add a WAF exception (Managed rules tab, “Add exception”) that skips only that rule ID, with the expression scoped to the admin-ajax path. Never “skip all managed rules” zone-wide.
- If it is the OWASP ruleset, prefer a path-scoped skip of the OWASP ruleset for admin-ajax.php over raising the global anomaly threshold or dropping the paranoia level — those two changes weaken inspection everywhere.
- Re-test both states — logged out and logged in — with the curl probe and a real form submission, then watch Security > Events for residual matches.
Budget note: Free includes 5 active WAF custom rules, Pro 20, Business 100. A skip implemented as a custom rule spends one of them; exceptions attached to a managed ruleset on paid plans do not.
When this fix is wrong
- No
cf-mitigatedheader and no matching event means the 403 came from the origin — ModSecurity, a security plugin, or fail2ban. Tuning Cloudflare will change nothing. - The blocked traffic is actually abuse. admin-ajax.php is a favourite flood target. If Events shows a handful of ASNs hammering one
actionvalue, you want a rate-limiting rule, not an exception. - Slow admin-ajax (timeouts, 524s) is an origin performance problem. The WAF is not involved.
Common mistakes
- Skipping all managed rules for the entire zone to fix one form.
- Allowlisting the whole
/wp-admin/path, which un-protects the actual admin. - Testing only while logged in from an office IP that has its own allow rule — you see success, visitors see 403s.
- Using a challenge action on AJAX endpoints at all; challenges are for pages a human loads.
- “Fixing” it by grey-clouding the DNS record, which removes the WAF, the CDN, and the DDoS protection in one move.
Prevention
- Write admin-protection rules with the admin-ajax carve-out from day one.
- After enabling OWASP or a new managed ruleset, review Security > Events filtered on
admin-ajax.phpand/wp-json/for a week before trusting it. - Keep a synthetic monitor that POSTs a probe action and alerts on anything other than a 400.
- Document every exception with the rule ID and the reason, and review them quarterly — see WAF managed rulesets for WordPress and Cloudflare WAF rule patterns for WordPress for the rule sets worth running, and the Cloudflare WAF docs for exception syntax.
A WAF that blocks admin-ajax.php is not “extra secure” — it is silently dropping revenue-bearing form fills and cart actions. Need Cloudflare stabilized in front of a WordPress or WooCommerce site that earns money? Stack Harbor runs that exact stack under enterprise WordPress operations — book an infrastructure consult.