Overview
CrabTrap sits between an AI agent and the internet. Every outbound HTTP and HTTPS request the agent makes is intercepted and evaluated before it is allowed through, which turns "what can this agent reach?" from a question about prompt wording into a question about network policy you can inspect and change.
Evaluation is two-tier, and the ordering is the point. Deterministic static rules are checked first and settle the common cases in microseconds; the LLM judge is only invoked when no rule matches, so the expensive, non-deterministic path handles the tail rather than every request. Policies can therefore be written in natural language without paying for a model call on traffic that a simple rule already covers.
The rest is production plumbing: HTTPS interception with a generated CA certificate, SSRF protection that blocks requests into private network ranges, per-IP rate limiting, a circuit breaker for when the judge model is unavailable, OpenTelemetry metrics in Prometheus format, and a full request/response audit trail in PostgreSQL with a web UI for managing policies and reading it back.
What it does
- Two-tier policy evaluation: deterministic static rules first, LLM judge only when nothing matches
- HTTPS interception via a generated CA certificate, so TLS traffic is inspectable
- SSRF protection that blocks agent requests into private network ranges
- Complete request/response audit logging to PostgreSQL, with a web UI to review it
- Per-IP rate limiting and a circuit breaker for LLM judge failures
- OpenTelemetry metrics exported in Prometheus format
Getting started
The quickstart runs the proxy and its dependencies with Docker Compose, then sends a request through it to confirm interception works.
Start the proxy
Brings up CrabTrap and its PostgreSQL audit store.
docker compose up -dCopy out the CA certificate
Clients need CrabTrap's CA to trust the intercepted TLS connections.
docker compose cp crabtrap:/app/certs/ca.crt ./ca.crtCreate an admin user
The gateway binary mints a token you use for the web UI and for authenticating proxy clients.
admin_token=$(docker compose exec -it crabtrap ./gateway create-admin-user test-admin | tail -n1 | cut -d" " -f2)Send a request through it
Point any HTTP client at the proxy with the token as the username and the CA you exported. This is also how you wire an agent's HTTP_PROXY/HTTPS_PROXY environment to CrabTrap.
curl -x http://${token}:@localhost:8080 --cacert ca.crt https://httpbin.org/getCommands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Give a production agent internet access without giving it unrestricted internet access
- Answer "what did the agent actually call last Tuesday?" from an audit log instead of from model traces
- Express an allow-list in natural language for the long tail, while keeping hot paths on deterministic rules
- Block SSRF-style attempts to reach internal services from a tool the agent controls
How CrabTrap compares
CrabTrap alongside other open-source guardrails & security tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| SkillSpector | ★ 17.4k | Security scanner for AI agent skills that checks a skill for prompt injection, data exfiltration, privilege escalation and supply-chain risks before you install it. |
| Presidio | ★ 10.9k | An open-source framework for detecting, redacting, masking, and anonymizing personal data (PII) across text, images, and structured data using NER models, regex, and rule-based recognizers. |
| Guardrails AI | ★ 7.4k | A Python framework that wraps LLM calls with composable input/output validators (from the Guardrails Hub) to check structure, type, and safety risks before responses reach users. |
| NeMo Guardrails | ★ 7.1k | NVIDIA's toolkit for adding programmable rails to LLM chat apps, using the Colang language to control dialog flow and block jailbreaks, prompt injection, and off-topic answers. |
| dcg (Destructive Command Guard) | ★ 6k | A Rust pre-tool hook for coding agents that inspects each shell or git command before it runs and blocks the destructive ones, with an explanation and a safer alternative. |
| GLiNER | ★ 3.7k | A small zero-shot named-entity recognition model that can extract arbitrary entity types from text and is widely used as a PII detection backend, including inside Presidio. |
| LLM Guard | ★ 3.2k | A security toolkit from Protect AI with 35+ input and output scanners that sanitize prompts and responses for prompt injection, toxicity, PII leakage, and harmful content. |
| CrabTrap | ★ 787 | An egress proxy that decides, per request, where your agent is allowed to go |