Every process on Linux can call into hundreds of kernel system calls, and most kernel privilege escalation and container escape bugs are reached through calls the workload never needed. seccomp (secure computing mode) lets a process, or the service manager or container runtime that starts it, install a filter that allows, denies, logs or kills on individual system calls. It is one of the cheapest ways to shrink the kernel attack surface, yet many Kubernetes clusters still run pods unconfined and most systemd services ship with no filter at all. This guide explains how seccomp filters work, what they do and do not protect, how to apply them to systemd services, Docker and Kubernetes, how to build custom profiles safely, and how to monitor them. It is for Linux platform engineers, container platform teams and detection engineers.
Key takeaways
- seccomp reduces kernel attack surface; it is not a sandbox on its own. The kernel documentation says so directly. Combine it with capabilities, namespaces and an LSM such as SELinux or AppArmor.
- Turn on the runtime default everywhere first: Docker applies a default profile, but Kubernetes pods are unconfined unless a profile is set or the kubelet's seccomp default is enabled.
- Privileged containers ignore seccomp: a pod with
privileged: truealways runs unconfined, so policy must block privileged pods as well. - Use systemd's syscall groups for services:
SystemCallFilter=@system-servicewithSystemCallArchitectures=nativeis a practical starting point for most daemons. - Build custom profiles in log mode first, then enforce, and treat profile changes as code with tests, because a missing syscall breaks the workload.
What seccomp is and what it is not
Linux has two seccomp modes. Strict mode (SECCOMP_SET_MODE_STRICT) allows only read, write, _exit and sigreturn, and is rarely useful outside special cases. Filter mode (SECCOMP_SET_MODE_FILTER, often called seccomp-bpf) loads a classic BPF program that inspects each system call's number, architecture and register arguments and returns an action. Filter mode is what Docker, containerd, CRI-O, systemd, browsers and many daemons use.
- Who can install a filter: a process must have set
no_new_privsor holdCAP_SYS_ADMINin its user namespace; otherwise the call fails with EACCES. This stops an unprivileged user from filtering a setuid program into misbehaving. - Inheritance: if the filter allows
fork,cloneandexecve, children and executed programs stay under the same filter. More filters can be stacked; the most restrictive action wins. - Arguments only, not memory: BPF filters can test register values but cannot dereference pointers. A filter can block
clonewith namespace flags, but it cannot inspect a path string passed toopen. File access policy belongs to an LSM. - Architecture matters: system call numbers differ between ABIs (for example x86-64, x32 and i386). A filter that does not check the architecture can be bypassed by calling through another ABI. The kernel documentation names this as the most common pitfall.
- Not a policy engine: the kernel documentation states that system call filtering "isn't a sandbox". It removes kernel entry points; it does not decide which files, networks or users a process may reach.
Filter actions
| Action (highest precedence first) | Effect | Typical use |
|---|---|---|
SECCOMP_RET_KILL_PROCESS | Whole process exits with SIGSYS | Hard deny for calls that should never happen |
SECCOMP_RET_KILL_THREAD | Calling thread exits | Legacy default kill behaviour |
SECCOMP_RET_TRAP | SIGSYS delivered to the task, call not run | Applications that handle the signal themselves |
SECCOMP_RET_ERRNO | Call skipped, error returned (for example EPERM) | Container runtime defaults; gentle failure |
SECCOMP_RET_USER_NOTIF | Call forwarded to a user-space supervisor | Runtimes that emulate selected calls; supervisor must avoid time-of-check races |
SECCOMP_RET_TRACE | ptrace tracer notified | Debugging and tracing tools |
SECCOMP_RET_LOG | Call runs and is logged | Profile development and audit mode |
SECCOMP_RET_ALLOW | Call runs | Allowed calls |
Logging of actions is controlled by /proc/sys/kernel/seccomp/actions_logged; SECCOMP_RET_LOG events appear only if log is listed there, and ALLOW actions can never be logged.
Where seccomp profiles come from
| Layer | How it is set | Default behaviour | Notes |
|---|---|---|---|
| Docker Engine | Default profile; --security-opt seccomp=profile.json for custom | Allowlist with defaultAction SCMP_ACT_ERRNO; disables around 44 of 300+ calls | Docker documents that changing the default is not recommended |
| Kubernetes | securityContext.seccompProfile.type: RuntimeDefault, Localhost or Unconfined | Unconfined unless set, or unless the kubelet runs with --seccomp-default | RuntimeDefault differs between containerd and CRI-O and between versions |
| systemd services | SystemCallFilter=, SystemCallArchitectures=, SystemCallErrorNumber=, SystemCallLog= | No filter unless the unit sets one | Many distribution units already set filters; check with systemd-analyze security |
| Applications | libseccomp or raw seccomp(2) in the program | Depends on the software | Browsers, OpenSSH's privilege-separated child and many sandboxed daemons do this themselves |
What the Docker default profile blocks
The Docker default profile is an allowlist. Calls that are not listed return an error, and several are allowed only when the container has been given the matching capability. Examples from Docker's documentation and the published profile:
- Kernel modules and kexec:
init_module,finit_module,delete_module,kexec_load,kexec_file_load. - Namespace and mount operations:
mount,unshare,setnsandclonewith namespace flags are allowed only when the container hasCAP_SYS_ADMIN. This matters because many kernel privilege escalation exploits start by creating a user namespace to gain capabilities inside it. - Kernel keyring:
add_keyandkeyctl, because the keyring is not namespaced. - Clock changes:
clock_settimeandclock_adjtime, because time is not namespaced. - io_uring:
io_uring_setup,io_uring_enterandio_uring_register, which Docker blocks citing known container escape vulnerabilities. - Tracing and BPF:
bpfandperf_event_open;bpfis allowed only withCAP_SYS_ADMINorCAP_BPF.
Granting capabilities therefore loosens the effective seccomp profile. A container given CAP_SYS_ADMIN regains mount, unshare and namespace calls. See the Linux Capabilities Guide.
seccomp for systemd services
systemd exposes seccomp through unit file settings, which makes it the easiest way to filter host daemons without changing their code. SystemCallFilter= takes system call names or predefined groups. Without a leading ~ it is an allowlist; with ~ it is a denylist. By default a denied call kills the process with SIGSYS; SystemCallErrorNumber=EPERM makes it fail with an error instead.
| Group | Contents | Typical decision |
|---|---|---|
@system-service | Calls typically needed by system services, excluding special-purpose groups such as @clock, @mount, @swap and @reboot | Recommended allowlist starting point |
@privileged | All calls that need superuser capabilities | Deny for services that run as non-root |
@resources | Changing resource limits, memory and scheduling parameters | Deny unless the service tunes itself |
@mount | Mounting, unmounting and chroot | Deny; also protects ReadOnlyPaths= from being undone |
@module, @reboot, @swap, @clock, @raw-io | Kernel modules, reboot and kexec, swap, clock changes, raw I/O ports | Deny for almost every service |
@debug, @cpu-emulation, @obsolete | ptrace and perf, vm86, obsolete calls | Deny |
A typical hardened unit drop-in:
[Service]
NoNewPrivileges=yes
SystemCallArchitectures=native
SystemCallFilter=@system-service
SystemCallFilter=~@privileged @resources
SystemCallErrorNumber=EPERM
- Block other ABIs: systemd's documentation recommends
SystemCallArchitectures=nativealongside any filter so that alternative ABIs cannot be used to get round it. - Know the implicit allowances:
execve,exit,exit_group,rt_sigreturnand time queries are always allowed, so the service can start. - Check group contents for your version:
systemd-analyze syscall-filter @system-servicelists what a group contains on this host. Group contents change between systemd versions. - Score your services:
systemd-analyze securitygives each service an exposure estimate from 0.0 to 10.0 based on the sandboxing settings in use, with higher meaning less sandboxed. It only considers systemd settings, not protections inside the program. - Audit before enforcing:
SystemCallLog=logs listed calls (or all except listed with~) without blocking, which helps find what a service uses.
The Linux Server Hardening Guide covers the other systemd sandboxing settings that pair with these.
seccomp in containers and Kubernetes
- Set a profile on every pod: use
seccompProfile.type: RuntimeDefaultat pod level inspec.securityContextso all containers inherit it, including init and ephemeral containers. Container-level settings override the pod value. - Make RuntimeDefault the node default: run the kubelet with
--seccomp-default(or the equivalent kubelet configuration setting) on each node, so pods without a profile getRuntimeDefaultinstead of running unconfined. This is stable from Kubernetes v1.27. - Enforce with Pod Security Admission: the Pod Security Standards Baseline level forbids explicitly setting
Unconfined; the Restricted level requiresRuntimeDefaultorLocalhostand prohibits an absent profile. See the Kubernetes Admission Control Guide. - Block privileged pods: seccomp cannot be applied to a container with
privileged: true, which always runs unconfined. Baseline and Restricted both disallow privileged pods. - Custom profiles:
Localhostprofiles are JSON files on each node under the kubelet seccomp directory (/var/lib/kubelet/seccompon Linux). If the file is missing, the container fails withCreateContainerError, so distribute profiles to every node before referencing them, typically with a DaemonSet or an operator. - Know runtime differences: Kubernetes warns that
RuntimeDefaultprofiles differ between runtimes and versions, and that some actions such asSCMP_ACT_NOTIFYare not supported everywhere. Test on the runtime you run.
Container escape (MITRE ATT&CK T1611 Escape to Host) and kernel exploitation for privilege escalation (T1068) are the threats seccomp most directly reduces. The Container Security Guide and Container Runtime Security Guide place it alongside the other runtime controls.
Choosing a profile strategy
| Strategy | Effort | Protection | Breakage risk | Choose when |
|---|---|---|---|---|
| Runtime default (RuntimeDefault, Docker default) | Low | Blocks the most dangerous calls | Low; occasional issues with tools needing namespaces or io_uring | Always, as the floor for every container |
systemd groups (@system-service plus denies) | Low to medium | Good for host daemons | Medium; test each unit | Host services you package or configure |
| Denylist of specific calls | Low | Limited; new calls are allowed by default | Low | Quick mitigation for a specific kernel bug |
| Recorded custom allowlist | High | Strongest; only observed calls allowed | High if recording missed rare paths | High-value, stable workloads; internet-facing parsers |
Small teams should stop at runtime default plus systemd groups and spend the effort on blocking privileged containers and dropping capabilities. Large platforms with stable, high-risk services can justify recorded allowlists, managed as code with an owner per profile.
Building and rolling out custom profiles
- Baseline: enable RuntimeDefault for all pods and the kubelet seccomp default on a pilot node pool; measure failures.
- Record: for a workload that needs a tighter profile, run it under a profile with
defaultActionSCMP_ACT_LOG(containers) orSystemCallLog=(services) through a full test cycle, including start-up, error paths, backups and shutdown. - Generate: build an allowlist from the logged calls, set
defaultActiontoSCMP_ACT_ERRNO, and include the architecture map for every architecture you run. - Test in CI: run integration tests against the enforced profile; fail the pipeline if the workload breaks.
- Canary: deploy to a small share of replicas with alerting on SIGSYS terminations and EPERM spikes.
- Enforce and own: roll out fully, store the profile next to the workload's code with a named owner, and regenerate when the base image or runtime changes.
- Roll back: revert to RuntimeDefault, not to Unconfined, if a custom profile breaks production.
Detection and measurement
- Kernel audit records: seccomp log and kill events appear as audit records (type SECCOMP) with the syscall number, architecture and process. Collect them through auditd or journald and translate syscall numbers per architecture.
- Kill and error spikes: a sudden rise in SIGSYS kills or denied calls from one workload can indicate an exploit attempt (for example a process trying
unshareorkeyctl) or a broken deployment. Both deserve a look. - Policy drift: alert on pods created with
Unconfined, withprivileged: true, or with addedSYS_ADMIN, using admission logs and the Kubernetes audit log. See the Kubernetes Audit Log Detection Guide. - Process status: the
Seccompfield in/proc/<pid>/statusshows whether a running process is filtered, which lets you audit hosts for unfiltered daemons.
Metrics: percentage of running pods with RuntimeDefault or Localhost profiles (target 100 per cent outside documented exceptions); number of privileged pods in production; percentage of nodes with the kubelet seccomp default enabled; median systemd-analyze security exposure score for internet-facing services; and number of custom profiles without an owner or older than the workload's current image.
Common failure patterns
- Assuming Kubernetes applies the runtime default: pods without a profile run unconfined unless the kubelet default is turned on, even though the same image under Docker would be filtered.
- Privileged pods as a shortcut: setting
privileged: trueto fix a permissions error removes seccomp, capabilities limits and device restrictions in one step. - Setting Unconfined to fix one tool: a debugging or monitoring agent needs one call, and the whole profile is removed rather than adjusted.
- Denylists that forget other ABIs: a filter that blocks a call by its x86-64 number but not its i386 or x32 number, without an architecture check.
- Recorded profiles that miss rare paths: the allowlist was recorded during happy-path tests, and the service dies during log rotation or failover.
- Treating seccomp as the whole sandbox: a filtered process running as root with broad capabilities and no LSM confinement can still read and change everything its calls permit.
Framework mapping
| Framework | Reference | How seccomp contributes |
|---|---|---|
| NIST SP 800-53 Rev. 5 | SC-39 Process Isolation; CM-7 Least Functionality; CM-6 Configuration Settings | Restricts the kernel functions a process can use; profiles are configuration settings to baseline |
| NIST CSF 2.0 | PR.PS-01 | Profiles applied and maintained as part of configuration management |
| MITRE D3FEND | D3-SCF System Call Filtering | The defensive technique seccomp implements |
| MITRE ATT&CK | T1611 Escape to Host; T1068 Exploitation for Privilege Escalation | Removes kernel entry points used in escapes and local exploits |
| Kubernetes Pod Security Standards | Baseline and Restricted seccomp controls | Admission-time enforcement of profiles |
| NIST SP 800-190 | Container runtime and host OS countermeasures | See the NIST SP 800-190 Container Security Guide |
Practitioner checklist
- Enable the kubelet seccomp default on every node and set RuntimeDefault at pod level in workload templates.
- Enforce Pod Security Standards Restricted (or at least Baseline) so Unconfined and privileged pods are rejected.
- Do not grant CAP_SYS_ADMIN to containers; it re-enables mount, unshare and namespace calls in the default profile.
- Add NoNewPrivileges, SystemCallArchitectures=native and SystemCallFilter=@system-service to host service units, tested per unit.
- Run systemd-analyze security on servers and work down the highest exposure scores for internet-facing services.
- Build custom allowlists in log mode first, test them in CI and canary them before enforcing.
- Store every custom profile with its workload, with an owner and a review trigger when the image or runtime changes.
- Collect seccomp audit records and alert on kill and denial spikes and on pods created unconfined.
Standards and references
- Linux kernel documentation: Seccomp BPF
- Linux man-pages: seccomp(2)
- systemd: systemd.exec(5)
- Docker Docs: Seccomp security profiles for Docker
- Kubernetes: Seccomp and Kubernetes
- Kubernetes: Restrict a Container's Syscalls with seccomp
- Kubernetes: Pod Security Standards
- MITRE D3FEND: System Call Filtering
Related NHI Mgmt Group resources: Container Security Guide · Linux Capabilities Guide · Linux Namespaces and cgroups Security Guide · Kubernetes Security Guide