Stop malicious bots while allowing legit·续

If the built-in settings do not cover your needs, create custom rules. Start by creating an exception for verified bots so they are protected before you deploy any blocking rules.

Navigate to custom rules, then create both rules:

  1. In the Cloudflare dashboard, go to Security > Security rules. Go to Security rules ↗
  2. Select Create rule > Custom rules.

First, create a verified bot exception:

  1. Enter a descriptive name in Rule name.
  2. Under When incoming requests match, select Edit expression and enter: (cf.client.bot)
  3. Under Then take action, select Skip from the Choose action dropdown. Then select All remaining custom rules.
  4. Under Place at, select First from the Select order dropdown so this rule executes before any blocking rules.
  5. Select Deploy.

This ensures verified bots (search engine crawlers, monitoring services) bypass your custom rules. If you have internal APIs, partner integrations, or monitoring tools that send automated traffic, create additional Skip rules for their IP addresses or user agents before deploying blocking rules. Review your expected automated traffic in Security Events to identify what to allowlist.

Then, create a blocking rule:

  1. Select Create rule.
  2. Enter a descriptive name in Rule name.
  3. Under When incoming requests match, select Edit expression and enter: (http.request.uri.path eq "/login" and http.request.method eq "POST")
  4. Under Then take action, select Managed Challenge from the Choose action dropdown.
  5. Under Place at, leave the Select order dropdown set to Last. This places the rule after the verified bot exception.
  6. Select Deploy.
  7. Review the results in Security Events. If the rule matches only bot traffic, edit the rule and change the action from Managed Challenge to Block.

For additional custom rule options including the visual field builder, refer to Create a custom rule in the dashboard.

If your bot traffic is concentrated from countries where you have no real users, you can combine geographic filters with the rules above. Add ip.src.country to your expression to restrict the rule to specific regions. For examples, refer to Block traffic by geographical location.

Protect high-frequency paths with rate limiting

Beyond form endpoints, bots also target checkout flows, API endpoints, and other high-value paths. Rate limiting rules cap the number of requests a single client can make to these paths within a time window.

The following example creates a rate limiting rule for a checkout endpoint. Adjust the path, rate, and action for your site.

Rate limiting options vary by plan

Available periods, actions, and counting options vary by plan. The example below uses a 1-minute period with Managed Challenge. Refer to Rate limiting rules availability for your plan's options.

  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 "/api/checkout" and http.request.method eq "POST"
  5. Under With the same characteristics, select IP.
  6. Under When rate exceeds, enter 10 requests per 1 minute.
  7. Under Then take action, select Managed Challenge.
  8. Select Deploy.
  9. Review the results in Security Events. If the rule matches only bot traffic, edit the rule and change the action to Block if needed.

For additional patterns and thresholds, refer to Rate limiting best practices.

Security Analytics rate analysis requires an Enterprise plan

Enterprise customers can use the Request rate analysis tab in Security Analytics to visualize request rate distributions and the Log action to observe rule matches without taking action. On other plans, estimate thresholds based on your expected traffic patterns. Refer to Find an appropriate rate limit for the full methodology.

Enterprise Bot Management: bot score in custom rules

Enterprise customers with Bot Management can reference the cf.bot_management.score field in custom rule expressions for granular control over bot traffic. Bot Management assigns a score from 1 to 99 to each request, where lower scores indicate more automated behavior. Refer to Bot scores and Bot Management variables for details.

Verify and tune your rules

After you deploy bot protection rules, use Security Events to verify they are working as intended and adjust thresholds based on the results.

Check Security Events

Security Events displays requests that Cloudflare security products acted on or flagged, including blocks, challenges, and flags.

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

Review the Sampled logs to inspect individual requests. Each log entry shows the action taken, the rule that triggered, the source IP, user agent, URI path, and country. Available dashboard sections vary by plan. Refer to Security Events availability for your plan's features.

Look for false positives (legitimate traffic that your rules incorrectly challenged or blocked). Common signs include:

  • Requests from known monitoring services or payment processors appearing in blocked events
  • User agents matching legitimate browsers but receiving challenges
  • High volumes of challenged requests from countries where you have real users

For rules using the Managed Challenge action, check the challenge solve rate (CSR). A low CSR likely indicates the rule is effectively filtering automated traffic rather than legitimate users.

