Bot detection
Recognize the bots visiting your application, let the ones you want through and block the others.
Bot detection recognizes more than 1,400 known bots: search engines, AI crawlers, scrapers, vulnerability scanners, SEO tools, feed readers, webhooks, HTTP libraries… Human visitors are not affected.
A bot that claims to be Googlebot, Bingbot, GPTBot, another major search engine or AI crawler, or the link-preview bot of Facebook, X, LinkedIn or Telegram is verified: if it does not really come from the network it claims, it is an impostor and is blocked. Other bots cannot be verified (see the table below). A request without a User-Agent is treated as a bot (a browser always sends one).
How a bot's identity is verified
| Bots | Verification |
|---|---|
| Googlebot, Bingbot, Applebot, DuckDuckBot, GPTBot, ChatGPT-User, OAI-SearchBot, PerplexityBot | Against the IP ranges published by Google, Microsoft, Apple, DuckDuckGo, OpenAI and Perplexity. Instant, with no network call during the request. An address outside these ranges is blocked, even if DNS is slow or down. |
| Link-preview bots of Facebook, X, LinkedIn and Telegram, Meta's AI crawlers | Against the origin network of the IP address: these bots come from their operator's own networks, where nobody can rent a server. An address from another network is blocked. |
| Other bots that claim a domain (YandexBot, Baiduspider…) | By DNS (reverse then forward lookup). If DNS does not answer, the request goes through: Zarex does not block because of an outage on its side. |
| WhatsApp, Slack, Discord, Pinterest, and most bots in the list (small search engines, SEO tools, feed readers…) | Not verifiable: if they are in allow, their User-Agent is enough. In the decision, verified is then false; do not grant privileges to such a bot. A WhatsApp link preview is built by the sender's phone, from its own mobile network; Slack and Discord run on hosting providers open to anyone. |
The official address lists are built into Zarex and updated automatically every day.
The problem
A large share of a site's traffic does not come from humans. Some bots are useful: Google indexing your pages, WhatsApp showing a link preview. Others are not: scrapers copying your prices and content, AI crawlers harvesting your pages, vulnerability scanners, scripts. And a malicious bot can pretend to be Googlebot to be let through.
What it stops
- scrapers and content harvesters;
- AI crawlers, if you do not want them to read your pages;
- scanners and scripts (curl, python-requests…);
- requests without a User-Agent, the usual signature of a script;
- fake search engines and fake AI crawlers, unmasked by verification.
When to use it
Content and pricing pages, APIs that should only be called by your own front end, forms. Allow search engines if your site needs to be indexed.
A limit to be aware of
Detection relies on the identity the bot announces (its User-Agent). A bot that pretends to be an ordinary browser is not recognized by this rule: combine it with rate limiting.
Allowing CATEGORY:SOCIAL (useful for link previews) also lets through a script that presents itself as WhatsApp, Slack or Discord, since these bots cannot be verified. Do not grant privileges (paid content, pages behind a login) to a bot whose verified is false.
Configuration
import { detectBot } from "@zarex/express"; // or your framework's package
rules: [detectBot({ allow: ["CATEGORY:SEARCH_ENGINE"] })],Here, verified search engines go through; every other bot is blocked.
Blocked by default
A recognized bot that is not in allow is denied. With no option, detectBot() therefore blocks every recognized bot, search engines included: remember to allow them if your site needs to be indexed.
Options
| Option | Values | Default | Role |
|---|---|---|---|
allow | categories or bot names (64 at most) | none: every recognized bot is denied | Allowed bots. |
deny | categories or bot names (64 at most) | none | Bots always denied, even if they are also in allow. Also enables the CATEGORY:HOSTING, CATEGORY:SPOOFED_BROWSER, CATEGORY:TOR and CATEGORY:VPN signals. |
mode | "LIVE" · "DRY_RUN" · "OFF" | "LIVE" | Deny, only observe, or disable. |
Names are case-insensitive: "Googlebot" and "GOOGLEBOT" are equivalent.
How allow and deny combine
denyalways wins. Withallow: ["CATEGORY:SEARCH_ENGINE"]anddeny: ["Googlebot"], Googlebot is denied; other search engines go through.- Every identity must be allowed. A script can slip several bot names into one User-Agent to benefit from the most permissive one. Zarex recognizes them all, and the request only goes through if each one is in
allow. - An allowed bot must still prove its identity, when possible (see the table above). A fake Googlebot is denied even if
CATEGORY:SEARCH_ENGINEis inallow.
A misspelled name matches nothing
An unknown name or category ("Googlebott", "CATEGORY:SEARCH") does not cause an error: it simply matches no bot, and the bot you meant stays denied. Copy names exactly as they appear in the decision log (name or matched_bots), or use the categories below.
mode: observe before blocking
rules: [detectBot({ mode: "DRY_RUN", allow: ["CATEGORY:SEARCH_ENGINE"] })],In DRY_RUN, nothing is blocked: the decision log shows the bots that would have been denied. On a site that is already live, observe for a few days to spot the useful bots to allow (link previews, monitoring, webhooks), then switch to LIVE.
Categories
| Category | Examples |
|---|---|
CATEGORY:SEARCH_ENGINE | Googlebot, Bingbot, Applebot, DuckDuckBot, YandexBot |
CATEGORY:AI | GPTBot, ClaudeBot, PerplexityBot, MetaExternalAgent |
CATEGORY:SOCIAL | WhatsAppBot, FacebookBot, LinkedInBot, TelegramBot |
CATEGORY:MONITOR | UptimeRobot, Pingdom, Datadog |
CATEGORY:SEO_TOOL | AhrefsBot, SemrushBot |
CATEGORY:ARCHIVE | ArchiveOrgBot, WaybackMachine |
CATEGORY:SCRAPER | content extraction bots |
CATEGORY:SCANNER | vulnerability scanners |
CATEGORY:HTTP_LIBRARY | curl, Wget, python-requests, axios |
CATEGORY:WEBHOOK | Stripe, PayPal, Shopify, Zapier, SendGrid, Zendesk |
CATEGORY:FEED | RSS feed readers: Feedly, Inoreader, NewsBlur |
CATEGORY:ADVERTISING | ad verification and targeting |
CATEGORY:ACADEMIC | university research crawlers |
CATEGORY:NO_USER_AGENT | EmptyUserAgent: HTTP request without a User-Agent |
CATEGORY:HOSTING | HostingBrowser: a browser coming from a hosting provider, only if you add it to deny (see below) |
CATEGORY:SPOOFED_BROWSER | SpoofedBrowser: a browser whose headers contradict its User-Agent, only if you add it to deny (see below) |
CATEGORY:TOR | TorExit: a visitor coming out of the Tor network, only if you add it to deny (see below) |
CATEGORY:VPN | CommercialVPN: a visitor coming out of a VPN provider's network, only if you add it to deny (see below) |
The bot list comes from crawler-user-agents (MIT license), extended and checked by Zarex. The list of Tor exits is published by The Tor Project.
Payment webhooks
Webhooks (Stripe, PayPal, Shopify, Zapier…) are recognized as bots, and therefore denied by default. On the route that receives your webhooks, allow them, or do not apply detectBot() there:
detectBot({ allow: ["CATEGORY:WEBHOOK"] })Also verify each webhook's signature, as your provider explains: a User-Agent can be imitated.
Requests without a User-Agent
A browser always sends a User-Agent: its absence almost always betrays a script. These requests are therefore blocked like other unallowed bots.
If your mobile app or a partner service (webhook) calls your site without a User-Agent, allow them explicitly:
rules: [detectBot({ allow: ["CATEGORY:SEARCH_ENGINE", "EmptyUserAgent"] })],Browsers coming from a hosting provider
A script pretending to be Chrome is recognized by no bot list. But it almost always runs on a rented server (AWS, Google Cloud, Azure, OVH, Hetzner, DigitalOcean…), whereas a real visitor arrives through their mobile carrier or internet provider.
Add CATEGORY:HOSTING to deny to deny these requests:
rules: [detectBot({ allow: ["CATEGORY:SEARCH_ENGINE"], deny: ["CATEGORY:HOSTING"] })],The decision names the hosting provider involved (hosting_provider).
Off by default
A real user may go through a VPN hosted at one of these providers, or work on a virtual desktop in the cloud. Enable this signal on routes that attract scripts (login, sign-up, forms, APIs), and try it in DRY_RUN first. Networks that carry real users are never affected: Cloudflare WARP, iCloud Private Relay, Google, carriers and internet providers.
Browsers with inconsistent headers
Along with its User-Agent, a real browser sends other headers consistent with it. Chrome and Edge send Sec-CH-UA, which repeats their version and platform. Chrome, Edge, Firefox and Safari send Sec-Fetch-Mode and Accept-Language. A script that copies Chrome's User-Agent forgets them, or gets them wrong.
Add CATEGORY:SPOOFED_BROWSER to deny to deny these requests:
rules: [detectBot({ allow: ["CATEGORY:SEARCH_ENGINE"], deny: ["CATEGORY:SPOOFED_BROWSER"] })],The decision lists the inconsistencies found (inconsistencies), for example sec_ch_ua_missing or sec_ch_ua_version_mismatch.
Only requests that present themselves exactly as a stock Chrome, Edge, Firefox or Safari are examined. In-app browsers, WebViews and browsers such as Phoenix, UC Browser, Opera Mini or Samsung Internet are never affected.
Off by default, and HTTPS required
Browsers only send Sec-CH-UA and Sec-Fetch-* over HTTPS. Do not enable this signal on a site served over plain HTTP: all your visitors would be denied. Try it in DRY_RUN first and look at the decisions in the dashboard.
Visitors coming through Tor or a VPN
Tor and VPNs hide the visitor's address: your site sees the address of a relay. Mass sign-ups and password guessing often go through them, because they make it easy to change address at will.
CATEGORY:TORrecognizes Tor exit addresses, from the list published by the Tor Project. Zarex keeps it up to date automatically.CATEGORY:VPNrecognizes networks owned by VPN providers, from a list maintained and checked by Zarex.
rules: [detectBot({ allow: ["CATEGORY:SEARCH_ENGINE"], deny: ["CATEGORY:TOR", "CATEGORY:VPN"] })],The decision says so: tor_exit: true, or vpn_provider (the network's holder).
These signals are about the address: they also apply to bots you allow, and to calls without an HTTP request. Putting them in allow has no effect. For wider coverage, add CATEGORY:HOSTING too: many VPN providers rent their servers from hosting companies.
Off by default
Real people use Tor or a VPN: journalists, people facing censorship, remote workers, public Wi-Fi users. Denying them shuts them out of your site. Enable these signals on sensitive routes (sign-up, login, checkout), and try them in DRY_RUN first.
What is not covered
Residential proxies (addresses of real home routers or phones), VPNs exiting through such addresses, Cloudflare WARP and iCloud Private Relay are not recognized. A VPN provider renting servers from an ordinary hosting company may be caught by CATEGORY:HOSTING. Shield, per-account rate limiting and CATEGORY:SPOOFED_BROWSER keep working behind these networks.
What the decision contains
The rule's result, in decision.results (ruleType: "BOT_DETECTION"), contains in reason:
| Field | Meaning |
|---|---|
bot | true: a bot was recognized. false (with human: true): an ordinary visitor. |
name, category | The bot and its category, when an identity check took place. |
matched_bots | Every bot recognized in the User-Agent. |
verified | true: identity proven (published address ranges, origin network or DNS). false: not proven, or impossible to prove. |
method | How the identity was checked: published_ranges, asn or fcrdns (DNS). |
denied_by, denied_category | The deny entry that got the request denied. |
hosting_provider | The hosting provider involved, for HostingBrowser. |
inconsistencies | The inconsistencies found, for SpoofedBrowser. |
tor_exit | true: the address is a Tor exit, for TorExit. |
vpn_provider | The network's holder, for CommercialVPN. |
reason | A short explanation, for your logs. |
Example, a script presenting itself as Googlebot from an address that is not Google's:
{ "bot": true, "name": "Googlebot", "category": "CATEGORY:SEARCH_ENGINE",
"verified": false, "method": "published_ranges",
"reason": "identity claimed but IP outside the ranges published by the operator (spoofing)" }And a curl request, with allow: ["CATEGORY:SEARCH_ENGINE"]:
{ "bot": true, "matched_bots": ["curl"], "reason": "at least one detected bot identity is not allowed" }If DNS verification does not answer (outage, timeout), the result is ERROR and the request goes through: an outage on our side never blocks your visitors.
Example: deny AI crawlers
rules: [
detectBot({
allow: ["CATEGORY:SEARCH_ENGINE", "CATEGORY:SOCIAL", "CATEGORY:MONITOR"],
deny: ["CATEGORY:AI"],
}),
],