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 noncompliant pods (run on any machine with kubectl access):
-
For each owning workload (Deployment/StatefulSet/DaemonSet/Job/CronJob) or standalone Pod found in step 1, export its manifest (run on any machine with kubectl access). Example for a Deployment:
For a standalone Pod:
-
Edit the manifest to set a read-only root filesystem (edit /tmp/workload.yaml on any machine with kubectl access):
- Under each
.spec.template.spec.containers[]and.spec.template.spec.initContainers[](or.spec.containers[]/.spec.initContainers[]for a standalone Pod), ensure:IfsecurityContextexists, addreadOnlyRootFilesystem: trueinside it.
- Under each
-
If the container needs writable paths, add
emptyDirvolumes and mount them (edit the same /tmp/workload.yaml):- Under
spec.template.spec.volumes(orspec.volumesfor a Pod) add, for each writable path: - Under the corresponding container’s
volumeMounts: - Remove any reliance on writing to
/or other parts of the root filesystem.
- Under
-
Apply the updated manifest (run on any machine with kubectl access):
For controllers (Deployments, etc.), this will roll out new pods. For standalone Pods, you may need to delete and recreate if they are not controlled:
-
Verify compliance (run on any machine with kubectl access):
Using kubectl
Using kubectl
On any machine with kubectl access:If the Pod is controlled by a higher-level object (Deployment, StatefulSet, DaemonSet, Job, CronJob), you’ll see If the container needs a writable path, also add an Apply it:Use the corresponding Confirm that all relevant containers now show
- Identify the non‑compliant Pod and its owner
ownerReferences in the Pod spec. Always fix the controller, not the individual Pod.- Patch a Deployment to use a read‑only root filesystem
emptyDir volume and mount it:- Equivalent manifest edits (for GitOps or IaC)
kubectl patch/manifest changes for other controllers:- StatefulSet:
kubectl patch statefulset <NAME> -n <NS> ... - DaemonSet:
kubectl patch daemonset <NAME> -n <NS> ... - Job:
kubectl patch job <NAME> -n <NS> ... - CronJob:
kubectl patch cronjob <NAME> -n <NS> ...
- Verification
readOnlyRootFilesystem=true and is_compliant=true.Automation
Automation

