Lightweight OS-level sandboxing for AI agents and autonomous applications.
- Filesystem isolation: Block access to sensitive directories (SSH keys, cloud credentials)
- Network allowlisting: Only permit connections to approved domains
- Write restrictions: Limit file modifications to specific directories
- Dynamic config: Automatically configures write paths for target project
- Cross-platform: Uses
bubblewrapon Linux,sandbox-execon macOS - Docker mode: Alternative isolation using Docker containers
# Install dependencies
./bin/setup.sh
# Run any command in sandbox with dynamic config
./bin/gritguard your-command [args...]
# Example: Run SelfAssembler on a project
./bin/gritguard selfassembler "Add feature" --repo /path/to/projectThe gritguard wrapper automatically generates sandbox config based on the target directory:
# Sandbox a command with auto-detected paths
gritguard <command> [args...]
# Explicitly specify target directory
gritguard selfassembler "task" --repo /path/to/project
# Enable debug output
GRITGUARD_DEBUG=1 gritguard your-commandDynamic mode automatically allows writes to:
- Target directory (the project being worked on)
<target>/.worktreesand<target>/../.worktrees<target>/logs<target>/plans/tmp
For fixed configurations, use the sandboxed wrapper:
# Uses .srt-settings.json in current directory
./bin/sandboxed your-command [args...]
# Or specify settings file
GRITGUARD_SETTINGS=/path/to/config.json ./bin/sandboxed your-commandEdit templates/base.json for network and read restrictions. Use $HOME for paths - it's expanded at runtime:
{
"filesystem": {
"denyRead": ["$HOME/.ssh", "$HOME/.aws", "$HOME/.gnupg", "/root"],
"allowWrite": [],
"denyWrite": []
},
"network": {
"allowedDomains": ["api.anthropic.com", "api.openai.com", "github.com"],
"deniedDomains": [],
"allowLocalBinding": true
}
}Note: allowWrite paths are dynamically added based on the --repo target directory.
| Field | Meaning |
|---|---|
denyRead |
Paths to hide from the sandbox (sensitive credentials) |
allowWrite |
Paths where writing is permitted (auto-populated by --repo) |
denyWrite |
Paths explicitly blocked for writing |
| Field | Meaning |
|---|---|
allowedDomains |
Domains the sandbox can connect to (supports wildcards: *.github.com) |
deniedDomains |
Domains explicitly blocked |
allowLocalBinding |
Allow binding to localhost ports |
- Python 3.6+ (for config generation)
- Node.js 18+
@anthropic-ai/sandbox-runtimenpm package- Linux:
bubblewrap(bwrap),socat - macOS: Built-in
sandbox-exec - Docker mode: Docker 20.10+
GritGuard supports Docker-based isolation as an alternative to bubblewrap/sandbox-exec.
# Build the sandbox Docker image
docker build -t gritguard-sandbox:latest docker/# Run command in Docker sandbox
./bin/gritguard-docker your-command [args...]
# With explicit target directory
./bin/gritguard-docker selfassembler "Add feature" --repo /path/to/project
# Enable debug output
GRITGUARD_DEBUG=1 ./bin/gritguard-docker your-command| Variable | Description | Default |
|---|---|---|
GRITGUARD_DOCKER_IMAGE |
Docker image to use | gritguard-sandbox:latest |
GRITGUARD_DOCKER_NETWORK |
Network mode: bridge, none, host |
bridge |
GRITGUARD_DOCKER_PROXY |
Enable squid proxy for domain filtering | 0 |
GRITGUARD_DEBUG |
Enable debug output | 0 |
- bridge (default): Normal network access, no domain filtering
- none: Complete network isolation (no outbound connections)
- proxy (
GRITGUARD_DOCKER_PROXY=1): Domain allowlisting via squid proxy
| Feature | Docker | Bubblewrap |
|---|---|---|
| Startup time | ~500ms-1s | ~50ms |
| Platform support | Any with Docker | Linux only |
| Sensitive path protection | Paths not mounted | Active blocking |
| Network domain filtering | Via squid proxy | Native support |
# Run all tests (srt + Docker) - 71 tests total
./tests/test_all.sh
# Quick mode (skip network tests)
./tests/test_all.sh --quick
# Run only srt/bubblewrap tests
./tests/test_all.sh --srt
# Run only Docker tests
./tests/test_all.sh --docker| Suite | Tests | Description |
|---|---|---|
test_sandbox.sh |
15 | Full srt sandbox tests (includes network) |
test_sandbox_quick.sh |
8 | Quick srt tests (no network) |
test_gritguard.sh |
16 | Dynamic config and --repo flag tests |
test_docker.sh |
40 | Docker isolation tests |
- AI Coding Agents: Prevent agents from accessing credentials or modifying system files
- Autonomous Workflows: Limit blast radius of automated processes
- Development Sandboxes: Isolate experimental code execution
- CI/CD Pipelines: Secure build and test environments
gritguard selfassembler "task" --repo /path/to/project
│
├── 1. Parse command to find target directory
│
├── 2. Generate dynamic config (templates/base.json + write paths)
│
├── 3. Run: srt --settings <temp-config> "selfassembler task --repo ..."
│
└── 4. Cleanup temp config on exit
MIT