kavach
Sandbox execution framework for Rust.
Backend abstraction, strength scoring, policy engine, credential proxy, and lifecycle management — in a single crate. Execute untrusted code across 8 isolation backends with quantitative security guarantees.
Name: Kavach (कवच, Sanskrit) — armor, shield. Protects both what's inside and what's outside. Extracted from SecureYeoman's production sandbox framework.
What it does
kavach is the execution sandbox — it wraps untrusted code in isolation and gives you a number (0–100) that tells you how protected you are. Applications build their agent execution on top of kavach.
| Capability | Details |
|---|---|
| 8 backends | Process, gVisor, Firecracker, WASM, OCI, SGX, SEV, Noop |
| Strength scoring | Quantitative 0–100 score per sandbox (not "secure"/"insecure") |
| Policy engine | Seccomp, Landlock, network allowlists, resource limits, presets |
| Credential proxy | Inject secrets via env/pipe — never touches sandbox filesystem |
| Lifecycle FSM | Created → Running → Paused → Stopped → Destroyed with audit hooks |
| Externalization gate | Nothing leaves the sandbox without policy approval |
| Builder pattern | Fluent config: .backend(GVisor).policy_seccomp("strict").network(false) |
Architecture
Consumer (SY, daimon, AgnosAI)
│
▼
Sandbox::create(config) → exec("command") → destroy()
│
├── Policy Engine (seccomp, Landlock, network, resources)
├── Strength Scoring (0-100 per backend + modifiers)
├── Credential Proxy (secrets injection)
│
▼
Backend Dispatch
├── Process (50) — seccomp + namespaces + cgroups
├── OCI (55) — runc/crun container
├── WASM (65) — wasmtime + WASI
├── gVisor (70) — user-space kernel (runsc)
├── SGX (80) — Intel hardware enclave
├── SEV (82) — AMD encrypted VM
└── Firecracker (90) — lightweight microVM
See docs/architecture/overview.md for the full architecture.
Quick start
[]
= "0.21"
use ;
async
Strength scoring
use ;
// Base score per backend
let process_score = base_score; // 50
let gvisor_score = base_score; // 70
let firecracker_score = base_score; // 90
// Policy modifiers raise the score
let strict = strict;
let score = score_backend;
println!; // "63 (standard)" — seccomp + ro rootfs + limits
Credential proxy
use ;
let mut proxy = new;
proxy.register;
let refs = vec!;
let env_vars = proxy.env_vars;
// env_vars = [("OPENAI_API_KEY", "sk-secret-12345")]
// The secret never touches the sandbox filesystem
Policy presets
use SandboxPolicy;
let minimal = minimal; // No restrictions
let basic = basic; // Seccomp + no network
let strict = strict; // Everything locked down
Features
| Flag | Backend | Default |
|---|---|---|
process |
Process isolation (seccomp, Landlock, namespaces) | yes |
gvisor |
gVisor user-space kernel | no |
firecracker |
Firecracker microVM | no |
wasm |
WebAssembly (wasmtime + WASI) | no |
oci |
OCI container (runc/crun) | no |
sgx |
Intel SGX enclave | no |
sev |
AMD SEV encrypted VM | no |
full |
All backends | no |
# Just process + WASM sandboxing
= { = "0.21", = ["wasm"] }
# Everything
= { = "0.21", = ["full"] }
Strength scoring scale
| Score | Label | Example |
|---|---|---|
| 0–29 | minimal | Noop (testing only) |
| 30–49 | basic | Process without seccomp |
| 50–69 | standard | Process + seccomp, OCI, WASM |
| 70–84 | hardened | gVisor, SGX, SEV, sy-agnos |
| 85–100 | fortress | Firecracker + full policy |
Who uses this
| Project | Usage |
|---|---|
| SecureYeoman | All agent execution — 279 MCP tools sandboxed |
| AGNOS (daimon) | Agent sandbox lifecycle, 7 backend dispatch |
| AgnosAI | Sandboxed crew execution (WASM/OCI agents) |
| aethersafta | Sandboxed compositor plugin execution |
| sutra | Sandboxed remote command execution on fleet |
Roadmap
| Version | Milestone | Key features |
|---|---|---|
| 0.21.3 | Foundation | Backend trait, scoring, policy, credentials, lifecycle FSM |
| 0.22.3 | Process backend | seccomp-bpf, Landlock, namespaces, cgroups, externalization gate |
| 0.23.3 | gVisor + OCI | runsc integration, OCI spec generation, container lifecycle |
| 0.24.3 | Firecracker + WASM | microVM, wasmtime + WASI, checkpoint/restore |
| 0.25.3 | Hardware enclaves | Intel SGX, AMD SEV-SNP, attestation |
| 0.26.3 | Consumer adoption | SY, daimon, AgnosAI integration |
| 1.0.0 | Stable API | All 8 backends, 90%+ coverage, formally verified FSM |
Full details: docs/development/roadmap.md
Building from source
# Build (process backend only — no system deps)
# Build with WASM support
# Run tests
# Run all CI checks
Versioning
Pre-1.0 releases use 0.D.M SemVer — e.g. 0.21.3 = March 21st.
Post-1.0 follows standard SemVer.
License
AGPL-3.0-only. See LICENSE for details.