Skip to main content

More Info:

Verifies every container drops ALL capabilities and adds back only what it needs. Excess capabilities expand the attack surface of a compromised container.

Risk Level

High

Address

Security

Compliance Standards

  • Cloudanix Best Practice

Triage and Remediation

Remediation

Manual Steps

  1. Identify all noncompliant pods
    • Run on: any machine with kubectl access
  2. Locate and edit the owning workload manifest(s)
    • For each noncompliant pod, find the controller and kind:
    • Export the current manifest for that controller (example for a Deployment):
    • Edit the file:
  3. Add securityContext.capabilities.drop: ["ALL"] to each container
    • In the manifest’s pod template (spec.template.spec.containers and, if present, spec.template.spec.initContainers), ensure each container has:
    • If securityContext or capabilities already exists, merge without removing other needed fields (e.g., runAsNonRoot, readOnlyRootFilesystem).
  4. Apply the updated manifest
    • Run on: any machine with kubectl access
    • For other controller kinds (StatefulSet, DaemonSet, Job, CronJob), export, edit, and apply their manifests similarly.
  5. Handle pods without controllers (bare Pods)
    • If ownerReferences is empty, export and edit the Pod manifest directly:
    • Add the same securityContext.capabilities.drop: ["ALL"] stanza to each container, then recreate the pod:
  6. Verify compliance
    • Run on: any machine with kubectl access
    • The environment is compliant when the command outputs only is_compliant=true.
On any machine with kubectl access:
  1. Identify the noncompliant Pod and its owner (from the audit output). If the Pod is owned by a higher-level resource (Deployment, DaemonSet, Job, etc.), you must patch that owner; changes to a standalone Pod will be lost when it is recreated.
  2. Example: patch a Deployment to drop all capabilities for all app containers.
    Edit /tmp/deploy-capabilities.yaml so each container (and initContainer, if present) has:
    Then apply:
    This will trigger a rollout of the Deployment.
  3. Example: patch a standalone Pod (not recommended for controllers, but works for ad‑hoc Pods):
    Edit each containers and initContainers entry as above, adding:
    Then delete and recreate the Pod from the edited manifest:
  4. Verification (same machine with kubectl access):
    Confirm is_compliant=true for all relevant containers.