More Info:
Restrict IAM user and role access to Amazon ECR to only what is required, using least-privilege IAM policies.Risk Level
MediumAddress
SecurityCompliance Standards
- CIS EKS
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
Inventory who can access ECR
- On any machine with AWS CLI configured for the account:
- In the AWS Console: IAM → Access Analyzer → Analyze policies (optional) to see which principals have ECR access.
- On any machine with AWS CLI configured for the account:
-
Identify IAM policies that grant ECR permissions
- List all policies that mention
ecr:actions: - For each returned policy ARN, inspect details:
- List all policies that mention
-
Review scope for over-privilege
- For each policy, check for:
- Wildcard actions (e.g.,
"Action": "ecr:*"). - Wildcard resources (e.g.,
"Resource": "*", or all repositories). - Principals that do not need ECR access (users/roles not tied to CI/CD or workloads that pull/push images).
- Wildcard actions (e.g.,
- Use console: IAM → Policies → (select policy) → JSON tab; verify actions and resources are narrowed to required repositories and operations.
- For each policy, check for:
-
Redesign least-privilege policies based on actual need
- Determine for each user/role what they must do:
- Pull only (e.g., node roles, application pods):
ecr:GetAuthorizationToken,ecr:BatchCheckLayerAvailability,ecr:GetDownloadUrlForLayer,ecr:BatchGetImage. - Push & pull (CI/CD): above plus
ecr:PutImage,ecr:InitiateLayerUpload,ecr:UploadLayerPart,ecr:CompleteLayerUpload,ecr:ListImages.
- Pull only (e.g., node roles, application pods):
- Create a new scoped policy (example for one repository) with the console or CLI:
- Determine for each user/role what they must do:
-
Attach new scoped policies and remove broad ones
- Attach the least-privilege policy to only those users/roles that require it:
- Detach or delete overly broad policies (after verifying no dependency):
- Attach the least-privilege policy to only those users/roles that require it:
-
Re-verify effective access to ECR
- Re-run the policy search to ensure no remaining broad access:
- Optionally, use IAM → Access Analyzer (AWS Console) to confirm there are no unintended principals with ECR permissions beyond what is required.
- Re-run the policy search to ensure no remaining broad access:
Using kubectl
Using kubectl
kubectl cannot be used to change IAM user or role permissions for Amazon ECR, because those are configured at the AWS account level via IAM (console, AWS CLI, or IaC such as CloudFormation/Terraform), not through Kubernetes API objects. Please refer to the Manual Steps section for guidance on reviewing and tightening ECR-related IAM access.
Automation
Automation

