1. Resources
  2. Detection rules
  3. ECR Repository or Registry Opened to Another Account

ECR Repository or Registry Opened to Another Account detection rules

An attacker changes an Amazon ECR repository policy, the registry policy or the replication configuration so that another account can pull the container images, or push images that workloads will later run.

Platform
AWS
Severity
Medium
Log source
AWS CloudTrail
Last updated
Rule formats
Sigmaand queries for: SplunkMicrosoft SentinelIBM QRadar
What an attacker needs
Credentials for a principal that may set the repository policy, the registry policy or the replication configuration in Amazon ECR.
Impact
An outside account can pull the container images, or push images that workloads later run, until the statement or the rule is removed.
Response
Restore the previous repository policy and remove unknown registry statements and replication rules, then verify the images pushed meanwhile.
Mitigation
Let only deployment and platform roles change repository and registry policies, and turn on tag immutability for production repositories.
CloudTrail events
PutRegistryPolicyPutReplicationConfigurationSetRepositoryPolicy

How the attack works

A private Amazon ECR repository is reachable only by identities of its own account until a repository policy says otherwise. The repository policy is a resource-based policy: it names principals, which can be a whole other account or IAM entities in it, and the actions they may perform on the repository. SetRepositoryPolicy applies it. Two registry-wide settings do something similar for every repository at once. The registry permissions policy (PutRegistryPolicy) is what AWS describes as the way to give another account permissions on the registry for cross-account replication, and the replication configuration (PutReplicationConfiguration) names the destination registries, by account ID and Region, that receive copies of the images.

Both directions matter to an attacker. Pull access hands over the images, which hold application code and often configuration and credentials that were built into them. Push access is worse: an image tag that a cluster or a task definition pulls can be replaced with one that carries the attacker's code, and the next deployment runs it. A replication rule to a registry in an account the attacker controls copies images out without any further call from the compromised identity.

ECR logs all of its API actions in CloudTrail under ecr.amazonaws.com, and AWS names SetRepositoryPolicy among the entries written for common tasks. AWS publishes no example record for these three events. The ECR API reference gives the policy as the string parameter policyText, and the wildcard rule here reads it on that basis. No public incident report was used for this page: it follows what AWS documents about repository policies, registry permissions and replication.

What an attacker needs

  • Credentials for a principal allowed ecr:SetRepositoryPolicy on the repository, or ecr:PutRegistryPolicy or ecr:PutReplicationConfiguration on the registry.
  • For access from another account, an identity in that account whose own policy allows the ECR actions, which an attacker controls in their own account.

Impact

With pull access the outside principal downloads the images of the repository and whatever is inside them. With push access it can replace images that workloads pull, which leads to code execution in those workloads with their roles. The access does not depend on the compromised identity and stays until the policy statement or the replication rule is removed.

Detection rules

ECR Registry Policy or Replication Configuration Changed

Detects PutRegistryPolicy and PutReplicationConfiguration calls to Amazon ECR. Both settings apply to the whole private registry of the account. AWS describes the registry policy as the policy that gives another AWS account permissions on the registry and that is used for cross-account replication. The replication configuration names the destination registries, by account ID and Region, that receive copies of the images. A destination in an account the attacker controls copies images out without any further call from the compromised identity. Both are rare administrative changes. AWS documents that all ECR API actions are logged by CloudTrail and publishes no example record for these two, so the rule matches the event names only: read the policy text and the destinations of the request. It also matches attempts that failed (errorCode present): check errorCode, because an unauthorized attempt is worth seeing.

LevelMediumStatusExperimentalLog sourceAWS CloudTrail
title: ECR Registry Policy or Replication Configuration Changed
id: 324ed4c0-0482-4b66-b752-44f7e2a91e75
status: experimental
description: >-
  Detects PutRegistryPolicy and PutReplicationConfiguration calls to Amazon
  ECR. Both settings apply to the whole private registry of the account. AWS
  describes the registry policy as the policy that gives another AWS account
  permissions on the registry and that is used for cross-account
  replication. The replication configuration names the destination
  registries, by account ID and Region, that receive copies of the images. A
  destination in an account the attacker controls copies images out without
  any further call from the compromised identity. Both are rare
  administrative changes. AWS documents that all ECR API actions are logged
  by CloudTrail and publishes no example record for these two, so the rule
  matches the event names only: read the policy text and the destinations of
  the request.
  It also matches attempts that failed (errorCode present): check errorCode,
  because an unauthorized attempt is worth seeing.
references:
  - https://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_PutRegistryPolicy.html
  - https://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_PutReplicationConfiguration.html
  - https://docs.aws.amazon.com/AmazonECR/latest/userguide/logging-using-cloudtrail.html
  - https://attack.mitre.org/techniques/T1098/003/
author: Forestall
date: 2026-11-18
tags:
  - attack.persistence
  - attack.privilege-escalation
  - attack.t1098.003
logsource:
  product: aws
  service: cloudtrail
detection:
  selection:
    eventSource: ecr.amazonaws.com
    eventName:
      - PutRegistryPolicy
      - PutReplicationConfiguration
  condition: selection
