agentguard
Network egress firewall for AI agent tools. Declarative domain allowlist; throws on violation.
[]
= "0.1"
# Or, with reqwest-middleware integration:
= { = "0.1", = ["reqwest"] }
Why
Your agent's tools call out to the network. Without a sandbox, a prompt injection or a confused-deputy bug can exfiltrate secrets to attacker-controlled domains. agentguard is the smallest possible primitive that stops it: a declarative allowlist you check before each call (or install once as reqwest-middleware and forget).
Quick start
use Allowlist;
let allow = new
.domain
.domain
.subdomains_of; // permits s3.us-east-1.amazonaws.com etc.
allow.check.unwrap;
allow.check.unwrap;
// Everything else is rejected:
assert!;
assert!;
With reqwest-middleware
Enable the reqwest feature, then plug GuardMiddleware into a reqwest_middleware::ClientBuilder:
#
#
Rules
.domain("api.openai.com")— exact-match host.sub.api.openai.comis not allowed..subdomains_of("anthropic.com")— apex + any subdomain.anthropic.com,api.anthropic.com,us.api.anthropic.comall pass..allow_schemes(["https", "wss"])— override the default["http", "https"].
Order doesn't matter — a URL is allowed if it matches any rule.
What it doesn't do
- No DNS resolution; matches on the URL host string. (DNS rebinding is a different threat — pin IPs at the resolver level.)
- No path filtering; full host gates everything.
- No regex; subdomain matching is structural (
.endsWith(.apex)).
Sibling: JS @mukundakatta/agentguard
JS users: see @mukundakatta/agentguard on npm.
License
MIT