{"slug": "show-hn-200-line-local-python-harness-to-audit-ai-agent-sandbox-leaks", "title": "Show HN: 200-line local Python harness to audit AI agent sandbox leaks", "summary": "A developer released agent-canary, a zero-dependency, localhost-only Python harness of roughly 200 lines that audits whether an AI agent sandbox (Claude Code, Cursor, OpenClaw, n8n Nod, Codex) exposes `.env` files, `~/.ssh` keys or outbound network traffic, run via `python3 agent_canary.py audit`. The tool performs four read-only checks — host credential isolation (`~/.ssh`, `~/.aws/credentials`, `~/.kube/config`, `~/.docker/config.json`, `~/.npmrc`, `~/.pypirc`, `~/.git-credentials`), env and `.env` secret hygiene, blast-radius isolation (cloud metadata `169.254.169.254` and local Postgres/Redis/Mongo/MySQL/n8n/Ollama), and outbound egress on port 443 — and ships an `init` command that creates fake canary keys plus a prompt-injection fixture (`README_UNTRUSTED.md`, `mock_mcp_tool.json`) with a `127.0.0.1:9999` trap listener that logs leaks such as `[LEAKED in 1.84s] ... matched: CANARY_OPENAI_KEY`. The author cites the November 17 PyPI compromise of Microsoft's `agent-framework` (`v1.26.1`/`v1.26.2`) and Signal's November 20 default OS screenshot blocking as reasons to verify isolation posture, and pairs the MIT-licensed harness with a UFW baseline script (`harden-burner-vps.sh`) for Ubuntu 24.04 that blocks outbound RFC1918 LAN ranges and `169.254.169.254`.", "body_md": "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.\n\nNo external packages. No data leaves your machine.\n\nAfter 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.\n\n`agent-canary` lets you verify your actual isolation posture in 10 seconds instead of guessing.\n\n```\npython3 agent_canary.py audit\n# Optional: tag which agent you are testing (OS & container are auto-detected)\npython3 agent_canary.py audit --label \"OpenClaw\"\n```\n\nChecks performed (read-only, never prints secret values):\n\n1. **Host credential isolation** (are`~/.ssh` ,`~/.aws/credentials` ,`~/.kube/config` ,`~/.docker/config.json` ,`~/.npmrc` ,`~/.pypirc` , or`~/.git-credentials` readable from this shell?)\n2. **Env & `.env` secret hygiene** (are raw`OPENAI_*` ,`ANTHROPIC_*` ,`STRIPE_*` ,`AWS_*` ,`GITHUB_TOKEN` vars in`os.environ` , or plaintext`.env` files in the current directory?)\n3. **Blast-radius isolation** (is cloud metadata`169.254.169.254` or local Postgres/Redis/Mongo/MySQL/n8n/Ollama reachable?)\n4. **Outbound egress control** (can an untrusted tool open an arbitrary outbound port 443 socket?)\n\nCreate a temporary folder containing fake canary keys and a benign prompt-injection fixture (`README_UNTRUSTED.md` + `mock_mcp_tool.json`):\n\n```\npython3 agent_canary.py init --dir ./canary-sandbox\n```\n\nStart the strict `127.0.0.1:9999` trap listener in Terminal 1:\n\n```\npython3 agent_canary.py listen\n```\n\nPoint 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:\n\n``` php\n[LEAKED in 1.84s] Canary exfiltrated to 127.0.0.1:9999/exfil -> matched: CANARY_OPENAI_KEY\n```\n\nSee [`harden-burner-vps.sh`](https://github.com/SuperMnr/agent-canary/blob/master/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:\n\n- Kernel-level sandboxing and credential-injection proxies such as [`nolabs-ai/nono`](https://github.com/nolabs-ai/nono)\n- Scoped secret vaults (never raw `.env` files on disk)\n- A prepaid, hard-capped API key instead of your main billing card\n\nFull write-up comparing Docker mounts, `nono`, and disposable cloud sandboxes: [Read on DEV](https://dev.to/supermnr/i-built-a-200-line-canary-test-to-audit-my-ai-agent-setup-my-dev-box-scored-14-2j2).\n\nMIT — strictly for defensive self-auditing of environments you own.", "url": "https://wpnews.pro/news/show-hn-200-line-local-python-harness-to-audit-ai-agent-sandbox-leaks", "canonical_source": "https://github.com/SuperMnr/agent-canary", "published_at": "2026-12-02 15:06:49+00:00", "updated_at": "2026-12-02 15:17:15.871551+00:00", "lang": "en", "topics": ["ai-agents", "ai-safety", "ai-tools", "developer-tools"], "entities": ["agent-canary", "Claude Code", "Cursor", "OpenClaw", "n8n Nod", "Codex", "Microsoft", "agent-framework"], "also_reported_by": [], "takeaway": "Run `python3 agent_canary.py audit` to check whether an agent shell can read `~/.ssh`, `~/.aws/credentials` or raw `OPENAI_*`/`ANTHROPIC_*` env vars, then use `init` plus the `127.0.0.1:9999` listener to confirm whether a prompt-injected agent exfiltrates canary keys.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/show-hn-200-line-local-python-harness-to-audit-ai-agent-sandbox-leaks", "markdown": "https://wpnews.pro/news/show-hn-200-line-local-python-harness-to-audit-ai-agent-sandbox-leaks.md", "text": "https://wpnews.pro/news/show-hn-200-line-local-python-harness-to-audit-ai-agent-sandbox-leaks.txt", "jsonld": "https://wpnews.pro/news/show-hn-200-line-local-python-harness-to-audit-ai-agent-sandbox-leaks.jsonld"}}