cd /news/ai-agents/show-hn-200-line-local-python-harnes… · home › topics › ai-agents › article
[ARTICLE · art-180276] src=github.com ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

Show HN: 200-line local Python harness to audit AI agent sandbox leaks

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`.

key 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.

read2 min views48 publishedDec 2, 2026
Show HN: 200-line local Python harness to audit AI agent sandbox leaks
Image: Michielbdejong (auto-discovered)

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
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.

── more in #ai-agents 4 stories · sorted by recency
── more on @agent-canary 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/show-hn-200-line-loc…] indexed:0 read:2min 2026-12-02 · —