seacomb: formally verified seccomp compiler
seacomb is a Rust library for compiling and enforcing
seccomp policies,
which is a Linux kernel feature for filtering/intercepting syscalls and sandboxing.
For example, Chrome
and Firefox
use seccomp to sandbox the processes that render web pages,
and Docker
and systemd
use it to restrict containers and services.
By declaring rules in a similar style to libseccomp,
seacomb compiles and registers these rules using a formally verified compiler to cBPF.
use *;
use Write;
// Allow any syscall when no rule matches.
let mut filter = new_native.unwrap;
// Make write to stderr (fd 2) fail with EPERM.
filter.add_rule.unwrap;
// Kill the process on execve.
filter.add_rule.unwrap;
Supported architectures: x86, x86-64, 32-bit ARM (little-endian), and AArch64.
What has been formally verified
seacomb is developed using Verus,
an automated program verifier for Rust.
Formally verified properties:
- Compiler correctness:
seacomb's policy compiler always produces cBPF filters equivalent to the source policy, relative to the formal semantics of policies and cBPF insrc/spec. This rules out miscompilations like these in libseccomp:- CVE-2019-9893:
64-bit
<,<=,>,>=argument comparisons were generated incorrectly, so filters could be bypassed. - #148: the optimizer merged code blocks that were not actually duplicates, which broke Tor's sandbox.
- GHSA-4q85-33p6-j5g6: merging overlapping 64-bit comparison rules let denied syscalls through.
- CVE-2019-9893:
64-bit
- Determinism: A policy picks exactly one action for each syscall.
- Chaining: Installing multiple policies is equivalent to evaluating them in order, verified against the kernel's precedence and tie-breaking rules.
To verify the proofs, install Verus, and run:
Without verification, this crate is also completely compatible with cargo.
Testing
QEMU is a prerequisite for testing (install with, e.g., brew install qemu).
To run all tests on all supported architectures, or on one: