Description
Ensure that no Amazon Elastic Container Registry (ECR) private repository is set to fully mutable image tags (MUTABLE). Repositories set to IMMUTABLE, IMMUTABLE_WITH_EXCLUSION or MUTABLE_WITH_EXCLUSION pass. With immutable tags, once an image is pushed with a tag, that tag cannot be moved to a different image, so each tag always refers to the same image.
Rationale
When tags are mutable, anyone with push access can replace the image behind a trusted tag, such as a release version, without changing the deployment configuration. This enables supply-chain attacks, backdoored deployments and unintended rollouts of untested code, and makes it hard to know which image is actually running. Enabling tag immutability, together with unique versioned tags for each build and least-privilege push permissions, keeps each tag tied to a single image.
Impact
Guarantees that a tag always points to the same image, improving release integrity and traceability
Pushes that reuse an existing tag (for example, latest) are rejected, so build pipelines must use a unique tag for each build
Already pushed images are not changed
Default Value
New ECR repositories are created with mutable image tags unless immutability is selected at creation.
Pre-Requisites
IAM permissions: ecr:DescribeRepositories and ecr:PutImageTagMutability
Confirmation that the build pipelines pushing to the repository use a unique tag for each image
Test Plan
Console:
Sign in to the AWS Management Console at https://console.aws.amazon.com.
Open the Amazon ECR console and select Repositories under Private registry.
Check the tag immutability (or tag mutability) setting shown for each repository.
Repeat for each region in use.
If any repository shows tags as mutable, follow the implementation steps.
CLI:
List all repositories with their tag mutability setting:
aws ecr describe-repositories --region <REGION> --query "repositories[].[repositoryName,imageTagMutability]" --output table
A repository fails only if imageTagMutability is MUTABLE. The values IMMUTABLE, IMMUTABLE_WITH_EXCLUSION and MUTABLE_WITH_EXCLUSION pass.
Implementation Steps
Console:
Sign in to the AWS Management Console at https://console.aws.amazon.com.
Open the Amazon ECR console and select Repositories under Private registry.
Select the repository, then choose Actions and Edit.
Set the image tag mutability setting to Immutable.
Choose Save.
Repeat for each affected repository in each region in use.
CLI:
Enable tag immutability for a repository:
aws ecr put-image-tag-mutability --repository-name <REPOSITORY_NAME> --image-tag-mutability IMMUTABLE --region <REGION>
Backout Plan
Sign in to the AWS Management Console at https://console.aws.amazon.com.
Open the Amazon ECR console and select Repositories under Private registry.
Select the repository, then choose Actions and Edit.
Set the image tag mutability setting to Mutable.
Choose Save.
CLI:
aws ecr put-image-tag-mutability --repository-name <REPOSITORY_NAME> --image-tag-mutability MUTABLE --region <REGION>
Note: rolling back allows existing tags to be overwritten with different images again.
Reference