Bashkit
Sandboxed bash interpreter for multi-tenant environments. Written in Rust.
Features
- POSIX compliant - Substantial IEEE 1003.1-2024 Shell Command Language compliance
- Sandboxed execution - No real filesystem access by default
- Virtual filesystem - InMemoryFs, OverlayFs, MountableFs
- Resource limits - Command count, loop iterations, function depth
- Network allowlist - Control HTTP access per-domain
- Async-first - Built on tokio
- Experimental: Git support - Sandboxed git operations on the virtual filesystem (
gitfeature) - Experimental: Python support - Embedded Python interpreter via Monty (
pythonfeature)
Quick Start
use Bash;
async
Built-in Commands (81)
| Category | Commands |
|---|---|
| Core | echo, printf, cat, nl, read |
| Navigation | cd, pwd, ls, find |
| Flow control | true, false, exit, return, break, continue, test, [ |
| Variables | export, set, unset, local, shift, source, ., eval, readonly, times |
| Text processing | grep, sed, awk, jq, head, tail, sort, uniq, cut, tr, wc, paste, column, diff, comm, strings |
| File operations | mkdir, rm, cp, mv, touch, chmod, rmdir |
| File inspection | file, stat, less |
| Archives | tar, gzip, gunzip |
| Byte tools | od, xxd, hexdump |
| Utilities | sleep, date, basename, dirname, timeout, wait, watch |
| Disk | df, du |
| Pipeline | xargs, tee |
| Shell | bash, sh (sandboxed re-invocation), : |
| System info | whoami, hostname, uname, id, env, printenv, history |
| Network | curl, wget (requires allowlist) |
| Experimental | python, python3 (requires python feature), git (requires git feature) |
Shell Features
- Variables and parameter expansion (
$VAR,${VAR:-default},${#VAR}) - Command substitution (
$(cmd)) - Arithmetic expansion (
$((1 + 2))) - Pipelines and redirections (
|,>,>>,<,<<<) - Control flow (
if/elif/else,for,while,case) - Functions (POSIX and bash-style)
- Arrays (
arr=(a b c),${arr[@]},${#arr[@]}) - Glob expansion (
*,?) - Here documents (
<<EOF)
Configuration
use ;
use Arc;
let limits = new
.max_commands
.max_loop_iterations
.max_function_depth;
let mut bash = builder
.fs
.env
.cwd
.limits
.build;
Sandbox Identity
Configure the sandbox username and hostname for whoami, hostname, id, and uname:
let mut bash = builder
.username // Sets whoami, id, and $USER env var
.hostname // Sets hostname, uname -n
.build;
// whoami → "deploy"
// hostname → "my-server"
// id → "uid=1000(deploy) gid=1000(deploy)..."
// echo $USER → "deploy"
Experimental: Git Support
Enable the git feature for sandboxed git operations on the virtual filesystem.
All git data lives in the VFS — no host filesystem access.
[]
= { = "0.1", = ["git"] }
use ;
let mut bash = builder
.git
.build;
// Local operations: init, add, commit, status, log
// Branch operations: branch, checkout, diff, reset
// Remote operations: remote add/remove, clone/push/pull/fetch (sandbox mode)
See specs/010-git-support.md for the full specification.
Experimental: Python Support
Enable the python feature to embed the Monty Python interpreter (pure Rust, Python 3.12).
Python code runs in-memory with configurable resource limits and VFS bridging — files created
by bash are readable from Python and vice versa.
[]
= { = "0.1", = ["python"] }
use Bash;
let mut bash = builder.python.build;
// Inline code
bash.exec.await?;
// Script files from VFS
bash.exec.await?;
// VFS bridging: pathlib.Path operations work with the virtual filesystem
bash.exec.await?;
bash.exec.await?; // "hello from python"
Limitations: no open() (use pathlib.Path), no network, no classes, no third-party imports.
See crates/bashkit/docs/python.md for the full guide.
Virtual Filesystem
use ;
use Arc;
// Layer filesystems
let base = new;
let overlay = new;
// Mount points
let mut mountable = new;
mountable.mount;
CLI Usage
# Run a script
# Interactive REPL
Development
LLM Eval Results
Bashkit includes an eval harness that measures how well LLMs use bashkit as a bash tool in agentic workloads — 25 tasks across 10 categories.
| Model | Score | Tasks Passed | Tool Call Success | Duration |
|---|---|---|---|---|
| Claude Haiku 4.5 | 98% | 23/25 | 87% | 2.9 min |
| Claude Opus 4.6 | 93% | 21/25 | 87% | 8.7 min |
| GPT-5.2 | 81% | 18/25 | 78% | 3.4 min |
Tool call success improved +8–19% after recent interpreter fixes. See the detailed analysis for category breakdown, remaining gaps, and model behavior differences.
Benchmarks
Bashkit includes a benchmark tool to compare performance against bash and just-bash.
See crates/bashkit-bench/README.md for methodology and assumptions.
Python Bindings
Python bindings with LangChain integration are available in crates/bashkit-python.
=
= await
Security
Bashkit is designed as a sandboxed interpreter for untrusted scripts. See the security policy for reporting vulnerabilities and the threat model for detailed analysis of 60+ identified threats.
Acknowledgments
This project was inspired by just-bash from Vercel Labs. Huge kudos to the Vercel team for pioneering the idea of a sandboxed bash interpreter for AI-powered environments. Their work laid the conceptual foundation that made Bashkit possible.
Ecosystem
Bashkit is part of the Everruns ecosystem.
License
MIT