Mental model
Traditional Linux security treats root (UID 0) as an all-powerful superuser. POSIX Capabilities partition root privileges into fine-grained permissions. Seccomp (Secure Computing Mode) acts as a kernel firewall for system calls, intercepting and blocking dangerous syscalls before execution.
Theory
- POSIX Capabilities:
CAP_NET_ADMIN: Perform network configuration tasks.CAP_SYS_ADMIN: Overly permissive legacy root capability (mount, cgroups, eBPF).CAP_NET_BIND_SERVICE: Bind sockets to privileged ports (< 1024).
- Seccomp BPF: Uses BPF filters attached to
prctl(PR_SET_SECCOMP)to audit system call numbers and arguments. Default Docker/Kubernetes seccomp profiles block ~40 dangerous syscalls (e.g.reboot,kexec_load,ptrace).
Alternatives and trade-offs
- Running Unrestricted Container Root: High security risk; a container breakout compromises the host kernel.
- Capabilities Drop + Seccomp BPF: Strict principle of least privilege; restricts process execution capability even if an attacker gains root code execution.
Failure modes and misconceptions
- Granting
--privilegedFlag in Docker: Passing--privilegeddisables all seccomp filters, grants ALL capabilities, and disables AppArmor/SELinux protection, completely invalidating container isolation boundaries. - Blocking Required Syscalls: Overly restrictive custom seccomp profiles blocking syscalls like
epoll_createorfutexcause applications to crash instantly withSIGSYSorEPERMerrors on startup.
Decision scenario
Enforce --cap-drop=ALL and attach restrictive Seccomp BPF profiles to all containerized workloads to enforce the principle of least privilege in production.
Learning outcomes
- Drop unneeded root capabilities using POSIX Capabilities.
- Build custom Seccomp BPF profiles to block dangerous system calls.
- Prevent container breakout vulnerabilities by eliminating
--privilegedflags.
Trade-offs
Capabilities and Seccomp provide robust process sandbox hardening, but require auditing application system call dependencies to avoid blocking required syscalls.