seccomp: A Kernel-Level Allowlist for Syscalls
seccomp is a Linux kernel firewall for system calls (syscalls), restricting which operations a process can request. Docker and Kubernetes use it to harden containers against exploits. The footgun is creating a custom profile so restrictive it breaks your app.
Why it exists
Even a process running as a non-root user can access hundreds of powerful kernel system calls (syscalls). This creates a large attack surface. seccomp was created to enforce the principle of least privilege at the kernel level, reducing the potential damage a compromised process can do.
The mental model
Think of seccomp as a one-way gate. A process can ask the kernel to activate a seccomp profile, which is an allowlist of syscalls. From that moment on, any attempt by the process to use a syscall NOT on the list causes the kernel to terminate the process. It's an enforcement mechanism, not just an audit tool.
How it works
A seccomp profile is a set of rules, typically defined in a JSON file, that specifies a default action (like SCMP_ACT_ERRNO to block) and a list of syscalls to permit. When a container starts, Docker (or the container runtime) loads this profile and applies it to the container's processes. The kernel then intercepts every syscall made by these processes, checks it against the loaded filter, and takes the specified action. Docker's default profile allows about 300 of the 400+ available syscalls, blocking those that are rarely needed and historically risky.
When to use it
Always use seccomp to harden containerized applications, especially those exposed to the network or processing untrusted input. It is a fundamental layer in defense-in-depth for containers and is enabled by default in Docker, Kubernetes, and other modern container platforms for this reason.
When not to use it
Avoid disabling the default profile unless an application legitimately needs a blocked syscall (e.g., for certain performance tracing or hardware interaction). Crafting custom profiles is powerful but risky; a profile that is too restrictive can cause applications to fail in obscure ways. Debugging a seccomp-related crash requires understanding which syscall is being blocked and why.
One canonical example
A common privilege escalation technique involves creating a new user namespace inside a container via the unshare syscall. This can trick the host into granting the process root privileges. Docker's default seccomp profile explicitly blocks the unshare syscall. If an attacker gains access to a container and tries to run an exploit using this technique, the kernel will immediately terminate the malicious process, neutralizing the threat.
Interview question
What is the immediate consequence when a process, protected by an active seccomp profile, attempts to execute a forbidden system call?
- a.The system call is re-routed to a secure, isolated sandbox for execution.
- b.The system call is logged as a security event and allowed to proceed.
- c.The process's user ID is automatically changed to a less privileged one.
- d.The kernel immediately terminates the offending process.Correct
Why? this is the answer
The card states that any attempt by a process to use a syscall not on the allowlist causes the kernel to terminate the process. Seccomp is an enforcement mechanism, not merely an audit tool that logs events.
Just read this? Test yourself on what you have been reading.
Read the original → docs.docker.com
- #linux
- #security
- #containers
- #kernel
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.
See open roles