Kubernetes check

Container has excessive Linux capabilities

K8S-SEC-007MediumSecurity

Trigger condition

A regular, init, or live ephemeral container's securityContext.capabilities flags one of two independent conditions. First: drop does not contain ALL -- an omitted security context, an omitted capabilities block, and an explicit but empty drop list are all treated identically. Second: add contains any capability other than NET_BIND_SERVICE. Both conditions are checked independently, and both are reported together when both apply. Duplicate or reordered entries in add never affect detection or deduplication -- comparison is set-based, not order- or occurrence-sensitive. Evaluated independently of privileged mode, startup UID, and allowPrivilegeEscalation, each its own separate check. A Pod or Deployment template explicitly declaring spec.os.name as windows is skipped, since Linux capabilities are a Linux-kernel-specific mechanism a Windows container does not have at all; an unspecified OS is evaluated using the Linux rule.

Evidence

States the container's type and name, and names each violation present: that it does not drop ALL capabilities, and/or the exact disallowed capability name(s) it adds, using standard Kubernetes manifest names (e.g. SYS_ADMIN, NET_ADMIN).

Impact

Linux capabilities grant a container fine-grained kernel privileges beyond an unprivileged process's own defaults. Dropping ALL and adding back only what is actually needed narrows this to a documented minimum; omitting the ALL drop, or adding a capability beyond NET_BIND_SERVICE, both leave additional kernel privileges available to this container's declared configuration. This describes the declared configuration only -- it does not establish which capabilities the running process actually exercises, or what the container runtime's own default capability set already grants independently of this setting.

Recommendation

Set securityContext.capabilities.drop to [ALL], and remove any added capability beyond NET_BIND_SERVICE, after checking that the workload does not depend on it; test workload compatibility before rollout or Pod replacement. If the workload only needs to bind a privileged port (e.g. 80 or 443), the Restricted Pod Security Standard still permits adding back NET_BIND_SERVICE specifically for that purpose. For a Deployment-managed container, make the change in the Deployment's own Pod template and roll out the change. For a Pod with no verified owning Deployment, if a controller manages it (e.g. a DaemonSet or StatefulSet), make the change in that workload's own source configuration and follow its normal update process; if the Pod is standalone, make the change in its own source manifest and recreate it. For a Deployment-owned Pod whose own violation set is not fully covered by its template's matching container, the recommendation names only the genuinely uncovered violation(s) -- missing ALL compared separately from each disallowed addition -- and directs investigation through the owning controller rather than editing the Pod directly. For an ephemeral container, apply the corrected configuration to any future debug container attached to the Pod; clearing this existing one requires replacing the Pod itself, through the Eviction API or a normal Deployment rollout, after checking available capacity and any PodDisruptionBudget.

Important limitations

This check evaluates only securityContext.capabilities.add/drop. It does not detect equivalent or partial privilege paths achieved through other means, such as securityContext.privileged or allowPrivilegeEscalation, both of which require their own separate attention and are evaluated by other checks.

← Back to the check catalogue