Skip to content

Lesson 10 of 13 · 11m

Tags Lie; Digests and Signatures Don't

Mutable tags versus pinned digests, keyless cosign signing, admission-time verification, and registry allowlists.

A tag is a pointer, and pointers move

registry.example/app:1.4.2 does not name an image. It names a current association between a string and a digest, held by the registry and changeable by anyone with push rights — your CI, a compromised registry account, or the upstream project's own hijacked pipeline. The registry will happily repoint 1.4.2 at a backdoored layer set, and every kubectl rollout restart re-pulls whatever the tag says today.

The digest is the immutable name: registry.example/app@sha256:abc…. Pin it in manifests and the tag's mutability stops mattering — the pull either gets exactly those bytes or fails. See what actually ran:

kubectl get pods -A -o jsonpath='{range .items[*]}{.spec.containers[*].image}{"\n"}{end}'
kubectl describe pod web | grep -i imageid

imageID shows the resolved digest — what the tag mapped to when it pulled.

Two caching wrinkles decide whether pinning helps: imagePullPolicy defaults to IfNotPresent for tagged images, so a node reuses its cached copy even after the tag repoints upstream (silent staleness), while Always re-pulls every start (fresh, but every pod start now depends on registry uptime and rate limits). The AlwaysPullImages admission plugin exists for the paranoid option. Note that pinning can itself be enforced — Kyverno images rules and admission policies can reject any pod spec carrying a bare tag instead of a digest, so "we pin digests" is a property of the cluster, not a habit of the deployers.

Signatures beat scanning

Image scanners answer "which known CVEs are in this image's packages." They cannot answer "is this the image my builder produced" — a typosquat (nginx-ingress-controler), a repushed tag, or a freshly backdoored base scans clean because the malice isn't a published CVE. Provenance is a different problem with a different tool: signatures.

Cosign (Sigstore) signs image digests. Keyless mode signs with a short-lived Fulcio certificate bound to an OIDC identity — GitHub Actions's OIDC token, your build system — and records the signature in Rekor's transparency log. The question it answers at admission time is exactly the right one: "was this digest signed by an identity I trust?"

Enforcement happens at admission:

  • Kyverno verifyImages rules check cosign signatures (and attestations) before allowing a pod.
  • Sigstore policy-controller does the same as a validating webhook.
  • Ratify + Gatekeeper verify signatures via the external_data interface.

Either way the pod spec carries a digest or tag and the cluster refuses it without a valid signature from your signer identity. Pair that with a registry allowlist — allowedRegistries/allowedImageRepos-style policy that refuses pulls from unapproved registries — and typosquats die at admission rather than at pager time.

Signatures also compose with attestations: cosign can sign an in-toto/SLSA provenance attestation — a signed statement of how the image was built (builder identity, source commit). Verifying provenance, not just the artifact signature, answers "was this built by my CI from my repo" — which a stolen-registry-credential push fails outright.

The evidence this isn't theoretical

JFrog's February 2024 Docker Hub analysis found millions of malicious repositories — roughly a fifth of all public repos — hosting phishing kits, malware droppers, and scam content in repository metadata and images. Docker Hub has repeatedly purged cryptominer images seeded under plausible names. None of that is exotic; it's what pulling an unverified public image at 3am can deploy.

What to actually do

Private registry as the only pull source (Harbor pull-through cache gives you availability plus scanning at the boundary), digest pinning on every deployment, cosign verification enforced at admission, and a registry allowlist so docker.io simply cannot be pulled. Scanners stay — for patch hygiene on what you did intend to run. Provenance is for proving it was what you intended.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.