Bot Detector

Beta and uses: Kong Gateway
This feature is currently in Beta and should not be used in a production environment.
Related Documentation
Minimum Version
Kong Gateway - 3.10
Incompatible with
on-prem

Bot Detector is a built-in Dedicated Cloud Gateway capability that identifies automated traffic using signals like user agents, request paths, and JA4 fingerprints. Unlike the IP Restriction plugin, which requires you to know the specific IPs or CIDR ranges you want to allow or deny, Bot Detector identifies bot traffic from the shape of the request itself, so you don’t need to enumerate bad actors in advance.

Bot Detector is a built-in capability, not a plugin, that you can enable on a per control plane basis for public Dedicated Cloud Gateway control planes.

Use Bot Detector to:

  • Reduce cost from automated traffic: Block traffic identified as bots before it reaches your upstream services and inflates your Dedicated Cloud Gateway usage. Requests blocked by Bot Detector aren’t counted toward your usage. Detections recorded in monitoring mode are counted normally.
  • Evaluate before you enforce: Run in monitoring mode to see what Bot Detector would have blocked, so you can build confidence in the results before switching to block mode.
  • Ensure trusted traffic isn’t blocked: Create a passthrough rule for a known partner IP, integration, or user agent so it’s never blocked.
  • Investigate why a request was flagged: Use the Detections view to see the path, IP, user agent, and matched rule behind any detection, and promote it into a passthrough rule if it’s a false positive.
  • Limit exposure while you evaluate: Enable Bot Detector on a single control plane, leave the rest untouched, and expand once you’re satisfied with the results.

How it works

Bot Detector uses it’s own built-in rules as well as any custom rules you create to detect bot traffic. The built-in rules are maintained and updated by Kong.

Kong-managed rules cover four broad categories of detection:

  • User-agent signals: Requests from known security scanners, headless browsers and automation frameworks, self-declared bots, and spoofed or malformed browser identities
  • Request-shape signals: Requests missing headers a real browser would send, or claiming to be a browser without behaving like one
  • Vulnerability probes: Requests targeting sensitive paths, admin panels, config files, and backup files
  • Injection patterns: Requests with matching SQL injection, path traversal, command injection, and encoded-payload variant patterns

Trusted crawlers, such as Googlebot, Bingbot, ClaudeBot, DuckDuckBot, and well-known uptime monitors, are allow listed.

You can create custom rules that match on a single condition (IP, path, user agent, or JA4 fingerprint). Your custom rules takes precedence over Kong-managed rules, so matching traffic is never blocked.

Bot Detector runs in one of two modes:

  • Monitoring (default): Bot Detector evaluates every request to your Dedicated Cloud Gateway control plane and records what it would have done (either block or passthrough), without affecting traffic. Use this mode to review detections and build confidence before blocking anything.
  • Block: Requests that match a block rule are rejected with a 403 response. All others passthrough.

You decide when you want to switch from monitoring to blocking after you’ve established confidence in the results in monitoring mode.

Using Bot Detector

The following are an overview of the general steps you should take to enable, monitor, and use Bot Detector:

  1. Enable it on a public Dedicated Cloud Gateway control plane.
  2. Monitor detections for any false positives or valid traffic that is marked as blocked.
  3. (Optional) Allow list IPs with the IP Restrictions plugin as a complement to Bot Detector.
  4. Create any custom rules from your observations while Bot Detector is in monitoring mode.
  5. After you’ve gained confidence in monitoring mode, switch Bot Detector to blocking mode.

Prerequisites

Enable Bot Detector

Bot Detector is enabled per control plane. Because Bot Detector is scoped to the control plane, not the organization, this allows you to enable it on a single control plane to evaluate it, leave your other control planes untouched, and expand once you’re satisfied with the results.

Assessing detections

After Bot Detector processes traffic in monitoring mode, it will populate the overview and detections dashboards with what it would have done to the traffic (passthrough or block).

Bot Detector provides two views for reviewing traffic:

  • Overview: An aggregate dashboard showing status, mode, active rules, and request totals (monitored and blocked) over a selectable time range.
  • Detections: A filterable log of every evaluated request, including the path, action taken, timestamp, IP, user agent, and matched rule. You can promote any detection directly into a passthrough rule using the action menu if it turns out to be a false positive.

Configure rules

If while you are in monitoring mode, you see traffic that is marked incorrectly as Block or Passthrough, you can create custom rules to block, monitor, or allow (passthrough) that traffic. Additionally, if there are certain IPs you know need to passthrough (for example, an IP of a partner company), you can create rules for those.

These rules match on one or more conditions (IP, path, user agent, or JA4 fingerprint) and take precedence over Kong-managed rules. You can specify multiple match types per rule, but all conditions on a rule must match for the rule to apply.

The following table describes which match types you can set and some example values:

Match type

Description

Exact match example

Regex example

IP address Matches a single client IP address. 203.0.113.5 Not supported
CIDR range Matches a range of client IP addresses in CIDR notation. 203.0.113.0/24 Not supported
JA4 Matches a client’s JA4 TLS fingerprint. t13d1516h2_8daaf6152771_02713d6af862 t13d1516h2_.*
User agent Matches the request’s User-Agent header. curl/8.7.1 (?i)(bot|crawler)
Path Matches the request path. /health ^/api/v[0-9]+/users$

Path, user agent, and JA4 conditions also have an Operator setting to choose whether the value should match exactly or by regular expression. IP address and CIDR range conditions only support exact matches.

Switching to blocking bot traffic

You can switch from monitoring to blocking mode after you’ve established confidence in the results in monitoring mode:

  • Make sure your Gateway Services, Routes, and clients are configured correctly.
  • Verify that good traffic is labelled as Passthrough and unwanted traffic is labeled as Block.

While Bot Detector is enabled, you can switch between monitoring and block mode at any time. Mode changes propagate to data planes on their next pull cycle (which can be up to five minutes). No data plane restart or redeploy is required.

Limitation

When you are configuring Bot Detector, keep the following limitations in mind:

  • Rules with same condition and priority are valid, but the order of execution will be undefined. For example, you could configure a block and a passthrough rule with the path condition and a value of /health and both rules will be valid, but neither will run.
  • Paths with / will always be passthrough. They cannot be blocked.

FAQs

No. Bot Detector is meant to handle bot traffic while WAF complements it with other security measures. For more information, see the Kong Gateway WAF capabilities.

No. Bot Detector is a complement to the IP Restriction plugin. Bot Detector can block bot traffic from the shape of the request whereas the IP Restriction plugin can be used when you know the exact IPs or CIDR ranges you want to allow list.

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!