Skip to main content

More Info:

Verifies readOnlyRootFilesystem is true. A writable root filesystem lets an attacker persist tools or modify binaries inside a running container.

Risk Level

Medium

Address

Security

Compliance Standards

  • Cloudanix Best Practice

Triage and Remediation

Remediation

Manual Steps

  1. Identify noncompliant pods and their owning workloads (run on any machine with kubectl access):
  2. For each affected Pod that is controlled by a Deployment/StatefulSet/DaemonSet/Job/CronJob, edit the owning workload manifest to set a read-only root filesystem (run on any machine with kubectl access). Example for a Deployment:
    In each container (including initContainers if present) under spec.template.spec.containers[] add or update:
  3. If a container needs write access to specific paths, mount an emptyDir instead of relying on a writable root (same edit session as step 2). Under spec.template.spec.volumes add:
    Then, in the relevant container, add a volumeMounts entry:
  4. For standalone Pods (no controller in ownerReferences), export, modify, and re-apply (run on any machine with kubectl access):
    Edit /tmp/pod-POD_NAME.yaml:
    • Remove fields status, metadata.resourceVersion, metadata.uid, metadata.selfLink, metadata.creationTimestamp, metadata.managedFields.
    • Under each container and initContainer, set:
    • Optionally define emptyDir volumes and volumeMounts for writable paths as in step 3. Then delete and recreate the Pod:
  5. Wait for updated workloads to roll out and ensure Pods are running (run on any machine with kubectl access):
  6. Verify compliance (run on any machine with kubectl access):
On any machine with kubectl access:
  1. Identify non‑compliant pods and owning controllers
For each non‑compliant pod, note the OWNER from the audit output (e.g., Deployment, StatefulSet, DaemonSet, Job, CronJob) and patch that controller, not the Pod.
  1. Example: patch a Deployment to use a read‑only root filesystem
Edit /tmp/deploy.yaml and, for each affected container, ensure:
Apply the manifest:
  1. Example: patch a single container in a Deployment (no extra volumes needed)
Adjust the container index in /containers/0/ if needed.
  1. Example: patch a DaemonSet similarly
  1. Example manifest snippet for new workloads
Apply with:
  1. Verification
Run the original audit command on any machine with kubectl access and confirm all listed is_compliant=true: