More Info:

ECR repository policies should not enable global or public access to images. ECR repository policies should limit access to images to known IAM entities and AWS accounts and avoid the use of account-level wildcards.

Risk Level

High

Address

Security

Compliance Standards

HIPAA, PCIDSS, SOC2, AWSWAF, HITRUST, NISTCSF

Triage and Remediation

Remediation

Sure, here are the step-by-step instructions to remediate the misconfiguration of ECR repositories not being private in AWS:

  1. Login to your AWS console.
  2. Navigate to the Amazon Elastic Container Registry (ECR) service.
  3. Select the repository that you want to make private.
  4. Click on the “Permissions” tab.
  5. Under the “Repository policy” section, click on the “Edit” button.
  6. In the JSON editor, replace the existing policy with the following policy:
{
  "Version": "2008-10-17",
  "Statement": [
    {
      "Sid": "AccessDenied",
      "Effect": "Deny",
      "Principal": "*",
      "Action": [
        "ecr:GetDownloadUrlForLayer",
        "ecr:BatchGetImage",
        "ecr:BatchCheckLayerAvailability",
        "ecr:PutImage",
        "ecr:InitiateLayerUpload",
        "ecr:UploadLayerPart",
        "ecr:CompleteLayerUpload"
      ]
    },
    {
      "Sid": "AllowPushPull",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::AWS_ACCOUNT_ID:root"
      },
      "Action": [
        "ecr:GetAuthorizationToken",
        "ecr:BatchCheckLayerAvailability",
        "ecr:GetDownloadUrlForLayer",
        "ecr:BatchGetImage",
        "ecr:PutImage",
        "ecr:InitiateLayerUpload",
        "ecr:UploadLayerPart",
        "ecr:CompleteLayerUpload"
      ]
    }
  ]
}

Note: Replace “AWS_ACCOUNT_ID” with your AWS account ID.

  1. Click on the “Save” button to save the policy.
  2. Verify that the repository is now private by checking the “Repository visibility” under the “Overview” tab.

That’s it! You have successfully remediated the misconfiguration of ECR repositories not being private in AWS.

Additional Reading: