If you run containers, you already use seccomp. Docker applies a default profile to every container unless you turn it off, systemd can attach a filter to any service with one line of config, and sandboxes from browsers to microVM monitors lean on it. Yet for most application developers it stays a black box that occasionally produces a baffling Operation not permitted.
This post explains what seccomp does in terms an application developer cares about, how to tell whether a process is filtered, how to add a filter to your own service, and, quoting the kernel's own documentation, what it is not.
The one-paragraph version
Every time a program asks the kernel to do something, such as open a file, start a process or create a socket, it makes a system call. Linux exposes hundreds of them, and a typical service uses a small fraction. seccomp lets a process install a filter that the kernel runs on each system call before handling it. The filter looks at the call's number and its arguments and returns a verdict: allow it, fail it with an error, kill the process, or one of a few other actions. Fewer reachable system calls means less kernel code an attacker can poke at.
How a filter decides
The kernel documentation for seccomp filters describes the mechanism. A few details matter in practice.
Filters are small BPF programs. They run over a structure holding the system call number, the architecture and the arguments. Nobody writes the BPF by hand; libraries such as libseccomp, and tools like Docker and systemd, compile a readable policy into it.
Filters cannot follow pointers. The docs note that BPF programs may not dereference pointers, so a filter can only evaluate argument values directly. That is deliberate, because it avoids time-of-check-to-time-of-use races. The consequence: a filter can allow or block openat as a whole, or check its flags argument, but it cannot see the path being opened, because the path is behind a pointer. Path-based rules need other tools, such as Landlock or an LSM like AppArmor or SELinux.
There is a fixed set of verdicts. In precedence order they include killing the process, killing the thread, sending a signal (TRAP), failing with an errno, handing the decision to a user-space supervisor (USER_NOTIF), notifying a ptrace tracer, logging, and allowing. When several filters are stacked, the most severe verdict wins.
Filters are inherited and only tighten. If the filter allows fork, clone and execve, child processes are bound by the same filters. More filters can be added later, but an installed filter cannot be removed. Installing one requires either CAP_SYS_ADMIN or setting the no_new_privs flag first, which stops the process and its children from gaining privileges through setuid binaries. The docs explain that this keeps a filter from being imposed on a more privileged child.
Is my process filtered?
Look at /proc/<pid>/status. The man page documents the fields:
grep -E 'NoNewPrivs|Seccomp' /proc/self/status Seccomp is 0 for no filtering, 1 for strict mode (the original, very limited mode) and 2 for filter mode. On Linux 5.9 and later, Seccomp_filters counts how many filters are attached. Run it on your laptop, then inside a container, and compare.
The filter you already use: Docker's default profile
Docker's seccomp documentation describes its default profile as an allowlist that blocks around 44 system calls out of more than 300, which it calls moderately protective while staying widely compatible. The blocked calls include things a normal application has no business doing from a container, such as loading kernel modules, rebooting or changing the system clock.
Two practical points:
- If something works on your machine but fails in a container with
Operation not permitted, a blocked system call is one suspect. The fix is a custom profile that allows the one call you need, not--security-opt seccomp=unconfined, which turns filtering off entirely. - Each blocked call in Docker's table comes with a reason, and many are also gated by a capability. Reading that table before allowing a call tells you what you are giving up.
Adding a filter to your own service
You do not need to write BPF to get value from seccomp. If your service runs under systemd, the SystemCallFilter= setting in systemd.exec takes named groups of system calls. The docs describe @system-service as a reasonable set for common system services and the recommended starting point for allow-listing:
[Service] NoNewPrivileges=yes SystemCallFilter=@system-service SystemCallErrorNumber=EPERM With SystemCallErrorNumber=EPERM, a blocked call fails with an error instead of killing the service, which makes the first rollout much less dramatic. A workable process:
- Start with the broad group and error-instead-of-kill.
- Run your test suite and a day of real traffic in staging.
- Watch logs for unexpected permission errors and investigate each one.
- Tighten further only where you understand the service's needs.
If you want the service to install its own filter at startup, after any privileged setup, the libseccomp library and its Go and Python bindings compile a readable policy into a filter for you.
What seccomp is not
The kernel docs are blunt about this, in a section titled "What it isn't": system call filtering "isn't a sandbox". It "provides a clearly defined mechanism for minimizing the exposed kernel surface" and is "meant to be a tool for sandbox developers to use."
In practice that means:
- Allowed calls are fully powerful. A filter that allows
read,write,openatandconnect, which almost every program needs, lets the program read any file its user can read and connect wherever the network allows. - It does not separate data. It has no notion of which files or hosts are sensitive. That is the job of permissions, namespaces, LSMs and network policy.
- The kernel is still shared. A bug in an allowed system call is still reachable. seccomp shrinks the attack surface; it does not remove it.
That is why serious sandboxes use seccomp as one layer among several. Our post on Firecracker's defense in depth shows one stack: hardware virtualization, a minimal device model, seccomp filters on the monitor's threads, and a jailer that limits the rest. Each layer covers gaps in the others.
Takeaways
- seccomp filters system calls by number and argument values, never by what pointers point to.
- Check
/proc/<pid>/statusto see whether a process is filtered. - Do not disable Docker's default profile to fix one failing call; allow the call.
-
SystemCallFilter=@system-serviceis a cheap first step for systemd services. - Treat seccomp as attack surface reduction, not as a boundary for running code you do not trust.
Originally published on the Sandscale blog.

