Container registry and image security review
Brief
Whoever can push to a registry decides what production runs, so the review starts with push rights and ends with what the images already carry. It reads repository policies and role assignments, checks signatures and the admission rule that should enforce them, dates the base images, and lists secret files in layers by name without opening them.
On this page
- Situation
- Pull rights for the review identity on the registries in scope, read on their policies and role assignments, read on the client's Dockerfiles, and where a cluster runs the images, the read-only kubeconfig from the Kubernetes first hour. Everything here is a read: we pull manifests and layers, never push, tag or delete, and where a layer holds a credential file we record its path and never read its contents. Only the registries and repositories the scope letter names are reviewed.
- Goal
- A registry table: who can push to each repository and whether tags can be overwritten, whether anyone outside the client can pull, the signing and admission state, base image ages, and credential file and variable names found in layers.
- Outputs
- The ECR lines were captured on 8 Nov 2026 (UTC) in the Atarus lab AWS Organization from the Atarus Bench edition
2026.11-cloud-0.3, with AWS CLI 2.39.3 and the edition's jq 1.7.1, in a member account through the lab's read-only review roleatarus-review, with account ids replaced by stable placeholders. The other outputs stay representative on placeholder registries until the lab has an Azure registry, a cluster and the image tools they need.
Check first
- The registries in scope (ECR, ACR, Artifact Registry, GitHub Container Registry or self-hosted) and which repositories production pulls from.
- Which identities push: CI roles, people, and any shared admin user.
- Whether images are signed, with which key or identity, and what is meant to check the signature.
- The Dockerfiles or build definitions, from the client's repositories.
- Where registry logs go: CloudTrail for ECR, diagnostic settings for ACR.
Steps
Who can push to the registry, and who can pull?
aws ecr describe-repositories --query 'repositories[].[repositoryName,imageTagMutability]' --output text
aws ecr get-repository-policy --repository-name payments/api --query policyText --output text \
| jq -c '.Statement[] | {Effect, Principal, Action}'
Expected output
payments/api MUTABLE # <- a push can replace the image behind a tag already deployed
app-api MUTABLE
base/python IMMUTABLE
{"Effect":"Allow","Principal":{"AWS":"arn:aws:iam::444455556666:root"},"Action":["ecr:BatchGetImage","ecr:GetDownloadUrlForLayer"]} # <- another account can pull: it belongs on the client's vendor list or it is a finding
On Azure Container Registry the same questions are the admin user, anonymous pull and the role assignments on the registry:
az acr show --name corpregistry --query "{admin:adminUserEnabled,anonPull:anonymousPullEnabled,network:publicNetworkAccess}"
az role assignment list --scope "$(az acr show --name corpregistry --query id -o tsv)" \
--query "[].{role:roleDefinitionName,principal:principalName}" -o table
Expected output
{
"admin": true, # <- one shared username and password with push rights
"anonPull": false,
"network": "Enabled"
}
Role Principal
------- -------------
AcrPush ci-build
Owner contractor-sp # <- Owner can push, delete and turn the admin user back on
Push decides what runs, and a mutable tag lets a push change what an existing deployment pulls next time it restarts. In ECR, push comes from IAM policies with ecr:PutImage as well as repository policies, so the CI role check from the cloud first hour applies here too. A repository policy with "Principal": "*" and no aws:PrincipalOrgID condition lets any AWS account pull, which is how a private image becomes public. The lab's policy names one other account instead, the lab's second member account, so every identity there that its own policies allow can pull payments/api. Two of the three repositories have mutable tags. In ACR, AcrPush, Contributor, Owner and the admin user can all push.
Negative result. Only the CI identity can push, tags are immutable, no wildcard principal without an organization condition, any other account named is on the client's vendor list, the ACR admin user is off and anonymous pull is off.
Fix. Turn off the ACR admin user, make production tags immutable, give push to the CI identity alone, add an organization condition to any wide repository policy, and deploy by digest rather than tag.
Are images signed, and does admission refuse unsigned ones?
cosign verify --key cosign.pub registry.example.com/payments/api:1.4.2
kubectl get clusterpolicies.kyverno.io -o json | jq -r '.items[]
| select(any(.spec.rules[]?; has("verifyImages")))
| .metadata.name + "\t" + ([.spec.validationFailureAction, (.spec.rules[].verifyImages[]?.failureAction)]
| map(select(. != null)) | join(","))'
Expected output
Error: no signatures found # <- the deployed image carries no signature
verify-signed-images Audit # <- the policy reports unsigned images and lets them run
A signature only helps if something checks it before a pod starts. Sigstore's policy controller, Kyverno verifyImages rules and Ratify with Gatekeeper all do that; the query above covers Kyverno, where an empty failure action also means Audit. A signature from the client's pipeline proves the image came from that pipeline, not that the pipeline was clean, as the LiteLLM release compromise showed with a malicious build signed and published by the project's own release process.
Negative result. cosign verify reports the checks it passed for the expected key or identity, and the admission policy enforces in every namespace that runs workloads.
Fix. Sign every image in CI with a KMS key or a keyless identity bound to the pipeline, enforce the check at admission, and pin deployments to digests.
How old are the base images?
git grep -h '^FROM' -- '*Dockerfile*' | sort | uniq -c
crane config registry.example.com/base/python:3.12-slim | jq -r .created
Expected output
3 FROM node:16-bullseye # <- Node.js 16 has been out of support since September 2023
2 FROM registry.example.com/base/python:3.12-slim
2025-02-11T08:14:52.180921Z # <- the internal base was last built in February 2025
The base image carries the operating system packages, so an image is as current as its base at the moment it was built. Internal base images are often the oldest thing in a registry, because nobody owns their rebuild. created is the build time in the image config; a reproducible build may set it to a fixed date, in which case the client's build records give the real one.
Negative result. Every FROM names a supported runtime, and every internal base was rebuilt within the client's patch window.
Fix. Rebuild base images on a schedule and on upstream releases, pin them by digest with an automated update, and retire end-of-life runtimes.
Are secrets baked into image layers?
img=registry.example.com/payments/api:1.4.2
crane config --platform linux/amd64 "$img" | jq -r '.config.Env[] | split("=")[0]'
for d in $(crane manifest --platform linux/amd64 "$img" | jq -r '.layers[].digest'); do
crane blob "${img%:*}@$d" | tar -tzf - 2>/dev/null \
| grep -E '(^|/)(\.env|\.npmrc|\.pypirc|\.git-credentials|credentials|id_rsa|id_ed25519)$' \
| sed "s|^|${d:7:12} |"
done
Expected output
PATH
NODE_VERSION
NPM_TOKEN # <- a token baked into the image config; the value ships to everyone who can pull
3f9a1c0b7e22 app/.npmrc # <- in a layer, so still in the image even if a later step deleted it
Layers only add. A file deleted in a later build step is hidden by a marker in the next layer, but the earlier layer still holds it for anyone who can pull. The loop lists file names in each layer and the config query prints variable names, so no value reaches our terminal. Anything found is reported by path and the client rotates it.
Negative result. No credential-like variable names in the config and no credential files in any layer.
Fix. Pass build-time tokens as BuildKit secret mounts, copy only build output into the final stage of a multi-stage build, rotate every credential found, and rebuild the affected images.
The defender sees
For ECR, CloudTrail records DescribeRepositories and GetRepositoryPolicy under the review identity, and every pull shows as BatchGetImage and GetDownloadUrlForLayer events. For ACR, the diagnostic logs record our login and each pull; the role assignment listing is a read and leaves no activity log entry. The Kyverno query appears in the cluster audit log as a list on cluster policies. A review identity pulling every layer of a production image is unusual, and pulls by anything other than nodes and CI are worth an alert. The event that matters most is a push from anything but the pipeline; if that does not alert, it goes in the report.
Done when
Every identity with push is listed per registry, tag mutability and anonymous or cross-account pull are recorded, a signature check and the admission result exist for each production image, each base image has a build date, and every credential name found in a layer is recorded by path.
Not covered
Vulnerability scanning of the packages inside images, the build pipeline's own trust (see CI pipeline OIDC trust review), and runtime container escapes.