Automation Can Be Helpful or Abusive
At 09:14 on a Tuesday, a small ticketing site's contact form receives 300 submissions in ten minutes, all advertising "SEO services." At 09:20, Googlebot recrawls the event pages, and a partner museum's availability checker polls the site as it has for a year. "Block the bots" would break both while leaving the spammer free to change addresses.
The useful question is not "bot or human?" It is "which control answers which question for this endpoint?" Four terms make that precise:
- An automated client is any program that sends HTTP requests: scripts, crawlers, scrapers, integration clients. Automation is not abuse; cost and intent are.
- Bot detection classifies a request from user agent, IP reputation, autonomous system, TLS fingerprint, and request patterns. It returns a category or score, is probabilistic, and is usually silent.
- Human verification asks for evidence that a person is present for one action. Turnstile runs a browser challenge and issues a short-lived token; passing proves a challenge was solved, not that later requests are trustworthy.
- Rate limiting counts requests per identity over a window and acts at a threshold. It is deterministic and indifferent to personhood.
Think of a mailroom with three controls: a sender-reputation list, signature-on-delivery for registered parcels, and a parcels-per-hour cap. The list goes stale, the signature inconveniences people, and the cap punishes a shared mailroom. Each fails differently, so a serious site uses more than one.
The mental model is three gates. Detection asks who is calling; throttling asks how much this identity has sent; verification asks whether a human completed a challenge for this action. Figure 1 shows the branches: a verified crawler may be allowed but still counted, a suspicious client may be challenged or blocked, and a surviving submission still needs server-side verification.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
R["POST /submit with form data"] --> B{"Edge bot signals"}
B -->|"verified crawler"| A["Allow, still count"]
B -->|"likely automated"| C["Challenge or block"]
B -->|"human or unclear"| L{"Rate counter for this identity"}
A --> L
L -->|"over limit"| Q["429 or challenge"]
L -->|"under limit"| O["Forward to origin"]
O --> V{"Origin calls Siteverify"}
V -->|"invalid, expired, or replayed"| X["400: request a fresh token"]
V -->|"valid, hostname and action match"| S["Process the submission"]
classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
class B,L,O,V,X primary;
class R,Q,S secondary;
class A ok;
class C danger;
Figure 2 redraws the path as boundaries. The browser holds a public site key and receives a token; the edge holds detection signals and counters; the origin holds the secret and decides. The token crosses the boundary; trust does not. Only your server may call Siteverify, because only your server may hold the secret.
Cloudflare's bot products and rate limiting run at the edge. Turnstile is separable: it works without other Cloudflare services, so an unproxied origin can use it, and that origin still owns the verification decision.
Bot Signals and Plan-Dependent Controls
Back to the ticket site. The spam shares three cloud ASNs, uses Python and curl user agents, sends no cookies, and arrives at near-identical intervals. The partner's checker also runs in one of those ASNs, but sends a stable user agent and requests a specific JSON path. Googlebot presents a verifiable identity. Three clients, three decisions.
Cloudflare's bot controls form a ladder. Bot Fight Mode is the Free-plan setting: it detects simple bots from cloud hosting and headless browsers and issues a computationally expensive challenge, across all domain traffic. It is not a rule builder. Super Bot Fight Mode (Pro, Business, Enterprise without Bot Management) adds customer-chosen allow, block, or challenge actions and, on Business, detects many sophisticated bots. On Pro, "likely automated" still requires Bot Management, and analytics are limited to a Bot Report. Bot Management is the Enterprise subscription exposing bot score, verified-bot status, and fingerprint fields to custom rules and rate limiting.
Turnstile sits outside that ladder: it verifies a human at one interaction, works on Free and Enterprise Turnstile plans, and needs no proxy. Rate limiting is on every plan, but its shape changes: Free allows one rule, a ten-second period, and IP only; Pro allows two rules and periods up to one minute; Business allows five rules, NAT-aware identity, and ten-minute windows; Enterprise adds headers, cookies, ASN, country, path, and JA3/JA4.
| Control | Question it answers | Enforced at | Availability (verified 2026-11-04) | Characteristic failure |
|---|---|---|---|---|
| Bot Fight Mode | Simple automated client? | Edge, domain-wide | Free | Challenges APIs and useful automation; no per-path tuning |
| Super Bot Fight Mode | Definitely automated, and what action? | Edge, domain-wide | Pro, Business, Enterprise without Bot Management | Coarse; "likely automated" needs Bot Management |
| Bot Management | Bot score and fingerprint? | Edge, per rule | Enterprise subscription | Probabilistic; higher cost and tuning |
| Turnstile | Human present for this action? | Widget plus your server | Free and Enterprise; no proxy required | Only protects actions that call Siteverify |
| Rate limiting | How much from one identity? | Edge counters | All plans; shape varies | Shared identities; per-colo counters |
For the ticket site, the split is unglamorous. Let Googlebot through as a verified bot but keep counting it. Give the partner an API path and an API-key rate limit, not a browser challenge. Put Turnstile on the contact form, where a human is present. Add a rate limit per IP and path, challenging document navigations and returning JSON 429 to the API. The table maps which control fails in which way.
Figure 3 shows the Turnstile half as a sequence, including a failed challenge, an expired token, and a spent token. The dangerous design is a flow where the second half never happens.
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
sequenceDiagram
autonumber
participant B as Browser
participant T as Turnstile widget
participant C as Cloudflare edge
participant O as Your origin
B->>T: Load widget with sitekey and action=contact
T->>C: Collect browser signals
alt Challenge succeeds
C-->>T: Single-use token, valid 300 seconds
T-->>B: callback(token)
B->>O: POST /api/contact with token
O->>C: siteverify(secret, token, remoteip)
alt Token valid and unused
C-->>O: success true, hostname, action
O-->>B: 200 accepted
else Expired, replayed, or mismatched
C-->>O: success false with error-codes
O-->>B: 400, fresh widget
end
else Challenge fails or times out
C-->>T: error or timeout
T-->>B: error-callback, no token
Note over B: Stop and do not POST
end
The code widget makes the boundary concrete. The markup panel is a complete page using a documented always-pass test site key, so it runs locally without an account. The TypeScript panel is the only place the secret appears and rejects a token unless the configured hostname and action match.
A 200 is not a pass
A rejected token still arrives as HTTP 200. Read the JSON verdict, not the HTTP status: a handler that checks only the response code accepts every forged token. A token is also bound to its widget, so compare the returned hostname and action before trusting it, and reuse one idempotency_key across retries.
Turnstile Tokens Must Be Verified on the Server
A Turnstile token is a claim that a challenge was completed, not a capability or proof of good intent. Anyone can POST to your form endpoint with any string in the cf-turnstile-response field. If the handler accepts the field's presence as evidence, the widget is decoration: the spammer never loads the page, and analytics show zero failed challenges because none were attempted.
The verification call is strict. Your server posts the widget secret and a token that is at most 2,048 characters, valid for 300 seconds, and single-use. The request is a plain form post; a rejection looks like this.
Parse the verdict, not the status. Compare the returned host and action with what the widget was rendered for. A second validation of the same token returns timeout-or-duplicate, and the endpoint always answers HTTP 200 even when it rejects the token.
Record the timestamp; distrust custom data. The challenge timestamp spots stale tokens, and custom data is correlation only, never trusted content.
Separate user errors from deployment faults. An expired or replayed token needs a fresh challenge; a bad secret should page someone.
The secret is the whole boundary. Keep it in an environment variable or secret binding, never in markup, a mobile binary, or a public build artifact. If it leaks into client code that trusts the response, an attacker can report success without your server seeing a verdict; rotate it. The site key is public and is not a credential.
A green widget is not a verdict
A green widget and a firing callback mean only that the browser obtained a token. They are not evidence that the visitor passed: anyone can POST a string directly to your endpoint. A submission is protected only after your server calls Siteverify, sees success: true, and confirms the token's hostname and action.
Verification has a user-facing half. Managed Challenges let Cloudflare choose the challenge from browser signals and are the recommended default; most people pass without a puzzle. Non-interactive challenges run JavaScript and usually finish within five seconds. Interactive challenges ask for a click and should be a last resort. Full-page challenges return HTML, so they break fetch and XHR from single-page apps; Turnstile pre-clearance issues a clearance cookie so API calls can proceed.
Accessibility is part of the threat model. Turnstile's Free and Enterprise plans document WCAG 2.2 AAA compliance, and the widget supports auto theme and language, tabindex, and timeout, unsupported-browser, and error callbacks. Never challenge the endpoint that serves the challenge, provide a human contact path, and avoid repeating a challenge: a loop is indistinguishable from a false positive, and both erode trust.
Rate Limits Need an Identity and an Explicit Failure Policy
A rate limit is two decisions disguised as one number. Identity: which requests share a counter? Policy: what happens at the threshold, for how long, and what does the client see? A limit without an identity is a site-wide outage waiting for a busy hour. An identity without a policy blocks the wrong people and teaches the right ones nothing.
Cloudflare keeps a counter per unique combination of characteristics, and every rule implicitly includes the data center ID. Counters are not global: the same IP in two data centers occupies two buckets, so a distributed client can exceed the nominal limit locally. Updates can lag by seconds, so excess requests may reach the origin first.
Identity is a tradeoff, not a setting. Every characteristic changes who shares a counter.
| Identity | Good for | Characteristic failure |
|---|---|---|
| IP address | Cheap default for anonymous traffic | Office, carrier NAT, and privacy proxies share one bucket; IPv6 rotation multiplies identities |
| IP with NAT support | Households and offices behind one address | Cookie-less visitors still share a bucket |
| API-key header | Machine clients and integrations | Missing headers collapse into one bucket; add a length check |
| Cookie or JWT claim | Authenticated users | Needs origin validation; forged values create bogus buckets |
| Path or host | Scoping a rule without identifying a person | Does not separate users at all |
The counting expression is where rules go wrong. By default it equals the match expression; a custom expression does not extend the match, so repeat the match inside it. Response-based counting happens after the origin replies and skips cached content, which makes it right for failed logins and wrong for a static asset.
The rule below turns the lab's contact-form limit into Terraform:
Block returns 429 by default, with an optional 400–499 status and a body up to 30 KB. Challenge actions return Managed, JavaScript, or Interactive challenges; on Free, Pro, and Business they always throttle, while Enterprise can set a mitigation timeout. A fixed block stops the abuser and everyone sharing the identity. Throttling lets requests through below the limit, but a client that cannot solve the challenge retries.
A challenge loop is a false positive you built
An XHR is challenged, expects JSON, receives HTML, throws, and retries; the counter is still over, so it is challenged again. Separate document and API paths, return JSON 429 to machines, enable pre-clearance for SPAs, and never challenge the challenge endpoint.
Figure 4 shows the other failure: identity choice changes who gets caught.
Shared offices and mobile carriers are the classic false positive, but probes, webhooks, pagination bursts, and accessibility tools also look abusive under one identity. Combine characteristics, raise thresholds for authenticated traffic, and challenge browsers before blocking. Excluding verified bots protects SEO but gives crawlers a free path.
AI Crawl Control is a separate content policy, available on all plans. It shows which AI services request your content, with per-crawler allow or block policies, robots.txt tracking, and optional pay-per-crawl in private beta. Free uses user agents; paid plans add Bot Management detection IDs. A crawler can spoof a user agent or ignore robots.txt, so identification is not compliance, and enforcement covers only Cloudflare traffic.
Protect a Test Form and Its Submission API
Protect a Test Form and Its Submission API
Execution status: design-only; the form and edge rule were not deployed. The Siteverify test-key responses in the final section were executed separately on 2026-11-04.
Prerequisites. Node.js 22+, a terminal, and curl. Part A needs no Cloudflare account because Turnstile publishes test keys for localhost. Part B needs a zone on any plan; Free allows one rate limiting rule.
Minimal setup. Run a local Node server that serves the markup panel and accepts the form post. Production must also pin the expected action; test keys return none.
| Setting | Value | Why |
|---|---|---|
| Server | server.mjs on http://localhost:8787 | Serves the form and the submission API |
| Site key | 1x00000000000000000000AA | Always-pass test key; renders without an account |
| Secret | 1x0000000000000000000000000000000AA | Always-pass test secret |
| Hostname | example.com, or the hostname in the verdict | Must match what Siteverify reports |
| Action | EXPECTED_ACTION in production | A token minted for another form must not pass |
| Rate rule | /api/contact, IP, five per ten seconds, block 429 | Part B only |
- Open the page and submit. Expected: the widget renders, and a 200 requires the token field.
- Keep the passing site key and set the secret to
2x0000000000000000000000000000000AA. Expected:invalid-input-response. - Keep the passing key and set the secret to
3x0000000000000000000000000000000AA. Expected:timeout-or-duplicate, the documented replay behavior. - Remove
cf-turnstile-responsefrom the app POST. Expected: the local guard rejects it asmissing-or-oversized-token; a direct Siteverify call with no token returnsmissing-input-response. - Set
EXPECTED_ACTION=loginwhile the widget renderscontact. Expected:hostname-or-action-mismatchdespite a successful Siteverify. - Set a malformed secret such as
0x0000000000000000000000000000000ZZ. Expected:invalid-input-secret, a deployment fault. - For part B, create a rule on
/api/contactwith IP as the characteristic, five requests per ten seconds, Block, status 429, JSON body. Send six requests in ten seconds. Expected: the sixth returns 429; counters are per data center.
Status is not the verdict. HTTP 200 with a false payload means the handler read the status instead of the JSON. A 400 with invalid-input-secret means the secret does not match the widget.
Some failures are expected. A widget that never renders on file:// needs HTTP or HTTPS, not a file path.
Read the blast radius. A loop on fetch means a challenge reached an API path. A 429 for a whole office means the identity was IP-only.
Cost dimensions. Part A is USD 0; Turnstile's Free plan documents unlimited challenges. Part B needs a domain, typically USD 10–15 per year, and Free includes one rule. No paid feature is required.
Cleanup. Stop the server, remove the environment variables, delete the test page and rate limiting rule, and delete the zone if it existed only for this exercise. Rotate any real secret that touched the test environment; deleting the widget is not enough once a secret is exposed.
Reject Invalid Tokens and Exercise Bounded Rate Tests
The Siteverify behavior below was observed on 2026-11-04 with no zone, production widget, or production secret. Requests were plain HTTPS form posts to https://challenges.cloudflare.com/turnstile/v0/siteverify; no SDK or CLI version applies.
Pass evidence.
- The passing test secret with the documented dummy token returned HTTP 200,
success: true,hostname: "example.com", andmetadata.result_with_testing_key: true. - The always-fail and duplicate-simulation secrets returned HTTP 200 with
invalid-input-responseandtimeout-or-duplicate. - A missing response field returned HTTP 200 with
missing-input-response. - A malformed secret returned HTTP 400 with
invalid-input-secret.
Test keys verify wiring, not release behavior
The always-pass test secret accepted an arbitrary string, not only the documented dummy token. That is what "always passes" means: in production it would accept every forged token.
These designs accept forged tokens
A form that trusts the response field is unverified. So is a handler that logs only the client callback, treats HTTP 200 as success without reading the verdict, accepts one token twice, or accepts a token whose action belongs to another form. On the rate-limit side, a rule that never fires because the header is absent, a 429 for a whole office, and a challenge-page parse error are design faults.
Self-check.
Why can't the client callback be the security boundary? It is a browser event, and an attacker needs no browser. Only the server's Siteverify call, with a secret the client never sees, is evidence.
Siteverify returns success, but action is newsletter while the endpoint is an admin login. Do you accept? No. A token is bound to its widget and action; accepting it lets a low-value form mint credentials for a high-value one.
A Free-plan rule allows 100 requests per minute per IP, and an office of 40 shares one address. What happens? One counter serves everyone, so aggregate browsing can trip the limit. Free offers only IP; raise the threshold, challenge instead of block, or upgrade for NAT-aware identity.
Siteverify times out. Fail open or closed? Per endpoint. Login, payment, and password reset should fail closed with a 503 and an alert. A low-risk form may fail open only with a compensating rate limit and a reviewed exception.
Unresolved limitations. No hosted zone, production widget, or paid plan was exercised, so no challenge pass rate, false-positive rate, mitigation latency, or counter behavior was measured. Plan matrices, challenge actions, widget limits, and AI Crawl Control availability were read from documentation dated April–November 2026 and can change. Bot scores are not observable on Free, and deeper AI Crawl Control identification depends on Bot Management.
References (verified 2026-11-04):
- Cloudflare Bots: https://developers.cloudflare.com/bots/
- Bot plans: https://developers.cloudflare.com/bots/plans/
- Bot Fight Mode (Free): https://developers.cloudflare.com/bots/plans/free/
- Super Bot Fight Mode (Pro): https://developers.cloudflare.com/bots/plans/pro/
- Super Bot Fight Mode (Business and Enterprise): https://developers.cloudflare.com/bots/plans/biz-and-ent/
- Turnstile overview: https://developers.cloudflare.com/turnstile/
- Server-side validation and error codes: https://developers.cloudflare.com/turnstile/get-started/server-side-validation/
- Client-side rendering: https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/
- Widget configurations: https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/widget-configurations/
- Turnstile test keys: https://developers.cloudflare.com/turnstile/troubleshooting/testing/
- Turnstile plans and widget limits: https://developers.cloudflare.com/turnstile/plans/
- Challenge types: https://developers.cloudflare.com/cloudflare-challenges/challenge-types/
- Interstitial challenge pages and pre-clearance: https://developers.cloudflare.com/cloudflare-challenges/challenge-types/challenge-pages/
- Rate limiting rules and availability: https://developers.cloudflare.com/waf/rate-limiting-rules/
- Rate limiting parameters and actions: https://developers.cloudflare.com/waf/rate-limiting-rules/parameters/
- Request rate calculation: https://developers.cloudflare.com/waf/rate-limiting-rules/request-rate/
- AI Crawl Control: https://developers.cloudflare.com/ai-crawl-control/
- Manage AI crawlers: https://developers.cloudflare.com/ai-crawl-control/features/manage-ai-crawlers/
Next in the Series
In Protect APIs and Third-Party Browser Code, we'll explore Connect API validation, identity, script monitoring, and CSP.