Container with added Linux capabilities

Limit added Linux capabilities to operations the application actually needs.

Description

Linux capabilities grant individual operating-system privileges. For example, NET_ADMIN permits network configuration and SYS_TIME permits clock changes.

Potential impact

A compromised process can use every capability it holds. The impact depends on its namespaces and host access.

Remediation

Remove unnecessary entries from securityContext.capabilities.add. Where possible, set drop: [ALL] and add back only what the image requires. Document exceptions and test the app as a non-root user with privilege escalation disabled.

Examples

Before

yaml
apiVersion: v1
kind: Pod
metadata:
  name: pod2
spec:
  containers:
    - name: app
      image: images.my-company.example/app:v4
      securityContext:
        allowPrivilegeEscalation: false
        capabilities:
          add: ["NET_ADMIN", "SYS_TIME"]

allowPrivilegeEscalation: false leaves both added capabilities in effect.

After

yaml
apiVersion: v1
kind: Pod
metadata:
  name: pod1
spec:
  containers:
    - name: app
      image: images.my-company.example/app:v4
      securityContext:
        allowPrivilegeEscalation: false

Removing add leaves the runtime’s default capabilities in place.

References