CL-0004: Unpinned image tags (implicit :latest)¶
Severity: MEDIUM (how it is derived)
The service's image is latest, another moving alias, or has no tag at all, so
each pull can deliver a different image. Pin a version tag, then a digest
(CL-0019) for the guarantee a tag cannot give.
Fix¶
services:
web:
image: nginx:1.27-alpine # was nginx:latest, or a bare nginx
- List the versions the image publishes.
crane, from go-containerregistry, lists the tags of an image on any registry, and runs as a container, so there is nothing to install:
# List nginx's tags and keep the 1.27 alpine builds
docker run --rm gcr.io/go-containerregistry/crane ls nginx \
| grep -E '^1\.27\.[0-9]+-alpine$'
# 1.27.0-alpine
# ...
# 1.27.5-alpine
1.27-alpine follows that line's patch releases; 1.27.5-alpine stays
where it is until you change it. Either clears this rule.
- Put the tag in the file, then pull and restart the service:
docker compose pull web && docker compose up -d web
- Check the finding is gone:
compose-lint -q compose.yaml | grep CL-0004 # prints nothing once fixed
A version tag now raises CL-0019 instead, which asks for the digest. Tag pinning protects against accidental version churn; digest pinning also protects against someone overwriting the tag in the registry:
image: nginx:1.27-alpine@sha256:...
Cosign signature verification or registry-level tag immutability add a further layer where your registry supports them.
Images with no version tags¶
Some projects publish no version tags. Excalidraw, for example, publishes
latest and per-commit sha-… tags but no version, so "pin the version" has
nothing to pin to. Pin the digest instead. This rule already accepts a digest-pinned
reference, because the digest is the real pin and the tag is a label:
image: excalidraw/excalidraw:latest@sha256:<digest>
Get the current digest:
# Print the multi-arch index digest without pulling the image
docker buildx imagetools inspect excalidraw/excalidraw:latest --format '{{ .Manifest.Digest }}'
then let Renovate bump it on a schedule (CL-0019 has the config).
This does not break when the tag moves: Docker resolves by digest and ignores the tag for content, so you keep pulling the exact image you pinned and upgrades happen only when the pin changes. The only failure case is the pinned digest being deleted from the registry (rare on Docker Hub; possible on a self-hosted registry with garbage collection enabled).
Tested on: Docker 29.7.2 with Compose 5.5.0, on a host without AppArmor (Yama ptrace_scope 1); the Fix steps above were re-run there in October 2026. Also measured in throwaway VMs in October 2026 (Docker 29.9.1 or 29.1.3): on the classic image store (overlay2, containerd snapshotter off, Ubuntu 24.04 with AppArmor), RepoDigests gives the same index digest crane returns. Not tested: Dependabot.
What it detects¶
Services using mutable image tags (latest, stable, edge, nightly, dev, test) or no tag at all. Build-only services (no image: key) and digest-pinned images (@sha256:...) are skipped.
The mutable-tag list is a closed enumeration of well-known aliases. Tags like main, master, release, prod, slim, or alpine are also mutable in practice but are not flagged here — distinguishing "moving target" from "stable channel" requires registry knowledge the linter does not have. CL-0019 (digest pinning) is the stronger check; treat CL-0004 as catching the obvious cases.
Why it matters¶
Mutable tags mean every pull can produce a different image. This breaks reproducibility, makes rollbacks impossible, and opens supply chain risk — a compromised upstream push to latest affects you on next deploy with no visibility into what changed.
ATT&CK coverage¶
Remediating this finding contributes to mitigating the following MITRE ATT&CK techniques (pinned to ATT&CK v18). compose-lint is a static analyser, so this is mitigation coverage — it detects nothing at runtime.
| Technique | Tactic |
|---|---|
| T1204.003 User Execution: Malicious Image | Execution |
See also¶
- CL-0019 — digest pinning (stronger guarantee against tag mutation)
- Hardening guide, step 2 — where this rule fits when hardening a whole file
Severity derivation¶
Derivation (see severity model):
- Baseline: B — the attacker can read the compose file, or influence what the image reference resolves to; no code execution anywhere yet
- Precondition: Second flaw — a mutable tag only becomes an attack when something outside this file changes what it points at: a registry compromise, a hijacked publisher account, a poisoned build
- Impact: Single container — the substituted image runs as this service. Reaching further needs a privilege this file grants elsewhere, which is scored by the rule that grants it
- Qualifier/modifier: none
- Derived: Second flaw × Single container = MEDIUM
- Shipped: MEDIUM
- Evidence: Not runtime-observable: tag mutability is a registry property, and compose-lint does not read the registry (ADR-020). The premise is the registry API contract — a tag is a mutable pointer, and
docker pullresolves it at pull time
References: - OWASP Docker Security Rule #13 — general supply-chain framing; it does not mention tags or version pinning - CIS Docker Benchmark 5.28 — Ensure that Docker commands always make use of the latest version of their image
A reference means the rule relates to that source. It does not mean a file with no finding complies with it. The CIS, OWASP and ATT&CK mapping for every rule, and the tags SARIF output carries for it, are on Standards mapping.