ECS task definitions should configure non-root users in Linux container definitions
Checks that every container in the task definition family's latest active revision sets user to a non-root user; empty, root and 0 fail, with or without a group, and a USER line in the image alone does not pass. Revisions declaring a Windows runtimePlatform are skipped. Root in a container raises the risk of container escape and privilege escalation.
- service
- ECS
- severity
- Medium
- scope
- evaluated in every region
How to fix it
- Can break clients: A process that needs root, such as one writing to root-owned paths, fails under another user, so confirm the image works as that user first.
In the console
ECS → Task definitions → the family → the latest revision → Create new revision with JSON
- user
- A non-root user or UID in every container, such as 1000:1000 or appuser
- Task definition
- The new revision, on each service's Update page and in each scheduled task; running tasks keep the old one
With Terraform
resource "aws_ecs_task_definition" "this" {
family = "example"
container_definitions = jsonencode([{
name = "app"
image = var.container_image
user = "1000:1000"
}])
}
See which of your accounts this check is failing on.
Book a live scan