NsJail is a Linux process isolation tool using namespaces, resource limits, cgroup controls, and seccomp-bpf filters. It can confine shells, services, and untrusted programs with configurable jails.
Overview
NsJail wraps processes in Linux namespaces and optional chroot or pivot root filesystem views, with read-only bind mounts, tmpfs, and custom proc mounts. It supports multiple run modes: a one-shot execution, inetd-style TCP listening with a process per connection, direct execve without a supervisor, and repeated rerun suited to fuzzing workflows.
Resource limits cover wall time, CPU time, address space, open files, and process counts, with cgroup integration for memory, PIDs, CPU, and network class on v1 and v2. Network isolation can clone interfaces, use MACVLAN, or userland networking via pasta. Seccomp policies use Kafel BPF syntax, supplied as files or inline strings.
Configuration can be driven from protobuf config files or command-line flags, with example configs for sandboxes ranging from bash to Firefox with networking. Documented scenarios include CTF challenge hosting, fuzzing loops, desktop application sandboxing, and minimal filesystem exposure for single binaries.
Installation paths include building from source on Debian-style dependencies or running via a Docker image build. The tool is a command-line program invoked on Linux hosts.
Key features
- LISTEN, ONCE, EXECVE, and RERUN modes
- UTS, mount, PID, IPC, net, user cgroups
- Chroot, pivot root, and bind mounts
- Kafel seccomp-bpf policies
- Cgroup v1 and v2 limits
- MACVLAN and pasta networking
- Protobuf jail configuration files
- CPU, memory, file descriptor limits
Use cases
- CTF networked service isolation
- Repeated fuzzing runs
- Sandboxing desktop GUI apps
- Minimal filesystem command execution
- Inetd-style TCP jails