Description
A writable root filesystem lets a process change files wherever its user has write permission.
Potential impact
Unexpected changes to files or configuration can make an incident harder to investigate.
Remediation
Set readOnlyRootFilesystem: true on the container. Mount separate writable volumes only where the app writes logs, caches, or temporary files. Restrict those volumes, review the runtime user and allowPrivilegeEscalation, and test the app’s write paths.
Examples
The examples use different Pod names. Update the workload that serves your application and use a maintained image in place of the legacy goproxy image.
Before
yaml
apiVersion: v1
kind: Pod
metadata:
name: rootfalse
spec:
containers:
- name: app
image: k8s.gcr.io/goproxy:0.1
securityContext:
readOnlyRootFilesystem: false
After
yaml
apiVersion: v1
kind: Pod
metadata:
name: roottrue
spec:
containers:
- name: app
image: k8s.gcr.io/goproxy:0.1
securityContext:
readOnlyRootFilesystem: true