π‘οΈ AWS ECS Task Definition Readonly Root Filesystem is disabledπ’
- Contextual name: π‘οΈ Task Definition Readonly Root Filesystem is disabledπ’
- ID:
/ce/ca/aws/ecs/task-definition-readonly-root-filesystem - Tags:
- π’ Policy with categories
- π’ Policy with type
- π’ Production policy
- Policy Type:
COMPLIANCE_POLICY - Policy Categories:
SECURITY
Logicβ
- π§ prod.logic.yamlπ’
Similar Policiesβ
Descriptionβ
Descriptionβ
This policy identifies AWS ECS Task Definitions in which the
readonlyRootFilesystemparameter is set to false or omitted (which defaults to false) for any container.When enabled, this parameter mounts the containerβs root file system as read-only.
Rationaleβ
Mounting the containerβs root file system as read-only is a security best practice aligned with immutable infrastructure principles.
Key benefits include:
- Immutability: Prevents application code and system files from being modified at runtime, reinforcing the expectation that containers are ephemeral and stateless.
- Malware Prevention: Limits an attackerβs ability to download scripts, install packages, or persist malicious binaries in common system directories.
- Configuration Drift Prevention: Ensures the running container cannot diverge from the original image definition.
If a container must write temporary data (e.g., logs, cache files), a dedicated
tmpfsmount or a Docker volume should be used rather than allowing writes to the containerβs root layer.... see more
Remediationβ
Remediationβ
Update the ECS Task Definition to Read-Only Root Filesystemβ
Using the AWS CLIβ
Retrieve the existing task definition JSON
aws ecs describe-task-definition \
--task-definition {{family-or-full-arn}} \
--query 'taskDefinition' > task-def.jsonEdit
task-def.jsonFor every container in the
containerDefinitionslist, setreadonlyRootFilesystemto true."containerDefinitions": [
{
"name": "my-app",
"image": "my-image",
"readonlyRootFilesystem": true,
...
}
]Register the updated task definition
aws ecs register-task-definition --cli-input-json file://task-def.jsonUpdate your ECS service to use the new task definition revision