A zero-dependency, localhost-only (127.0.0.1) defensive audit harness to check whether your AI agent sandbox (Claude Code, Cursor, OpenClaw, n8n Nod, Codex) leaks .env files, ~/.ssh keys, or outbound network traffic.

No external packages. No data leaves your machine.

After the November 17 PyPI compromise of Microsoft's agent-framework (v1.26.1 / v1.26.2) and Signal rolling out default OS screenshot blocking on November 20, trusting an autonomous agent on a main laptop or a production server is a real blast-radius problem.

agent-canary lets you verify your actual isolation posture in 10 seconds instead of guessing.

python3 agent_canary.py audit
# Optional: tag which agent you are testing (OS & container are auto-detected)
python3 agent_canary.py audit --label "OpenClaw"

Checks performed (read-only, never prints secret values):

  1. Host credential isolation (are~/.ssh ,~/.aws/credentials ,~/.kube/config ,~/.docker/config.json ,~/.npmrc ,~/.pypirc , or~/.git-credentials readable from this shell?)
  2. Env & .env secret hygiene (are rawOPENAI_* ,ANTHROPIC_* ,STRIPE_* ,AWS_* ,GITHUB_TOKEN vars inos.environ , or plaintext.env files in the current directory?)
  3. Blast-radius isolation (is cloud metadata169.254.169.254 or local Postgres/Redis/Mongo/MySQL/n8n/Ollama reachable?)
  4. Outbound egress control (can an untrusted tool open an arbitrary outbound port 443 socket?)

Create a temporary folder containing fake canary keys and a benign prompt-injection fixture (README_UNTRUSTED.md + mock_mcp_tool.json):

python3 agent_canary.py init --dir ./canary-sandbox

Start the strict 127.0.0.1:9999 trap listener in Terminal 1:

python3 agent_canary.py listen

Point your AI agent at ./canary-sandbox and ask it to summarize README_UNTRUSTED.md or inspect mock_mcp_tool.json. If the agent reads .env and hits http://127.0.0.1:9999/exfil, the listener logs:

[LEAKED in 1.84s] Canary exfiltrated to 127.0.0.1:9999/exfil -> matched: CANARY_OPENAI_KEY

See harden-burner-vps.sh for a minimal Ubuntu 24.04 UFW baseline that blocks outbound RFC1918 LAN ranges and 169.254.169.254. Pair it with:

  • Kernel-level sandboxing and credential-injection proxies such as nolabs-ai/nono
  • Scoped secret vaults (never raw .env files on disk)
  • A prepaid, hard-capped API key instead of your main billing card

Full write-up comparing Docker mounts, nono, and disposable cloud sandboxes: Read on DEV.

MIT — strictly for defensive self-auditing of environments you own.

原文来源:github.com