r/CloudFlare • u/CodingDragons • 2h ago
Discussion Building a Worker to Auto-Detect and Block Bot Attacks on a Woo Site
We see a lot of bots hitting our clients' sites, so I got to thinking, what about setting up a CF Worker to automate things? The one site I want to do this on is a Woo site on Kinsta and they have their own Cloudflare Pro. This site gets hit constantly and I'm tired of playing whack-a-mole by hand. Over the last few months we've dealt with:
- Card testing on checkout / Store API
- SQLi scans on search
- Spam account registrations and comment/review spam
- Crawlers hammering faceted filters (filter_, min_price, etc.)
- A bot using the host's temp domain to bypass CF entirely (since closed)
Today, twice in 12 hours, a PDP flood from ~900 rotating residential IPs using Google Shopping srsltid params with a spoofed same-site referrer. PDPs aren't cached (client needs instant stock), so it maxed out PHP and took the site down
Current setup is 12/20 custom rules and 2/2 rate limit rules (maxed on Pro). I have rules for card testing, SQLi, XML-RPC, filter crawling, ASN/VPN challenges on checkout, AI crawlers, and a catch-all bot block rule. Can't use Super Bot Fight Mode because it breaks ShipStation and other webhooks/API traffic, even with allow rules.
Problem is every new attack means me finding it in the logs after the fact and hand-writing a new condition.
My Plan is a Worker on a 5 min Cron that
- Pulls the last 5 min of traffic from the GraphQL analytics API
- Looks for patterns across the whole site, not just one attack type: request spikes by ASN, UA, path, query pattern, referrer, POSTs to checkout/login/register, etc.
- When something crosses a threshold, writes it into the existing catch-all block rule via the Rulesets API (no new rules, no IPs since they rotate)
- Logs each entry in KV with an expiry so it drops out after X days and doesn't block real customers forever
- Never touches verified bots, payment/shipping webhooks or /wp-json integrations
- Pings me when it adds or removes something
Questions
- Is GraphQL analytics on Pro enough for this or will I hit limits on breakdowns/lookback?
- Better signals than ASN/UA/path that are available on Pro? (I know JA4 is Bot Management only)
- Anything built into CF I'm overlooking that would do this without a Worker?
- Anyone already doing something like this, and what bit you?
Am I missing anything here? Solid?

