procjail
Run untrusted code in a sandbox. procjail picks the best containment strategy available on the system (bubblewrap > firejail > unshare > rlimits), strips secret environment variables, enforces timeouts, and reports resource usage.
use ;
use Path;
let config = builder
.runtime
.max_memory_mb
.max_cpu_seconds
.timeout_seconds
.build;
let mut proc = spawn.unwrap;
proc.send.unwrap;
let response = proc.recv.unwrap;
Containment strategies
| Strategy | PID isolation | Network | Filesystem | How |
|---|---|---|---|---|
| Bubblewrap | Yes | Yes | Full (ro-bind) | Recommended. Rootless. |
| Firejail | Yes | Yes | Full (--private) | Adds seccomp + rlimits. |
| Unshare | Yes | Yes | Partial (mount ns) | No full FS restriction. |
| RlimitsOnly | No | No | No | Harness enforces limits. Last resort. |
procjail auto-detects which strategies work on the current system. Override with .strategy(Strategy::Bubblewrap).
Secret stripping
36 environment variables are stripped by default (AWS keys, GitHub tokens, database URLs, API keys). Custom additions via .env_strip(&["MY_SECRET"]). The passthrough list cannot re-add stripped secrets.
Resource reporting
let usage = proc.wait_with_usage.unwrap;
println!;
println!;
println!;
Contributing
Pull requests are welcome. There is no such thing as a perfect crate. If you find a bug, a better API, or just a rough edge, open a PR. We review quickly.
License
MIT. Copyright 2026 CORUM COLLECTIVE LLC.