Seccomp Filtering#
A program asks the system for things all the time: open a file, start a process, use the network. Each of those requests is a syscall. Rustbox puts a small filter (seccomp-BPF) in front of every box that checks each request before the kernel sees it, and blocks the 51 that code would need to break out. This is layer 5 of the 8 layers of protection.
Block a list, allow the rest#
We block the specific requests that could get code out of the box and allow everything else.
Why not allow only a fixed list instead? Because the languages we run need a lot from the system, and what they need changes:
- Python makes over 100 different requests just for
import sys. A fixed allowed list would break when Python updates. - Java starts threads and uses futex, mmap and clone, and that changes between small JVM versions.
- The C++ standard library checks for features (io_uring, statx) when it starts. Killing those checks would kill harmless programs.
Blocking exactly what attackers need keeps working as languages and versions change.
The 51 blocked requests#
| Family | Syscalls | Action | Why |
|---|---|---|---|
| io_uring | io_uring_setup, io_uring_enter, io_uring_register | ERRNO(ENOSYS) | Kernel LPE history (CVE-2021-41073, CVE-2023-2598) |
| Tracing | ptrace | KILL | Cross-process inspection |
| Process memory | process_vm_readv, process_vm_writev | ERRNO(EPERM) | Runtime crash handlers probe these at startup |
| Kernel subsystems | bpf, userfaultfd, perf_event_open | KILL | eBPF loading, page fault interception, perf abuse |
| Module loading | kexec_load, kexec_file_load, init_module, finit_module, delete_module | KILL | Kernel module/boot manipulation |
| Mount/swap | mount, umount2, pivot_root, swapon, swapoff | KILL | Filesystem manipulation |
| New mount API | fsopen, fsmount, fsconfig, fspick, move_mount, open_tree, mount_setattr | KILL | Linux 5.2+ mount manipulation |
| Namespace escape | unshare, chroot, setns | KILL | Nested namespace creation, chroot escape |
| DAC bypass | name_to_handle_at, open_by_handle_at | KILL | File handle manipulation (CVE-2014-0038) |
| System clock | reboot, settimeofday, clock_settime, acct | KILL | System state manipulation |
| Kernel keyring | add_key, keyctl, request_key | KILL | Not namespaced (CVE-2016-0728) |
| NUMA | mbind, set_mempolicy, move_pages | KILL | Memory policy manipulation |
| Execution domain | personality | ERRNO(EPERM) | Blocks READ_IMPLIES_EXEC |
Three answers#
Not every blocked request gets the same answer:
-
Errno(ENOSYS), "not available", for feature checks (io_uring). The program hears "not supported" and uses a safe alternative, so it doesn't crash just for checking. -
Errno(EPERM), "not allowed", for harmless diagnostic requests (process_vm_readv/writev, personality). Crash handlers in language runtimes carry on instead of being killed. -
KillProcess, "stopped", for requests only an exploit makes (ptrace, bpf, mount). The program is stopped at once. No second chance.
How it is built#
The filter is built with the seccompiler crate (from AWS Firecracker). Four filters are stacked:
- "Not available" filter (io_uring checks)
- "Not allowed" filter (diagnostic requests)
- "Stop" filter (exploit requests)
- A
clone(NEWUSER)check that blocks creating user namespaces
The kernel runs all four and applies the strictest answer.
Why clone is checked, not blocked#
Every program uses clone to start processes and threads, so blocking it would break everything. Instead, a separate filter looks inside each clone request and blocks only the one flag (CLONE_NEWUSER) that would create a user namespace.