sandbox-rs
Lightweight process sandboxing for Linux
Things
- Unprivileged mode — works without root via user namespaces, Landlock, and setrlimit
- Privileged mode — full isolation with cgroups v2, chroot, and all namespace types
- Auto-detection — automatically picks the best mode for the current environment
- Seccomp BPF — six built-in syscall filtering profiles
- Landlock — filesystem access control without root (Linux 5.13+)
- Resource limits — memory, CPU, and PID constraints
- Streaming output — real-time stdout/stderr capture
Requirements
- Linux kernel 5.10+ (5.13+ for Landlock support)
- Root is optional — unprivileged mode uses user namespaces + seccomp + Landlock + setrlimit
Quick Start
Library
[]
= "0.1"
use ;
use Duration;
Note:
memory_peakandcpu_time_usrequire privileged mode (cgroups v2). In unprivileged mode these values are0.
CLI
# Run a program in a sandbox (auto-detects privilege mode)
# Use a security profile with resource limits
# Check system capabilities
# List seccomp profiles
Seccomp Profiles
Each profile includes all syscalls from profiles below it (cumulative).
| Profile | Syscalls |
|---|---|
Essential |
Process bootstrap only (~40): execve, mmap, brk, read, write, exit, ... |
Minimal |
Essential + signals, pipes, timers, process control (~110 total) |
IoHeavy |
Minimal + file manipulation: mkdir, chmod, unlink, rename, fsync, ... |
Compute |
IoHeavy + scheduling/NUMA: sched_setscheduler, mbind, membarrier, ... |
Network |
Compute + sockets: socket, bind, listen, connect, sendto, ... |
Unrestricted |
Network + privileged: ptrace, mount, bpf, setuid, ... |
Security
- Defense-in-depth: multiple isolation layers (namespaces, seccomp, Landlock, cgroups)
- Combine with AppArmor or SELinux for production use
- Kernel vulnerabilities can bypass sandbox boundaries — keep your kernel updated
- Not a replacement for VM-level isolation for fully untrusted code
License
MIT — see LICENSE for details.