heel
A cross-platform Rust library for running LLM-generated code in secure sandboxes with native OS-level isolation.
Why heel
Docker is a great tool for running containers, with isolation provided by the Linux kernel. However, it has to rely on virtualization to provide isolation on non-Linux platforms, which blocks it to provide GPU and NPU access.
Heel is built at the top of native OS-level isolation mechanisms, such as sandbox-exec on macOS, landlock on Linux, and AppContainer on Windows. It reduces some security, but more lightweight and powerful.
Heel is not designed to be a general sandbox for running untrusted code.
Heel is designed to be a sandbox for running LLM-generated code in a secure environment. It is not designed to be a general sandbox for running untrusted code.
We provide three tier isolation level
- Strict: Most restricted, only allow read/write within sandbox's workdir.
- Default: Allow read/write within sandbox's workdir, and allow read-only access outside sandbox's workdir.
- Permissive: Least restricted, allow read/write access to all directories.
Platform Support
| Platform | Backend | Status |
|---|---|---|
| macOS | sandbox-exec with SBPL profiles |
✅ Fully implemented |
| Linux | Landlock (ABI v4) + Seccomp | ✅ Implemented (kernel 6.7+) |
| Windows | AppContainer | 🚧 Planned |
Features
- Native OS sandboxing - Uses platform-specific isolation mechanisms for maximum security
- Network policy enforcement - All traffic routes through a local proxy with configurable filtering
- Type-safe network policies - Generic
Sandbox<N: NetworkPolicy>enables compile-time policy composition - Fine-grained security controls - Protect home directories, credentials, cloud configs, and more
- IPC support - Type-safe communication between sandboxed processes and the host
- Python virtual environment support - Built-in venv creation and management
- Async-first, runtime-agnostic - Works with any
executor-corecompatible runtime (smol, tokio) - Automatic cleanup - Working directories and child processes are cleaned up on drop
Installation
Add to your Cargo.toml:
[]
= "0.1"
Install the CLI from the same crate:
Quick Start
use Sandbox;
async
Network Policies
By default, all network access is denied. Configure access using built-in policies:
use ;
// Allow specific domains (supports wildcards)
let policy = new;
let config = builder
.network
.build?;
let sandbox = with_config.await?;
Available policies:
DenyAll- Block all network access (default)AllowAll- Allow all network accessAllowList- Allow specific domains with wildcard supportCustomPolicy<F>- Custom async handler for dynamic filtering
Security Configuration
Fine-grained control over what the sandbox can access:
use ;
let security = builder
.protect_user_home // Block ~/
.protect_credentials // Block ~/.ssh, ~/.gnupg, keychains
.protect_cloud_config // Block ~/.aws, ~/.azure, etc.
.allow_gpu // Block GPU access
.build;
let config = builder
.security
.build?;
IPC Communication
Enable sandboxed processes to call host-registered commands:
use ;
use ;
// Register command and create sandbox
let router = new.register;
let config = builder.ipc.build?;
let sandbox = with_config.await?;
Sandboxed processes use the heel ipc subcommand to call registered commands.
Python Support
Built-in virtual environment management:
use ;
// Create a venv with packages
let venv_config = builder
.path
.packages
.build;
create.await?;
// Create sandbox with Python configured
let config = builder
.python
.build?;
let sandbox = with_config.await?;
// Run Python code
let output = sandbox
.run_python
.await?;
CLI
The heel crate also ships the heel CLI:
# Run a command in sandbox
# Interactive shell in sandbox
# Run Python script with venv
License
MIT OR Apache-2.0