# web bot auth & aipref gate

- Status: `experiment`
- Track: [content negotiation, signed citations & attribution](https://aifoc.us/labs/web-protocols/)
- Layer: 4. Network Stack, Content Negotiation & Protocols
- Updated: 2 December 2026
- Live demo: https://web-bot-auth-aipref-gate.kinlan-test.workers.dev
- Source: https://github.com/PaulKinlan/web-bot-auth-aipref-gate

## Inspired by

- [hyper content negotiation](https://aifoc.us/hyper-content-negotiation/)
- [A link is all you need](https://aifoc.us/a-link-is-all-you-need/)
- [hypermedia was always the point](https://aifoc.us/hypermedia/)

## Why this matters

Publishers currently guess crawler identity from spoofable `User-Agent` strings and fragile IP allowlists while managing four overlapping preference formats (`robots.txt`, IETF `aipref` `Content-Usage`, `Content-Signal`, and RSL 1.0) that frequently contradict one another with no shared conflict rule.

## What this opens up

Cryptographic crawler identity paired with explicit per-purpose access control: sites can allow verified real-time `ai-input` RAG grounding while blocking bulk `train-ai` crawls, stop replayed signatures with an atomic SQLite nonce window, or gate licensed access behind RSL 1.0 tokens.

## How the tests work

1. Click **Sign & Fetch Allowed RAG (200)** to sign a live HTTP request in your browser with an Ed25519 key enrolled in `/.well-known/http-message-signatures-directory`.
2. Click **Replay Captured Nonce (409)** to re-send the exact captured signature and watch the `ReplayGuard` SQLite Durable Object block the duplicate nonce.
3. Run **Run All 5 Attacks** to verify that replayed nonces (`409`), tampered paths (`401`), unlisted rogue keys (`403`), expired timestamps (`401`), and disallowed `train-ai` purposes (`403`) all fail closed.
4. Toggle `robots.txt`, `Content-Usage`, `Content-Signal`, and `RSL 1.0` rules in the **Policy Conflict Matrix Editor** and switch between the three precedence modes to see how contradictions resolve.


## Hypothesis

- **Claim:** Request-side RFC 9421 Ed25519 `Signature-Agent` verification backed by an atomic Durable Object replay ledger (`ReplayGuard`) authenticates automated crawlers without static IP lists, while explicit precedence rules are required to resolve contradictory `robots.txt`, `Content-Usage`, `Content-Signal`, and RSL 1.0 signals deterministically.
- **Confirms it:** Enrolled browser Ed25519 keys pass `/protected/article` for `ai-input` (`200`), all 5 red-team attacks fail closed (`409`, `401`, `403`, `401`, `403`), and the Policy Conflict Matrix flags pairwise contradictions across `restrictive-intersection`, `specific-overrides-robots`, and `license-aware` modes.
- **Bounds or disproves it:** Without a stateful nonce store (`ReplayGuard`), a captured valid RFC 9421 signature replays freely until expiry, and publishing conflicting `robots.txt`, `Content-Usage`, `Content-Signal`, and RSL 1.0 rules produces opposite crawl outcomes depending on which precedence rule a crawler picks.


## Under the hood

[Web Bot Auth & aipref Gate](https://web-bot-auth-aipref-gate.kinlan-test.workers.dev) ([GitHub](https://github.com/PaulKinlan/web-bot-auth-aipref-gate)) tests the request-side half of [IETF Web Bot Auth](https://datatracker.ietf.org/wg/webbotauth/about/) alongside [IETF AI Preferences (`aipref`)](https://datatracker.ietf.org/wg/aipref/about/):

- **Request-Side RFC 9421 Ed25519 Signing & `ReplayGuard` DO** — Generates an Ed25519 keypair in browser RAM via WebCrypto, enrolls only the public JWK in `/.well-known/http-message-signatures-directory` (persisted in SQLite `ReplayGuard`), signs requests over `("@authority" "signature-agent" "@method" "@target-uri")`, and enforces an atomic sliding replay window in SQLite (`sig_nonces`).
- **5 Live Red-Team Attacks** — Runs replay (`409 REPLAY_DETECTED`), tampered authority/path (`401 SIG_INVALID`), unlisted rogue directory (`403 KEY_UNTRUSTED`), expired timestamp (`401 SIG_EXPIRED`), and disallowed purpose (`403 AIPREF_DENIED`) live against `/protected/article`, `/protected/ai-dataset`, and `/protected/robots-disallowed`.
- **Policy Conflict Matrix** — Shares `public/lib/policy-matrix.js` between browser and edge to evaluate [RFC 9309 `robots.txt`](https://www.rfc-editor.org/rfc/rfc9309), IETF `Content-Usage`, `Content-Signal`, and [RSL 1.0](https://rslstandard.org/) (`/rsl.json` JSON and XML) across `restrictive-intersection`, `specific-overrides-robots`, and `license-aware` precedence modes.


## Key terms & further reading

- [IETF Web Bot Auth](https://datatracker.ietf.org/wg/webbotauth/about/) — An IETF working group standardizing cryptographic crawler authentication using RFC 9421 request signatures and `Signature-Agent` directories.
- [IETF AI Preferences (aipref / Content-Usage)](https://datatracker.ietf.org/wg/aipref/about/) — A standardized HTTP header vocabulary letting publishers set distinct usage rules for `search`, `ai-input` (RAG), and `train-ai`.
- [RFC 9421 HTTP Message Signatures](https://www.rfc-editor.org/rfc/rfc9421) — The HTTP signature specification binding `@authority`, `signature-agent`, `@method`, `@target-uri`, expiry, and a unique `nonce` to an Ed25519 signature.
- [RFC 9309 robots.txt](https://www.rfc-editor.org/rfc/rfc9309) — The Robots Exclusion Protocol defining path-level allow and disallow directives for automated crawlers.
- [RSL 1.0 (Really Simple Licensing)](https://rslstandard.org/) — A machine-readable licensing specification for declaring free, attribution-only, or pay-per-crawl terms alongside preference headers.
- [Ed25519 & Sliding Replay Window](https://datatracker.ietf.org/doc/html/rfc8032) — A fast public-key signature algorithm paired with a Durable Object SQLite nonce table so captured valid signatures cannot be replayed.

## Open questions to iterate on

- How should edge caches handle signed `Signature-Agent` requests without collapsing CDN hit rates on public articles?
- Which conflict precedence rule (`restrictive-intersection` vs. `license-aware`) will dominate when `Content-Usage` and RSL 1.0 disagree?

## Iteration log

- **2026-12-02:** Deployed Cloudflare Worker + SQLite `ReplayGuard` Durable Object hosting RFC 9421 self-signed `/.well-known/http-message-signatures-directory`, unlisted rogue directory fixture, WebCrypto Ed25519 browser signing workbench, 5 live red-team attacks, and live `robots.txt` / IETF `aipref` (`Content-Usage`) / `Content-Signal` / RSL 1.0 conflict matrix.

## Primitives tested

- `RFC 9421 HTTP Message Signatures (Signature-Agent)`
- `WebCrypto Ed25519`
- `IETF aipref (Content-Usage)`
- `Content-Signal`
- `RSL 1.0`
- `RFC 9309 robots.txt`
- `Durable Object SQLite (ReplayGuard)`

## Connected labs in other tracks

- [signed web citations](https://aifoc.us/labs/web-protocols/signed-web-citations/) — Tests response-side RFC 9421 Ed25519 origin signatures over quoted passages.
- [agent well-known audit lab](https://aifoc.us/labs/agent-bridges-and-discovery/agent-well-known-audit-lab/) — Audits `/.well-known/http-message-signatures-directory`, `/.well-known/aipref`, and 10 other agent discovery endpoints.
- [x402 micropayment rail](https://aifoc.us/labs/agent-bridges-and-discovery/x402-micropayment-rail/) — Pairs policy-gated crawler access with HTTP 402 exact and metered settlement.

---
Canonical: https://aifoc.us/labs/web-protocols/web-bot-auth-aipref-gate/