falsepositives:
  - Platform teams that set up replication between the Regions or accounts of the organization, usually once and through infrastructure-as-code. Add the deployment roles to a filter_* selection on userIdentity.arn.
level: medium

False positives

  • Platform teams that set up replication between the Regions or accounts of the organization, usually once and through infrastructure-as-code. Add the deployment roles to a filter_* selection on userIdentity.arn.

ECR Repository Policy Set

Detects SetRepositoryPolicy calls to Amazon ECR, which apply a resource-based policy to a repository. The policy can let another account, or IAM entities in it, pull the images of the repository or push to it. AWS documents that all ECR API actions are logged by CloudTrail and names SetRepositoryPolicy among the entries written for common tasks. The rule cannot tell who the policy admits: AWS publishes no example record for this event, so the rule does not read the policy. Read the policy text of the request, and look for a wildcard principal, for account IDs that are not yours and for push actions. It also matches attempts that failed (errorCode present): check errorCode, because an unauthorized attempt is worth seeing.

LevelMediumStatusExperimentalLog sourceAWS CloudTrail
title: ECR Repository Policy Set
id: 9ff12d0f-b173-4363-a599-fa6068da97aa
status: experimental
description: >-
  Detects SetRepositoryPolicy calls to Amazon ECR, which apply a
  resource-based policy to a repository. The policy can let another account,
  or IAM entities in it, pull the images of the repository or push to it.
  AWS documents that all ECR API actions are logged by CloudTrail and names
  SetRepositoryPolicy among the entries written for common tasks. The rule
  cannot tell who the policy admits: AWS publishes no example record for
  this event, so the rule does not read the policy. Read the policy text of
  the request, and look for a wildcard principal, for account IDs that are
  not yours and for push actions.
  It also matches attempts that failed (errorCode present): check errorCode,
  because an unauthorized attempt is worth seeing.
references:
  - https://docs.aws.amazon.com/AmazonECR/latest/userguide/logging-using-cloudtrail.html
  - https://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_SetRepositoryPolicy.html
  - https://docs.aws.amazon.com/AmazonECR/latest/userguide/security_iam_service-with-iam.html
  - https://attack.mitre.org/techniques/T1098/003/
author: Forestall
date: 2026-11-18
tags:
  - attack.persistence
  - attack.privilege-escalation
  - attack.t1098.003
logsource:
  product: aws
  service: cloudtrail
detection:
  selection:
    eventSource: ecr.amazonaws.com
    eventName: SetRepositoryPolicy
  condition: selection
falsepositives:
  - Infrastructure-as-code pipelines and platform teams that set repository policies when a repository is created or shared on purpose. AWS documents that creating a repository can write this entry as part of the task. Add the deployment roles to a filter_* selection on userIdentity.arn and review calls made by anyone else.
  - Policies that only admit a role of the same account or an AWS service also match.
level: medium

False positives

  • Infrastructure-as-code pipelines and platform teams that set repository policies when a repository is created or shared on purpose. AWS documents that creating a repository can write this entry as part of the task. Add the deployment roles to a filter_* selection on userIdentity.arn and review calls made by anyone else.
  • Policies that only admit a role of the same account or an AWS service also match.

ECR Repository Policy Set with a Wildcard Principal

Detects SetRepositoryPolicy calls whose policy text names a wildcard principal ("Principal": "*" or "AWS": "*"). A wildcard principal with an Allow effect and no condition lets principals of any AWS account perform the actions of the statement on the repository. The policy is read from requestParameters.policyText, which follows the policyText request parameter of the ECR API reference (a JSON string): AWS publishes no example record for this event, so confirm the field in your own events. The rule reads the policy as text with a regular expression that allows for whitespace and for a list of principals that starts with the wildcard. It does not read the Condition element: a wildcard that is narrowed by a condition such as aws:PrincipalOrgID also matches. It also matches attempts that failed (errorCode present): check errorCode, because an unauthorized attempt is worth seeing.

LevelHighStatusExperimentalLog sourceAWS CloudTrail
title: ECR Repository Policy Set with a Wildcard Principal
id: e4e59114-ec88-40f4-b968-b62c23dbb6a9
status: experimental
description: >-
  Detects SetRepositoryPolicy calls whose policy text names a wildcard
  principal ("Principal": "*" or "AWS": "*"). A wildcard principal with an
  Allow effect and no condition lets principals of any AWS account perform
  the actions of the statement on the repository. The policy is read from
  requestParameters.policyText, which follows the policyText request
  parameter of the ECR API reference (a JSON string): AWS publishes no
  example record for this event, so confirm the field in your own events.
  The rule reads the policy as text with a regular expression that allows
  for whitespace and for a list of principals that starts with the
  wildcard. It does not read the Condition element: a wildcard that is
  narrowed by a condition such as aws:PrincipalOrgID also matches.
  It also matches attempts that failed (errorCode present): check errorCode,
  because an unauthorized attempt is worth seeing.
references:
  - https://docs.aws.amazon.com/AmazonECR/latest/APIReference/API_SetRepositoryPolicy.html
  - https://docs.aws.amazon.com/AmazonECR/latest/userguide/logging-using-cloudtrail.html
  - https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html
  - https://attack.mitre.org/techniques/T1098/003/
