# Security in Container registry

Who may push, pull and manage what (IAM), what is audited, and what a public repository exposes.

## IAM actions

Every request, through the registry, the API, the CLI, Terraform or the console, is checked against
your IAM policies. A repository's resource name is
`rn:ews::<organization id>:ecr:repository/<repository id>`; registry-wide settings (signing,
pull-through cache, storage quota, aliases) are checked on `rn:ews::<organization id>:ecr:*`, and
the lifecycle default on `rn:ews::<organization id>:ecr:lifecycle-default/image`.

(The table of IAM actions is generated on the web page.)
- A policy names one repository by its id, or all of them; there are no name prefixes such as
  `team/*`.
- `docker push` needs `ecr:PushImage` on the repository; to a name that has no repository yet,
  `ecr:CreateRepository` on the registry instead.
- `docker pull` needs `ecr:PullImage`, unless the repository is public and no credentials are
  sent. `ecr:PullImage` is marked sensitive and is not in the read-only policies.
- A registry delete (`DELETE /v2/<repository>/manifests/<reference>`) needs `ecr:DeleteImage`, or
  `ecr:PushImage`.
- Bringing an image in through a pull-through cache needs `ecr:BatchImportUpstreamImage` on the
  registry.
- `ecr:GetAuthorizationToken` counts as a write: a login token carries your registry rights for 12
  hours.
- The console's repository pages need `ecr:DescribeRepositories` on the repository; without it they
  answer 404. Its **Images** tab lists images with that permission alone, while the API's image list
  needs `ecr:ListImages`.

## Audit

A write through the API that reaches its permission check is recorded in the audit log, allowed
or denied; issuing a login token counts as a write. A request refused before that, for a malformed
id or body, is not recorded. In the registry protocol, creating a repository by a push and bringing an image in
through a pull-through cache are recorded; pushes, pulls and deletes are not. See
[Audit log](/docs/audit-log).

## Public repositories

A public repository serves anonymous pulls only. An anonymous registry token names that one
repository, grants `pull` and nothing else, and reaches only the layers its own images reference.
Every write without credentials is refused with `DENIED` `anonymous access is read-only`.

## Isolation

The registry host names your organization; a credential of another organization is refused. A
layer is served from a repository only if that repository holds it, whatever its digest, so a
digest from a build log reveals nothing in another repository.

## Related

- [Make a repository public](make-a-repository-public.md)
- [Log in to the registry](log-in.md)
