Safeguard
Security Guides•

How do you find every service using a vulnerable base image?

Record the base image digest at build time with standard OCI annotations, then query registries and clusters. Steps to answer which services use it.

Safeguard Security Team
3 min read

To find every service using a vulnerable base image, record the base image reference and digest when you build, using standard OCI annotations, then search your registries and running workloads for that digest. Without build time records you must unpack layers or guess from Dockerfiles, which is slow and unreliable.

Why this is hard after the fact

An image is built on a base, and the base is built on another base. Once the build finishes, nothing in the final image says which tag you started from unless someone wrote it down. Tags also move. The Docker documentation describes tags as labels that can be reused or changed, while a digest is a content hash that identifies exactly one image.

So "we use debian slim" is not an answer. Which digest of it, at which build time, is.

The annotations to set

The OCI image specification defines pre defined annotation keys. These are the ones that help here:

KeyMeaning
org.opencontainers.image.base.nameFully qualified reference of the immediate base image
org.opencontainers.image.base.digestDigest of that base
org.opencontainers.image.revisionSource control revision of the packaged software
org.opencontainers.image.sourceURL of the source used to build the image
org.opencontainers.image.versionVersion of the packaged software

The spec says the base fields should name the immediate base that supplies the layers, not other images used in a multi-stage build. Keep that in mind when you read the data back.

Steps

  1. Add the annotations in your build. Most image build tools can set labels or annotations; make it part of the shared pipeline template so every service gets it.
  2. Resolve the base to a digest at build time. Write the digest, not just the tag.
  3. Ask the vulnerability question by digest. When a base image gets a new advisory, list the affected base digests.
  4. Search registries. Find images whose base digest matches. This gives candidates.
  5. Cross check with what runs. Compare to image digests in each cluster or account. Running matches are urgent, registry only matches are cleanup.
  6. Open one change per owner. Group by the source annotation or your service catalog.

For images built before you had annotations

Fall back to layer comparison: an image built on a base shares that base's layer digests as its first layers. It is a heuristic, so treat results as leads and confirm with the build file in the source repository.

Try it yourself

Open the demo to see how an image scan lists its operating system packages and findings. Look for the base layer entries, since those are what a base image advisory touches.

Click through it at your own pace, or open it full screen.

Quick check

Is pinning the base by digest enough?

It makes builds repeatable, but it also freezes the base until you update the digest. Pair it with a routine for refreshing.

Do multi-stage builds break this?

Only the final stage's base matters for what ships. The OCI spec says the base fields should name the immediate base, not images used in earlier stages.

Safeguard's container image scanning and SBOM generation record image contents so base layer findings can be traced across services. A free scan is at gold.safeguard.sh/scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.