Skip to content

About

AI agent sandbox

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

AI Agent Developer Sandbox

A secure, isolated development environment for running autonomous AI coding agents (Claude Code, OpenCode) on Fedora Silverblue. The sandbox ensures agents can help you write code without risking your host system's security, privacy, or stability.

How the Sandbox Works

Defense-in-depth architecture with four layers of isolation:

  1. gVisor: Interposes a user-space kernel (the Sentry) between the container and the host kernel. Syscalls from the AI agent never reach your real kernel. File I/O goes through a separate Gofer process, adding another boundary.
  2. Filesystem Boundary: The AI sees your project folder (/w) plus exactly the paths listed in mounts.conf — nothing else. SSH keys and system files are invisible. Note that the default mounts.conf does bind in live agent credentials (~/.claude.json rw, ~/.config/gh ro), so treat those as fully readable by whatever runs in the sandbox; see Credential exposure.
  3. User Namespaces: The AI operates as an unprivileged user (--userns=keep-id). Files it creates in your project are owned by your host user account.
  4. Air-Gapped Network: The container is on an internal-only network with zero direct internet access. All traffic must go through a Squid proxy that only allows whitelisted domains.

What's Inside the Container

  • Languages: Go, Node.js
  • AI agents: Claude Code, OpenCode
  • Editors: Helix
  • Shell: Fish
  • Tools: gopls, git, make, gcc, curl, jq, ripgrep, fd, fzf, tree, and more

Customize via Containerfile

Prerequisites

  • podman, just, runsc(gVisor)

Setup

1. Install gVisor

just install-gvisor

2. Build and Run

First time, build the image, start the proxy, and launch the sandbox:

just setup

This runs just build && just proxy-up && just run in sequence.

Usage

Daily workflow

Navigate to your project directory and launch the sandbox:

cd ~/my-go-project
just run
# just run-in

You'll be dropped into Fish shell. Run claude, opencode, or use your Go tooling directly. Type exit to destroy the sandbox.

Networks

Whitelisted Domains

Configured in squid.conf (your gitignored copy of squid.conf.example). Only these domains are reachable from the sandbox by default:

Domain Purpose
.anthropic.com, .claude.ai Claude API and auth
.opencode.ai OpenCode services
.github.com, .githubusercontent.com Git repos, release assets
.golang.org, .go.dev, storage.googleapis.com Go modules, proxy, downloads
.npmjs.org, .npmjs.com npm packages

Everything else is blocked. Bypassing the proxy does not help: the sandbox sits on an internal podman network with no external route and no external DNS, so direct connections fail to resolve (by hostname) or fail to connect (by raw IP).

Testing the Network Isolation

From inside the sandbox:

# --noproxy is required on the direct tests: HTTP_PROXY/HTTPS_PROXY are set in
# the container, so without it curl silently uses the proxy and you end up
# testing the allowlist rather than direct egress.

# Direct, by hostname -- fails at DNS, since the sandbox has no external resolver
#   curl: (6) Could not resolve host: google.com
curl --noproxy '*' -m 5 https://google.com

# Direct, by raw IP -- fails at the network layer. This is the test that actually
# proves there is no route off the internal network.
#   curl: (7) Failed to connect to 1.1.1.1 port 443
curl --noproxy '*' -m 5 https://1.1.1.1/

# Allowed domains via the proxy work
curl -x http://ai-proxy:3128 https://api.anthropic.com

# Blocked domains via the proxy are denied by squid
#   curl: (56) CONNECT tunnel failed, response 403
curl -x http://ai-proxy:3128 https://google.com

Personal Config

Anything specific to you — private repos, employer domains, extra mounts — stays out of git. Seed your working copies from the committed templates:

just init-local
Tracked (template) Yours (gitignored) Holds
squid.conf.example squid.conf Proxy rules and allowed domains
mounts.conf.example mounts.conf Bind mounts into the sandbox
config.fish.example config.fish Sandbox shell config and aliases
.env.example .env GOPRIVATE, loaded by just

Each pair is a template plus a full copy you own outright — edit the gitignored file, never the .example. init-local only creates what is missing, so it is safe to re-run and will not overwrite your edits.

When a .example changes upstream, diff it against your copy and merge by hand:

diff -u squid.conf.example squid.conf

Adding Allowed Domains

Add an acl allowed_domains dstdomain .example.com line to squid.conf, above the http_access allow allowed_domains rule, then restart the proxy:

just proxy-down && just proxy-up

Mounted Config

Edit mounts.conf, then restart the sandbox (exit and just run)

Credential exposure

The sandbox contains the host; it does not contain the credentials you hand it. By default mounts.conf binds in ~/.claude.json (rw), the Claude profile dirs (rw), and ~/.config/gh (ro), while .github.com sits on the proxy allowlist. Anything running in the sandbox therefore holds your GitHub token and a working network path to use it, so it can push to any repo you can push to. That requires no container escape — it is the intended configuration, and it is exactly what makes git and gh usable inside.

Note also what the allowlist does and does not do. It restricts where the sandbox can fetch from; it does not restrict what it can send. Any allowed domain that accepts arbitrary request bodies — analytics endpoints, GitHub gists — is a working egress path.

If that is more trust than you want to extend, the options are to scope the token down (a fine-grained PAT covering only the repos you actually sandbox, kept in a separate GH_CONFIG_DIR), or to drop the ~/.config/gh mount and authenticate per session.

About

AI agent sandbox

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages