Autonomous AI coding agents (Claude Code, Cursor background agents, containerized SWE sandboxes) are increasingly given raw shell execution inside cloud VMs, Docker containers, or Tailscale-joined workstations. Left unguarded, two predictable failure modes show up fast:
- AI Sandbox SSRF & Lateral Movement: An unisolated coding agent can query cloud instance metadata (
169.254.169.254/fd00:ec2::254) to harvest IAM credentials, probe private192.168.0.0/16or100.64.0.0/10peers over TCP:22SSH /:2375Docker /:5432Postgres, or collide on shared TailscaleNodeKeystate across container restarts. - RFC 1918 Wi-Fi Collisions & Selective QUIC Stalls: Advertising raw
/24LAN routes over Tailscale breaks silently whenever a hotel or coffee-shop Wi-Fi shares your home prefix, while throttledUDP/443proxy tunnels inSing-boxorMihomostall Apple Media and mobile Gmail fetches for 50 seconds—yet blockingUDP/443globally breaks YouTube mobile (CronetHTTP/3) captions.
To eliminate these failure modes deterministically across Linux, macOS, and Tailscale without external dependencies, I built and open-sourced StarHub Kit (v1.3.0) — a zero-dependency Python 3.9+ policy compiler and native Model Context Protocol (MCP) server certified Linux Foundation OpenSSF Best Practices Silver (#16658) with SLSA Build Level 3 provenance.
1. Turnkey Autonomous AI Agent Sandbox Isolation (--profile ai-sandbox)
Instead of hand-maintaining brittle firewall shell scripts across OSes, a single declarative topology (profiles/topology.ai-sandbox.json) compiles into Linux nftables (inet), macOS pf anchors, Tailscale ACL HuJSON, and dual-stack iptables / ip6tables (--target all):
- Hard-drops cloud metadata SSRF (
169.254.169.254/32andfd00:ec2::254/128); - Rejects inbound/lateral TCP
:22SSH over both IPv4 and IPv6 (STARHUB-BOT-NOSSH/NOSSH6) while isolating per-sandbox Tailscale state directories; - Permits only explicitly declared upstream API endpoints before dropping remaining RFC 1918 and CGNAT lateral traffic.
2. Eliminating Subnet Collisions (4via6) & Cross-Engine QUIC Guardrails (Sing-box + Mihomo)
- Zero Subnet Collisions: Containers join Tailscale natively on
100.64.0.0/10, while non-Tailscale hypervisors map through stateless Tailscale4via6IPv4-to-IPv6 translation with an automaticSTARHUB-IPV6-EXIT-GUARDleak-prevention chain. - Selective QUIC (
UDP/443) & Deterministic Split-DNS: Compiles matching rulesets for bothSing-box(v1.11+rule actions) andMihomo, rejectingUDP/443only for stalled Apple/Gmail endpoints so clients fall back to TCP/TLS in<50 mswhile keeping YouTube HTTP/3 untouched.
3. 10-Second Unprivileged Preview & Zero-Dependency MCP Server
Every target supports non-root --dry-run preview directly to stdout, static risk auditing (starhub audit), and a built-in stdio MCP server (starhub mcp) for Claude Code, Cursor, or Windsurf:
# Install via Homebrew Tap (macOS / Linuxbrew): brew install Ziqi/tap/starhub-kit # Preview Linux nftables, macOS pf, Tailscale ACL & Sing-box rules with zero root or disk writes: starhub render --profile ai-sandbox --target all --dry-run starhub audit # Or run directly via Nix Flakes without installing: nix --extra-experimental-features 'nix-command flakes' run github:Ziqi/starhub-kit -- \ render --profile ai-sandbox --target nftables --dry-run Before publishing configs, starhub doctor --verify-public-export scans your working tree and Git history to verify zero private IPs, tailnet names, or keys leak into public commits.
- GitHub Repository (MIT License): https://github.com/Ziqi/starhub-kit
- OpenSSF Best Practices Silver (
#16658): https://www.bestpractices.dev/projects/16658

