Stop malicious bots while allowing legitimate traffic (Free, Pro, and Business)

Last updated Aug 25, 2026 The right defense against malicious bot traffic depends on the traffic patterns on your site and your plan. This guide covers a layered approach using Cloudflare Bots, Cloudflare Application Security (also known as Web Application Firewall or WAF), and Turnstile, from baseline protection to targeted custom rules. The core workflow uses features on Free, Pro, and Business plans, with callouts for Enterprise options.

Note

Most procedures in this guide are configured per domain or zone. Select your domain in the Cloudflare dashboard before starting. Turnstile is the exception: widgets are configured at the account level.

Review your bot traffic

Before you change any bot settings, review your traffic data to understand what bots are doing on your site.

Find your bot analytics

Bot analytics show you how much of your traffic is automated, which pages bots target, and how Cloudflare scores each request.

Bot Analytics requires a Business plan or above

Bot score distribution data and detailed bot analytics are available on Business and Enterprise plans. Free and Pro plan users can review basic security metrics through Security Events. For full bot analytics capabilities, refer to Bot Analytics.

  1. In the Cloudflare dashboard, go to the Analytics page. Go to Analytics ↗
  2. Select the Bot analysis tab.

Review the following:

  • Bot score distribution chart: Scores closer to 1 indicate automated traffic. Scores closer to 99 indicate human traffic.
  • Top requested paths: Which endpoints receive the most bot traffic. Login pages, API endpoints, and checkout flows are common targets.
  • Traffic patterns: Sudden spikes in low-score traffic, specific user agents appearing at high volume, or geographic concentration of requests can indicate bot activity worth investigating.

Understand bot categories

Cloudflare classifies bot traffic into categories based on bot scores and verification status:

  • Verified bots: Crawlers and services that Cloudflare has confirmed as legitimate, such as Googlebot, Bingbot, and uptime monitors. Cloudflare maintains a verified bot list with strict requirements.
  • Automated (score 1): Cloudflare is quite certain the request is automated.
  • Likely automated (scores 2-29): Probably a bot. This category and Automated are the primary targets for security rules, including scrapers, credential stuffing tools, and spam submitters.
  • Likely human (scores 30-99): These requests appear to come from real users. Do not challenge or block this traffic.

Block automated traffic with Bot Fight Mode

Bot Fight Mode identifies requests that match known bot patterns and issues a computational challenge. It reduces automated traffic across your entire site without requiring you to write any rules.

What Bot Fight Mode does

Bot Fight Mode is included with Free plans. When enabled, it:

  • Identifies traffic matching patterns of known bots
  • Issues computationally expensive challenges in response to these bots
  • Protects entire domains without endpoint restrictions
  • Cannot be customized, adjusted, or reconfigured via custom rules
  • Cannot be bypassed with custom rule Skip actions. If Bot Fight Mode challenges a request you want to allow, you can turn off Bot Fight Mode or upgrade to Super Bot Fight Mode for more granular control.

For more details, refer to Bot Fight Mode considerations.

Turn on Bot Fight Mode (Free plan)

  1. In the Cloudflare dashboard, go to the Security Settings page. Go to Settings ↗
  2. Filter by Bot traffic.
  3. Go to Bot fight mode.
  4. Turn Bot fight mode on.

Enable Super Bot Fight Mode (Pro, Business, and Enterprise)

Super Bot Fight Mode adds verified bot allowlisting, per-category actions, static resource protection, and JavaScript detections.

Note

If you are upgrading from Bot Fight Mode to Super Bot Fight Mode, go to Security > Settings, filter by Bot traffic, and turn Bot fight mode off.

  1. In the Cloudflare dashboard, go to the Security Settings page. Go to Settings ↗
  2. Filter by Bot traffic.
  3. Go to Super Bot fight mode.
  4. Turn Super Bot fight mode on.
  5. Choose how your domain should respond to various types of traffic by selecting the associated edit icon:
  6. For more details on verified bots, refer to Verified Bots.
  7. For more details on supported file types, refer to Static resource protection.
  8. For more details on invisible code injection, refer to JavaScript detections.
  9. For more details on WordPress optimization, refer to Super Bot Fight Mode for WordPress.

Plan availability

Super Bot Fight Mode is available on Pro, Business, and Enterprise plans. Free plan users can use Bot Fight Mode for baseline protection. Enterprise customers who need machine learning-based bot scoring and custom allow/block rules can add Bot Management.

Caution

If your organization uses Cloudflare Tunnel, keep Definitely Automated set to Allow in Super Bot Fight Mode. Otherwise, tunnels might fail with a websocket: bad handshake error.

Protect forms from automated abuse

Turnstile and Application Security rate limiting rules protect form endpoints in different ways and work best together.

Turnstile versus rate limiting

Turnstile challenges suspected bots before they can submit a form (login, signup, contact, or checkout), without showing visitors a CAPTCHA. It can be embedded into any website without sending traffic through Cloudflare. Use Turnstile when you need to challenge automated form submissions.

Rate limiting allows you to define rate limits for requests matching an expression and the action to perform when those limits are reached. Use rate limiting to protect endpoints from abuse, such as brute-force attacks on a login page or excessive API calls from a single client.

Both together provide the strongest coverage. Turnstile challenges automated submissions at the form level. Rate limiting catches high-volume attacks that bypass or do not encounter the form, such as direct POST requests to the endpoint that skip the client-side widget.

