More Info:
Verifies readOnlyRootFilesystem is true. A writable root filesystem lets an attacker persist tools or modify binaries inside a running container.Risk Level
MediumAddress
SecurityCompliance Standards
- Cloudanix Best Practice
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
Identify non-compliant Pods and their controllers (run on any machine with kubectl access):
-
For each affected controller (Deployment, StatefulSet, DaemonSet, Job, CronJob, etc.), edit the manifest to set
readOnlyRootFilesystem: true(run on any machine with kubectl access). Example for a Deployment:In each affected container (and initContainer if present) underspec.template.spec.containers[](orinitContainers[]), ensure:IfsecurityContextalready exists, add only thereadOnlyRootFilesystem: trueline. -
If a container needs a writable path, add an
emptyDirand mount it (samekubectl editsession as step 2):- Under
spec.template.spec.volumes: - Under the appropriate container:
nameandmountPathas needed for each workload. - Under
-
For standalone Pods that are not managed by a higher-level controller, export, edit, and re-apply (run on any machine with kubectl access):
Edit
/tmp/pod-POD_NAME.yaml:- Remove
metadata.uid,metadata.resourceVersion,metadata.creationTimestamp,metadata.ownerReferences,statusand other server-populated fields. - Under
spec.containers[]andspec.initContainers[]set:and, if needed, addemptyDir+volumeMountsas in step 3. Apply:
- Remove
-
Wait for updated workloads to roll out and confirm Pods are running (run on any machine with kubectl access):
-
Verification (run on any machine with kubectl access):
Confirm the output is
is_compliant=trueor that all listed containers showis_compliant=true.
Using kubectl
Using kubectl
On any machine with kubectl access:Use the audit output you already have to see the If Repeat for each non‑compliant controller (Deployment, StatefulSet, DaemonSet, Job, CronJob), adjusting the resource type, name, namespace, and container index as needed.Apply the manifest:
- Identify non‑compliant Pods (and their controllers)
owner= field (e.g. Deployment/StatefulSet/Job). You must edit the owning controller, not the live Pod.- Patch a controller to set
readOnlyRootFilesystem: true
my-app named web so all containers use a read‑only root filesystem:securityContext already exists, use:- Provide writable paths via
emptyDir(when needed)
emptyDir volumes there instead of leaving the root filesystem writable. Example manifest snippet:- Verification
Automation
Automation

