Capability Management
What you'll learn: How to minimize container attack surfaces by dropping unnecessary Linux capabilities and recognizing which ones create security risks.
What Are Linux Capabilities?
Traditionally, Linux processes run as either root (all-powerful) or non-root (limited). Linux capabilities split root's monolithic power into distinct privileges. For example, CAP_NET_ADMIN allows network configuration, while CAP_SYS_TIME allows changing the system clock.
Containers often inherit many capabilities by default, even when they don't need them. This violates the principle of least privilege—giving processes only the permissions they actually require.
Why Capability Management Matters
Think of capabilities like keys on a master keyring. If your container only needs to open the front door (bind to ports), why give it the key to the safe (access raw devices) or the alarm system (load kernel modules)?
Running containers with excessive capabilities creates unnecessary risk. An attacker exploiting a vulnerability in your containerized application could leverage these capabilities to escalate privileges, escape the container, or compromise the host.
High-Risk Capabilities to Drop
Most containers should never have:
CAP_SYS_ADMIN– nearly equivalent to root; allows mounting filesystems, namespace manipulationCAP_SYS_MODULE– loads kernel modules, direct path to host compromiseCAP_NET_RAW– creates raw sockets, enables spoofing attacksCAP_SYS_PTRACE– debugs other processes, can extract secrets
Drop Capabilities by Default
When launching containers, explicitly drop all capabilities and only add back those truly needed. Most web applications need zero capabilities. Even specialized services rarely need more than one or two (like CAP_NET_BIND_SERVICE to bind ports below 1024).
Combined with seccomp, AppArmor, and SELinux from previous lessons, capability management creates defense-in-depth for your runtime environment.
Key Takeaway: Drop all Linux capabilities from containers by default and only grant the minimal set required for specific functionality—most applications need none at all.