Skip to content

#1070 Add opt-in AI-bot identity verification snippet - #1077

Merged
mariano-dagostino merged 3 commits into
mainfrom
1070-ai-bot-verification
Sep 11, 2026
Merged

mariano-dagostino merged 3 commits into
mainfrom
1070-ai-bot-verification

Conversation

@mariano-dagostino

Copy link
Copy Markdown
Collaborator

Follow-up to #1076 (robots.txt baseline), closing out #1070's CDN/WAF item.

What

robots.txt is advisory — any client can send User-agent: GPTBot. This adds web/sites/ai_bot_verification.php, an opt-in snippet (modeled on bot_trap_protection.php) that enforces bot identity via forward-confirmed reverse DNS:

  1. Request claims to be a known AI bot (GPTBot, ClaudeBot, PerplexityBot, Meta-ExternalAgent, …).
  2. Its source IP must reverse-resolve to the vendor domain (.openai.com, .anthropic.com, .perplexity.ai, .facebook.com).
  3. That hostname must forward-resolve back to the same IP.
  4. Fails any step → 403. Ordinary traffic (non-AI UA) is untouched and never triggers a DNS lookup.

Deliberately not wired in

bot_trap_protection.php is required from the settings files; this one is not. It's shipped as a documented, self-contained opt-in (see the file's docblock for how to enable) because per-request DNS enforcement in PHP is a fallback — a CDN/WAF verified-bot rule (e.g. Cloudflare) is the better home. Left available for projects that want it without a WAF.

Kept to a single file so it doesn't conflict with #1076's README changes; a README pointer can follow once both land.

🤖 Generated with Claude Code

Ship web/sites/ai_bot_verification.php, an opt-in, no-WAF fallback that
enforces AI-bot identity via forward-confirmed reverse DNS: a request claiming
to be GPTBot/ClaudeBot/PerplexityBot/Meta-ExternalAgent must reverse-resolve to
the vendor domain and forward-resolve back to the same IP, otherwise it gets a
403. Ordinary traffic never triggers a DNS lookup.

Not wired into settings by default; enable by requiring it next to
bot_trap_protection.php. Prefer CDN/WAF verified-bot rules when available.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019P53wM3Lq5g9ZVH3uziQsR
Comment thread web/sites/ai_bot_verification.php Outdated
mariano-dagostino and others added 2 commits September 2, 2026 14:49
Replace the reverse-DNS lookups with an in-memory match against vendor-
published IP ranges. Ranges are fetched out-of-band via an OOP cron hook
(AiBotRangeCronHook) and cached to a file that the pre-bootstrap snippet
reads with no network I/O, so a slow vendor endpoint can't stall PHP
workers. Cache is written atomically and the snippet fails open.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016hxr3xBHM8RvMXbXprZrx7
@mariano-dagostino
mariano-dagostino merged commit 1909146 into main Sep 11, 2026
5 checks passed
@mariano-dagostino
mariano-dagostino deleted the 1070-ai-bot-verification branch September 11, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants