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 and their owning controllers (run on any machine with kubectl access):
-
For each affected controller (Deployment/DaemonSet/StatefulSet/Job/CronJob), export its manifest (run on any machine with kubectl access; adjust kind/name/namespace):
-
Edit the manifest to set
readOnlyRootFilesystem: truefor each affected container, and, if writes are needed, define anemptyDirvolume and mount it at the writable path (run on any machine with kubectl access):Example changes inside each affected container spec:Apply the same pattern toinitContainersif present. -
Apply the updated controller manifest so new pods use a read-only root filesystem (run on any machine with kubectl access):
-
If necessary, recreate existing pods so they pick up the new security context (run on any machine with kubectl access):
The controller will create new pods with
readOnlyRootFilesystem: true. -
Verify all non-system pods now have
readOnlyRootFilesystemset to true (run on any machine with kubectl access):
Using kubectl
Using kubectl
On any machine with Apply the same Add under each container / initContainer:And define any
kubectl access:- Identify a noncompliant Pod and its owning workload (Deployment/DaemonSet/Job, etc.):
- Export the owning workload manifest:
- Edit containers to use a read-only root filesystem and add a writable
emptyDirfor any paths that must be writable.
/tmp/deployment-readonly-fix.yaml:securityContext.readOnlyRootFilesystem: true and emptyDir pattern to every container and initContainer that currently needs a writable path.- Apply the updated manifest:
- (If the Pod is not controlled by a higher-level object, edit it directly; note this is not persistent across restarts):
emptyDir volumes and volumeMounts needed for writable paths.- Verification (same scope: any machine with
kubectl):
readOnlyRootFilesystem=true and is_compliant=true for all containers:Automation
Automation