Bot Fight Mode and Super Bot Fight Mode are aggressive by design. False positives are expected, especially in the first few days after turning them on. The key difference between the two is how you handle exceptions:

  • Bot Fight Mode (Free) cannot be bypassed with custom rule Skip actions. You can turn off Bot Fight Mode or upgrade to Super Bot Fight Mode for more control.
  • Super Bot Fight Mode (Pro and above) can be bypassed with custom rules using the Skip action, giving you more flexibility to create exceptions.

For more information on handling false positives, refer to False positives.

Adjust your rules

After reviewing Security Events, adjust your rules based on the results.

Scenario 1: Your monitoring tools or services are being blocked.

Internal monitoring tools, health check services, or partner APIs appear in blocked events. The fix depends on which feature is blocking them:

  • If Super Bot Fight Mode (Pro and above) is blocking the traffic, create a custom rule with a Skip action matching the tool IP address or user agent:
  • Go to the Security rules page. Go to Security rules ↗
  • Select Create rule > Custom rules.
  • Enter a descriptive name.
  • Under When incoming requests match, select Edit expression and enter: (ip.src eq 192.0.2.1) (replace with your tool's IP address).
  • Under Then take action, select Skip. Then select All Super Bot Fight Mode rules.
  • Select Deploy.
  • If Bot Fight Mode (Free) is blocking the traffic, turn off Bot Fight Mode or upgrade to Super Bot Fight Mode for granular exception rules.

For details on Skip action configuration, refer to Configure a rule with the Skip action.

Scenario 2: Malicious traffic is still getting through.

Bot activity appears in Security Events that your current rules do not catch. Bots that stay under rate limits or evade single-signal rules require combining multiple signals. For example, to challenge POST requests to /login that are not from verified bots:

  1. In the Cloudflare dashboard, go to Security > Security rules. Go to Security rules ↗
  2. Select Create rule > Custom rules.
  3. Enter a descriptive name.
  4. Under When incoming requests match, select Edit expression and enter:
   (http.request.uri.path eq "/login" and http.request.method eq "POST" and not cf.client.bot)
   ```

5. Under **Then take action**, select *Managed Challenge*.
6. Select **Deploy**.
7. Review the results in Security Events. If the rule matches only bot traffic, change the action to *Block*.

For more expression fields and examples, refer to [Custom rules use cases](https://developers.cloudflare.com/waf/custom-rules/use-cases/).

If bots are staying under your rate limiting thresholds, edit the rate limiting rule and reduce the request count or shorten the time window.

Note

Custom rules execute before Super Bot Fight Mode in the evaluation order. If a custom rule takes a terminating action (Block, Managed Challenge), the request does not reach Super Bot Fight Mode. Refer to [Security features interoperability](https://developers.cloudflare.com/waf/feature-interoperability/).

Enterprise Bot Management

Enterprise customers with [Bot Management](https://developers.cloudflare.com/bots/plans/bm-subscription/) can tune rules using the `cf.bot_management.score` field for more granular control. Refer to [Bot Management variables](https://developers.cloudflare.com/bots/reference/bot-management-variables/) for available fields.

## Related resources

**Bots**

- [Bot Fight Mode](https://developers.cloudflare.com/bots/get-started/bot-fight-mode/) — Baseline bot protection available on all plans
- [Super Bot Fight Mode](https://developers.cloudflare.com/bots/get-started/super-bot-fight-mode/) — Granular bot controls for Pro, Business, and Enterprise plans
- [Enterprise Bot Management](https://developers.cloudflare.com/bots/plans/bm-subscription/) — Machine learning-based bot scoring and behavioral analysis
- [Bot Analytics](https://developers.cloudflare.com/bots/bot-analytics/) — Monitor bot traffic patterns across your domain

**Application Security**

- [Custom rules](https://developers.cloudflare.com/waf/custom-rules/) — Write targeted rules using traffic signals and bot scores
- [Rate limiting rules](https://developers.cloudflare.com/waf/rate-limiting-rules/) — Control request volume to protect endpoints from abuse
- [Security Events](https://developers.cloudflare.com/waf/analytics/security-events/) — Review and investigate mitigated requests

**Turnstile**

- [Turnstile](https://developers.cloudflare.com/turnstile/) — Free, privacy-preserving challenge for forms and user interactions

Was this helpful?

YesNo

## On this page

[![](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2NiIgaGVpZ2h0PSIzMCIgZmlsbD0ibm9uZSIgdmlld0JveD0iMCAwIDY2IDMwIj48ZyBjbGlwLXBhdGg9InVybCgjY2xpcDBfNzQ2XzIpIj48cGF0aCBmaWxsPSIjZmY5OTEwIiBkPSJNNTMuMTIgMTMuMTI1YzYuOTk3IDAgMTIuNjY4IDUuNzA4IDEyLjY2OCAxMi43NSAwIDEuMjU1LS4xOCAyLjQ2OC0uNTE2IDMuNjE0YS43Mi43MiAwIDAgMS0uNjk0LjUxMUg0Ni45NTNhLjM3NS4zNzUgMCAwIDEtLjM0OC0uNTFsLjMzNy0uODgyYzEuMDc2LTIuODMzIDQuMTQ2LTUuMTU0IDYuOTg3LTUuMjlsNS4zODQtLjI3N2EuNTQzLjU0MyAwIDAgMCAuNTE0LS41NDQuNTQzLjU0MyAwIDAgMC0uNTEtL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c3YS41NDMuNTQzIDAgMCAwIC41MTQtLjU0NC41NDMuNTQzIDAgMCAwLS41MS0uNTQ0bC01LjA1Ni0uMjk5Yy0yLjcxOC0uMTQtNC4wNDYtMi41Ni0zLjMxNS01LjA4MWwuODQyLTIuOTAyYS43Mi43MiAwIDAgMSAuNjQ2LS41MjdxLjM0LS4wMi42ODYtLjAxOSIvPjxwYXRoIGZpbGw9IiNmZjVmMDgiIGQ9Ik0zNS42MDkgMGM3LjI5NSAwIDEzLjQyNCA1LjAyNSAxNS4xNTcgMTEuODI0LjA3My4yODUuMDUuNTg2LS4wNTQuODYybC0xLjM4OCAzLjY3N2MtMS4wNzYgMi44MzMtMy44NDIgNS4yOS02Ljk3IDUuMjlsLTI0LjEwNS4yNzhhLjUzMy41MzMgMCAwIDAtLjUyNS41MzVjMCAuMjkzLjIzNC41MzEuNTI0LjUzNWwyMy43NjUuMzE2YzIuNzI0IDAgNC4wNDYgMi41NiAzLjMxNiA1LjA4MWwtLjMwNyAxLjA2MWEuNzUuNzUgMCAwIDEtLjcxNi41NDFILjk2NGEuNzEuNzEgMCAwIDEtLjcxOC0uNjQ2IDExIDExIDAgMCAxLS4wMzQtLjg1NGMwLTUuNDc2IDQuMTY2LTkuOTczIDkuNDgyLTEwLjQ1NmE3LjIgNy4yIDAgMCAxLS4xNjctMS41NDRjMC0zLjkzNSAzLjE3LTcuMTI1IDcuMDgtNy4xMjUgMS41NTUgMCAyLjk5NC41MDYgNC4xNjIgMS4zNjJDMjIuODQ5IDQuNDk3IDI4LjcwNyAwIDM1LjYwOSAwIi8+PC9nPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDBfNzQ2XzIiPjxwYXRoIGZpbGw9IiNmZmYiIGQ9Ik0wIDBoNjZ2MzBIMHoiLz48L2NsaXBQYXRoPjwvZGVmcz48L3N2Zz4=)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/use-cases/solutions/stop-malicious-bots/#page","headline":"Stop malicious bots while allowing legitimate traffic (Free, Pro, and Business)","description":"Block malicious bots while allowing legitimate traffic using Bot Fight Mode, Turnstile, custom rules, and rate limiting on Free, Pro, and Business plans.","url":"https://developers.cloudflare.com/use-cases/solutions/stop-malicious-bots/","inLanguage":"en","image":"https://developers.cloudflare.com/use-cases/solutions/stop-malicious-bots/og.png?v=15ebc9aabe891469","dateModified":"2026-08-25","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: Protect web applications and APIs with Cloudflare Application security (WAF), DDoS protection, bot security, API Shield, and client-side security. title: Application security image: https://developers.cloudflare.com/use-cases/application-security/og.png?v=ede9b04f431cae10


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/use-cases/llms.txt
Use this file to discover all available pages before exploring further.