Linux sandboxing frameworks provide essential isolation layers for running untrusted workloads on self-hosted servers. This guide compares three major approaches: Landlock (the kernel LSM for filesystem sandboxing), Seccomp-BPF (system call filtering), and Bubblewrap (user-space sandboxing). Each offers different trade-offs between security guarantees, ease of configuration, and performance overhead.
What Is Linux Sandboxing?
Sandboxing restricts what a process can do — which files it can access, which system calls it can invoke, and which kernel resources it can manipulate. On self-hosted servers running multiple services, sandboxing prevents a compromised application from affecting other services or the host system.
The Linux kernel provides multiple sandboxing mechanisms at different levels:
- Mandatory Access Control (MAC) — Kernel-level enforcement via LSM hooks (Landlock, AppArmor, SELinux)
- System call filtering — Restricts which syscalls a process can invoke (Seccomp-BPF)
- User-space isolation — Combines namespaces, capabilities, and filesystem mounts (Bubblewrap)
Understanding the differences between these approaches helps you choose the right tool for each workload.
Landlock: Filesystem Sandbox LSM
GitHub: kernel source (built into Linux 5.13+) | Stars: N/A (in-tree)
Landlock is a Linux Security Module (LSM) introduced in kernel 5.13 that enables unprivileged processes to restrict their own filesystem access. Unlike AppArmor or SELinux, which require root configuration, Landlock allows any process to define its own sandbox rules.
Key Features
- Unprivileged sandboxing — No root access needed to set up rules
- Filesystem-focused — Controls file read, write, execute, and directory traversal
- Inheritance — Rules are inherited by child processes automatically
- No policy language — Rules are set via
prctl()andlandlock_create_ruleset()syscalls
How Landlock Works
Landlock uses a ruleset-based approach. A process creates a ruleset, adds access rules for specific file paths, then applies the ruleset to itself:
| |
Docker Compose Example
Running a service with Landlock requires kernel 5.13+ and a container runtime that supports Landlock passthrough:
| |
Landlock Access Rights
| Access Right | Description | Kernel Version |
|---|---|---|
LANDLOCK_ACCESS_FS_EXECUTE | Execute a file | 5.13+ |
LANDLOCK_ACCESS_FS_WRITE_FILE | Write to a file | 5.13+ |
LANDLOCK_ACCESS_FS_READ_FILE | Read from a file | 5.13+ |
LANDLOCK_ACCESS_FS_READ_DIR | List directory contents | 5.13+ |
LANDLOCK_ACCESS_FS_REMOVE_DIR | Remove a directory | 5.13+ |
LANDLOCK_ACCESS_FS_REMOVE_FILE | Remove a file | 5.13+ |
LANDLOCK_ACCESS_FS_MAKE_CHAR | Create character device | 5.13+ |
LANDLOCK_ACCESS_FS_MAKE_DIR | Create a directory | 5.13+ |
LANDLOCK_ACCESS_FS_REFER | Rename/hardlink files | 5.13+ |
LANDLOCK_ACCESS_FS_TRUNCATE | Truncate a file | 5.13+ |
Seccomp-BPF: System Call Filtering
GitHub: kernel source (built into Linux 3.17+) | Stars: N/A (in-tree)
Seccomp (Secure Computing Mode) with BPF (Berkeley Packet Filter) filtering restricts which system calls a process can make. It is the foundation of container sandboxing and is used by Docker, Kubernetes, and systemd by default.
Key Features
- Syscall-level control — Filter individual system calls
- BPF filtering — Apply complex rules based on syscall arguments
- Container default — Docker uses a default seccomp profile
- Whitelist/blacklist — Either allow only specific syscalls or block specific ones
Seccomp Profile Example
A Docker seccomp profile in JSON format:
| |
Docker Compose with Seccomp
| |
Common Seccomp Actions
| Action | Behavior | Use Case |
|---|---|---|
SCMP_ACT_ALLOW | Permit the syscall | Whitelisted operations |
SCMP_ACT_ERRNO | Return error (errno) | Graceful denial |
SCMP_ACT_KILL | Kill the process | Dangerous syscalls |
SCMP_ACT_TRAP | Send SIGSYS signal | Debug/diagnostic |
SCMP_ACT_LOG | Allow but log | Audit mode |
Bubblewrap: User-Space Sandbox
GitHub: https://github.com/containers/bubblewrap | Stars: 3,100+
Bubblewrap (bwrap) is a user-space sandboxing tool that combines Linux namespaces, capabilities, and filesystem mounts to create isolated environments. Unlike Landlock and Seccomp, which are kernel-level mechanisms, Bubblewrap operates entirely in user space.
Key Features
- No root required — Uses unprivileged user namespaces
- Full isolation — Combines PID, network, mount, and IPC namespaces
- Filesystem virtualization — Bind mounts, tmpfs overlays, read-only roots
- Flatpak foundation — Powers Flatpak application sandboxing
Installation
| |
Basic Usage
| |
Docker Compose with Bubblewrap
| |
Comparison: Landlock vs Seccomp-BPF vs Bubblewrap
| Feature | Landlock | Seccomp-BPF | Bubblewrap |
|---|---|---|---|
| Layer | Kernel LSM | Kernel syscall filter | User-space tool |
| Primary Scope | Filesystem access | System call filtering | Full namespace isolation |
| Requires Root | No | No (for profile creation) | No (unprivileged namespaces) |
| Kernel Version | 5.13+ | 3.17+ | Any (user-space) |
| Container Support | Limited (needs runtime support) | Native (Docker default) | Yes (with namespace support) |
| Performance Overhead | Minimal | Minimal | Low (namespace setup) |
| Configuration | C API / liblandlock | JSON profile | CLI arguments |
| Child Inheritance | Automatic | Automatic | Per-process |
| Network Isolation | No | No | Yes (–unshare-net) |
| Best For | Untrusted file processing | Container syscall hardening | Application sandboxing |
Combining Sandboxing Layers
The strongest security comes from combining multiple sandboxing mechanisms:
| |
In practice, Docker already combines Seccomp with AppArmor/SELinux. Adding Landlock provides an additional filesystem-level restriction layer that works independently of the other mechanisms.
Why Self-Host Sandboxing Frameworks?
Self-hosted applications often process untrusted data — user uploads, API requests, third-party webhooks. Without sandboxing, a vulnerability in any service can compromise the entire server. Sandboxing frameworks provide defense-in-depth:
Containment of compromised services — If a web application is exploited, sandboxing limits the attacker’s ability to read /etc/shadow, access other services’ data, or pivot to the host system.
Multi-tenant isolation — Self-hosted platforms serving multiple users or organizations benefit from per-tenant sandboxing, ensuring that one tenant’s compromised service cannot access another’s data.
Compliance and auditing — Many security standards (SOC 2, ISO 27001) require process isolation and least-privilege execution. Sandboxing frameworks provide measurable controls for audit purposes.
Reduced blast radius — Even with perfect application security, vulnerabilities in dependencies (Log4Shell, etc.) are inevitable. Sandboxing ensures that a single compromised container has minimal impact on the broader infrastructure.
For container security scanning, see our container image analysis guide. For kernel-level filesystem security, our native filesystem encryption comparison covers complementary protections.
FAQ
What is the difference between Landlock and Seccomp?
Landlock restricts filesystem access at the LSM level, controlling which files and directories a process can read, write, or execute. Seccomp restricts system calls, controlling which kernel functions a process can invoke. They operate at different layers and are complementary — Landlock controls what files you can access, while Seccomp controls what kernel operations you can perform.
Can I use Landlock without root access?
Yes. Landlock is specifically designed for unprivileged sandboxing. Any process can create a Landlock ruleset and apply it to itself using prctl(PR_SET_NO_NEW_PRIVS, 1) followed by landlock_restrict_self(). This makes Landlock ideal for sandboxing user applications without requiring administrative privileges.
Does Docker support Landlock?
Docker does not natively support Landlock ruleset configuration as of 2026. However, Landlock rules can be applied from within a container, and container runtimes like containerd and CRI-O have experimental Landlock support. For now, Seccomp remains the primary sandboxing mechanism in Docker.
Is Bubblewrap as secure as kernel-level sandboxing?
Bubblewrap uses the same kernel mechanisms (namespaces, capabilities) as Docker and other container runtimes, so its isolation is kernel-enforced. However, because it operates in user space, the configuration is more flexible and easier to audit. The security boundary is the same kernel — the difference is in how the isolation is set up and managed.
Which sandboxing approach should I use for my self-hosted services?
For containers, use Docker’s default Seccomp profile plus a custom profile for your specific service. For user-space applications that need filesystem isolation, use Bubblewrap. For fine-grained filesystem access control within an application, use Landlock. The best approach combines all three: namespaces for isolation, Seccomp for syscall filtering, and Landlock for filesystem restrictions.
Does sandboxing affect performance?
The performance overhead of all three mechanisms is minimal. Landlock adds approximately 1-2% overhead to filesystem operations. Seccomp-BPF filtering adds less than 1% overhead per syscall. Bubblewrap’s namespace setup has a one-time cost during process startup but no ongoing runtime overhead. For most self-hosted workloads, sandboxing does not measurably impact performance.
Can I combine Landlock and Seccomp in the same process?
Yes, and this is the recommended approach. Seccomp restricts which syscalls the process can make, and Landlock restricts which files the process can access through those allowed syscalls. Together, they provide defense-in-depth: even if a Seccomp rule is too permissive, Landlock provides an additional filesystem-level barrier.