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#

FamilySyscallsActionWhy
io_uringio_uring_setup, io_uring_enter, io_uring_registerERRNO(ENOSYS)Kernel LPE history (CVE-2021-41073, CVE-2023-2598)
TracingptraceKILLCross-process inspection
Process memoryprocess_vm_readv, process_vm_writevERRNO(EPERM)Runtime crash handlers probe these at startup
Kernel subsystemsbpf, userfaultfd, perf_event_openKILLeBPF loading, page fault interception, perf abuse
Module loadingkexec_load, kexec_file_load, init_module, finit_module, delete_moduleKILLKernel module/boot manipulation
Mount/swapmount, umount2, pivot_root, swapon, swapoffKILLFilesystem manipulation
New mount APIfsopen, fsmount, fsconfig, fspick, move_mount, open_tree, mount_setattrKILLLinux 5.2+ mount manipulation
Namespace escapeunshare, chroot, setnsKILLNested namespace creation, chroot escape
DAC bypassname_to_handle_at, open_by_handle_atKILLFile handle manipulation (CVE-2014-0038)
System clockreboot, settimeofday, clock_settime, acctKILLSystem state manipulation
Kernel keyringadd_key, keyctl, request_keyKILLNot namespaced (CVE-2016-0728)
NUMAmbind, set_mempolicy, move_pagesKILLMemory policy manipulation
Execution domainpersonalityERRNO(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:

  1. "Not available" filter (io_uring checks)
  2. "Not allowed" filter (diagnostic requests)
  3. "Stop" filter (exploit requests)
  4. 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.