author: Forestall
date: 2026-11-18
tags:
  - attack.persistence
  - attack.privilege-escalation
  - attack.t1098.003
logsource:
  product: aws
  service: cloudtrail
detection:
  selection_event:
    eventSource: ecr.amazonaws.com
    eventName: SetRepositoryPolicy
  selection_wildcard:
    requestParameters.policyText|re: '"(AWS|Principal)"\s*:\s*\[?\s*"\*"'
  condition: selection_event and selection_wildcard
falsepositives:
  - Repositories shared with a whole organization through a wildcard principal and an aws:PrincipalOrgID condition, which is a common pattern for central registries. Read the Condition element before closing the alert, and add the roles that deploy such policies to a filter_* selection on userIdentity.arn.
level: high

False positives

  • Repositories shared with a whole organization through a wildcard principal and an aws:PrincipalOrgID condition, which is a common pattern for central registries. Read the Condition element before closing the alert, and add the roles that deploy such policies to a filter_* selection on userIdentity.arn.

Detection logic

Patterns that need more than one event, a baseline or knowledge of your own environment. Each is a hypothesis to build and tune in your SIEM, not a ready rule.

Repository policy or replication rule names an account that is not yours

Detection hypothesisNeeds your own lists

Sharing a repository with one outside account is an ordinary call, and the request holds the account ID. Whether the account is an attacker's or one of yours is not in the event: it needs your own account list.

  1. Collect SetRepositoryPolicy, PutRegistryPolicy and PutReplicationConfiguration events from ecr.amazonaws.com.
  2. Extract every 12-digit account ID from the principals of the policy text, and the registry ID of every destination in the replication configuration.
  3. Compare each ID with the accounts of your organization and the third parties you have approved, and alert when an ID is on neither list.

EventsSetRepositoryPolicyPutRegistryPolicyPutReplicationConfiguration

LimitsIt needs a current list of your accounts and approved partners. The policy text and the destinations are request parameters of the ECR API reference, and AWS publishes no example record that shows them, so confirm the fields in your own events first.

Triage

  • Identify the caller (userIdentity.arn), the source IP address and the user agent, and the repository named in the request. Is the caller the pipeline or platform role that manages this repository?
  • Read the policy text of the request. Look for a wildcard principal, for account IDs that are not yours, and for which actions the statement allows, pull actions only or push actions as well.
  • For a replication change, read the destination registry IDs of the request and check whether each one is an account of your organization.
  • Check whether the repository was created just before by the same caller, because AWS documents that creating a repository can write a SetRepositoryPolicy entry as part of the task.
  • If push access was granted, look for PutImage events on the repository after the change and compare image digests with what the pipeline built.

Response

Once the attack is confirmed:

  1. Remove the access first. Put back the previous repository policy or delete the statement that admits the outside principal, and remove the registry policy statement or the replication rule that names an unknown account.
  2. Contain the identity that made the change by deactivating its access keys or revoking its role sessions.
  3. If push access existed, treat the images pushed in that period as untrusted. Redeploy workloads from images the pipeline built, by digest, and review what the affected workloads did.
  4. If pull access existed, treat the content of the images as disclosed and rotate every credential that was built into them.
  5. Check the other repositories of the registry for the same kind of statement.

Mitigation

  • Allow ecr:SetRepositoryPolicy, ecr:PutRegistryPolicy and ecr:PutReplicationConfiguration only to deployment and platform roles.
  • Do not use a wildcard principal in a repository policy without a condition that limits it to your organization.
  • Turn on tag immutability for repositories that production workloads pull from, so that an existing tag cannot be overwritten, and deploy by image digest where you can.
  • Do not build credentials into images, so that pull access discloses code only.
  • Review cross-account access to repositories with IAM Access Analyzer and compare repository policies with what your pipelines deploy.

Frequently asked questions

Does the repository policy rule tell me who was given access?

No. It fires on every SetRepositoryPolicy call, including policies that only admit a role of the same account or an AWS service. Read the policy text of the request. A second rule on this page fires only when that text names a wildcard principal, and a specific outside account has to be found by comparing account IDs with your own.

Why does the rule fire when a repository is created?

AWS documents that common tasks write several entries. Its example is the creation of a repository, for which GetAuthorizationToken, CreateRepository and SetRepositoryPolicy entries are generated. A policy set by the same caller right after CreateRepository is usually part of that task and not a later change.

Will CloudTrail show images being pulled from another account?

AWS documents that all ECR API actions are logged, and that a pull generates GetDownloadUrlForLayer and BatchGetImage entries. Whether the entries of a caller in another account are delivered to your trail is not stated on that page, so do not rely on seeing them. Treat the policy change itself as the event to act on.

Has this been seen in real intrusions?

This page was not written from an incident report, and no public report that describes it at the audit event level was used. It follows what AWS documents about repository policies, registry permissions and replication.

References

We respect your privacy

We use cookies to keep this site secure and working properly. With your permission, we also use optional cookies to understand usage and improve the experience. Cookie Policy

You can change your choice at any time.