Add Turnstile to a form

Adding Turnstile involves three steps: create a widget, add the client-side snippet, and validate the token on your server.

1. Create a Turnstile widget

Turnstile is configured at the account level.

  1. In the Cloudflare dashboard, go to the Turnstile page. Go to Turnstile ↗
  2. Select Add widget.
  3. Fill out the required information:
  4. Widget name: A descriptive name for your widget.
  5. Hostname management: Domains where the widget will be used.
  6. Widget mode: Choose from Managed, Non-Interactive, or Invisible.
  7. (Optional) Configure Pre-clearance support for single-page applications.
  8. Select Create to save your widget.
  9. Copy your sitekey and secret key, and store the secret key securely.

You need both the sitekey and secret key in the following steps.

2. Add the client-side snippet

Add the Turnstile script and widget container to your form HTML:

<script
    src="https://challenges.cloudflare.com/turnstile/v0/api.js"
    async
    defer
></script>

<form action="/submit" method="POST">
    <!-- Your existing form fields -->
    <div class="cf-turnstile" data-sitekey="<YOUR_SITE_KEY>"></div>
    <button type="submit">Submit</button>
</form>

Replace <YOUR_SITE_KEY> with the sitekey from the previous step. The widget renders inside the div and produces a token when the visitor passes the challenge.

3. Validate the token on your server

Before processing the form submission, send the token to the Turnstile siteverify endpoint to confirm the visitor passed the challenge:

curl https://challenges.cloudflare.com/turnstile/v0/siteverify \
  --header "Content-Type: application/json" \
  --data '{
  "secret": "<YOUR_SECRET_KEY>",
  "response": "<TURNSTILE_RESPONSE_TOKEN>"
}'

Replace <YOUR_SECRET_KEY> with your secret key and <TURNSTILE_RESPONSE_TOKEN> with the cf-turnstile-response value from the form submission. The endpoint returns a JSON object with a success field. Only process the form submission if success is true.

For complete integration details, refer to Turnstile get started.

Limit request volume on form endpoints with rate limiting

For login endpoints, a tiered rate limiting approach works well alongside Turnstile. The following example from the Rate limiting best practices shows two rules that escalate the response based on the volume of failed attempts. Adjust the thresholds for your site's traffic patterns.

Tiered rate limiting rules require a Business plan or above

Rules that use counting expressions with response codes (such as counting only 401 and 403 responses) require a Business plan or above. On Free and Pro plans, you can create simpler rate limiting rules with IP-based counting. Refer to Rate limiting rules for plan availability details.

Short-window rule: Challenge an IP that sends too many failed login requests in a short window.

  1. In the Cloudflare dashboard, go to Security > Security rules. Go to Security rules ↗
  2. Select Create rule > Rate limiting rules.
  3. Enter a descriptive name in Rule name.
  4. Under If incoming requests match, select Edit expression and enter: http.request.uri.path eq "/login" and http.request.method eq "POST"
  5. Under With the same characteristics, select IP.
  6. Enable Use custom counting expression and enter: http.request.uri.path eq "/login" and http.request.method eq "POST" and http.response.code in {401 403}
  7. Under When rate exceeds, enter 4 requests per 1 minute.
  8. Under Then take action, select Managed Challenge.
  9. Select Deploy.

Long-window rule: Block an IP that accumulates failed login attempts over a longer period.

  1. In the Cloudflare dashboard, go to Security > Security rules. Go to Security rules ↗
  2. Select Create rule > Rate limiting rules.
  3. Enter a descriptive name in Rule name.
  4. Under If incoming requests match, select Edit expression and enter: http.request.uri.path eq "/login" and http.request.method eq "POST"
  5. Under With the same characteristics, select IP.
  6. Enable Use custom counting expression and enter: http.request.uri.path eq "/login" and http.request.method eq "POST" and http.response.code in {401 403}
  7. Under When rate exceeds, enter 20 requests per 1 hour.
  8. Under Then take action, select Block with a duration of 1 day.
  9. Select Deploy.

This pattern uses a counting expression that only counts POST requests returning authentication failure codes. Legitimate users who log in successfully on the first attempt never trigger the rule. Review the results in Security Events to confirm the thresholds are not catching legitimate users.

For the full tiered credential stuffing example with three rules, refer to Rate limiting best practices.

Target bot patterns with custom rules and rate limiting

Application Security custom rules and rate limiting rules let you target specific traffic patterns that built-in bot protection does not catch. Cloudflare separates detection (scoring traffic) from mitigation (acting on those scores). You write rules that reference detection signals to decide what action to take.

Block requests with missing or suspicious headers

Legitimate browsers typically send headers like User-Agent, Accept, and Accept-Language. Many bots omit these headers or send non-browser values. A custom rule targeting requests with empty or suspicious headers catches bots that evade score-based detection.

Before creating custom rules, review the built-in bot settings in Security > Settings (filter by Bot traffic). These settings handle common scenarios like blocking AI crawlers, challenging automated traffic, and allowing verified bots without requiring you to write expressions. For the full list of built-in settings, refer to Challenge bad bots.

Plan availability

Built-in bot settings are part of Super Bot Fight Mode (Pro and above). On Free plans, only the Bot Fight Mode toggle is available. Custom rules are available on all plans, with the number of rules increasing on higher plans.