Skip to content

Lesson 16 of 24Security and supply chain

Scanning, SBOMs and Signed Images

Triage CVE scan results like a senior, publish SBOMs and provenance, sign images with cosign, and only deploy what your pipeline built.

15 min read0/4 questions

A new critical CVE in a compression library hits the news on a Monday morning. Your security team asks two questions before lunch: which of our running images contain it, and can we prove the image in production is the one our CI built? A team that answers in ten minutes has scanning in the registry, an SBOM for every image, and signed digests. A team that answers next week is grepping Dockerfiles. Docker in Production showed a one-line trivy image in CI. This lesson builds the rest: how scanners actually work, how to triage what they find without drowning, and how SBOMs, provenance and signatures let you prove what you ship.

How a scanner sees your image

A scanner does not run your code. It unpacks the image layers and reads package metadata: /var/lib/dpkg/status for Debian packages, the apk database for Alpine, *.dist-info folders for Python, package-lock.json or node_modules/*/package.json for Node, and build information embedded in Go and Rust binaries. It turns that into a list of package names and versions, then matches each against vulnerability databases (the NVD, distribution security trackers like Debian's, GitHub's advisory database, and others).

That design explains the blind spots, which interviewers like to ask about:

  • Software with no metadata is invisible. A binary fetched with curl in a RUN step, a vendored C library, or a copied-in .jar with stripped manifests produces no finding, even if it is years out of date.
  • Distribution backports confuse naive matching. Debian often patches an old version number instead of upgrading. Good scanners use the distribution's own tracker, so openssl 3.0.x-deb12u5 is judged as fixed even though upstream says 3.0.x is vulnerable.
  • Results change without your image changing. The image from March has the same packages in October, but dozens of new CVEs have been published against them since. A scan is a point-in-time answer.

That last point decides where you scan. One scan in CI is not enough:

  1. In CI, to stop a release that adds a known critical issue.
  2. In the registry, on push and continuously afterwards. Amazon ECR enhanced scanning (powered by Amazon Inspector), Docker Scout on Docker Hub, and Harbor's Trivy integration all rescan stored images when new advisories arrive.
  3. Against what is running, because the image deployed six months ago and never rebuilt is the one most likely to be vulnerable. Kubernetes operators and cloud security tools inventory running images for this.

The common tools are Trivy (Aqua, open source, scans images, filesystems, IaC and more), Grype (Anchore, open source, pairs with Syft), Docker Scout (built into the Docker CLI), and the scanners built into registries. They use different databases and matching rules, so the same image gives different counts in each. Pick one as the gate and do not panic when another disagrees.

trivy image --severity CRITICAL --ignore-unfixed --exit-code 1 ghcr.io/acme/api:sha-7f3c2a1docker scout cves --only-severity critical,high --only-fixed --exit-code ghcr.io/acme/api:sha-7f3c2a1

Both commands fail (non-zero exit) only for serious issues that have a fix, which is the useful gate. docker scout cves --ignore-base hides CVEs inherited from the base image, handy for asking "what did our layers add?"

Triage: the skill that makes scanning useful

Run a scanner on python:3.13 (the full image) and you get a few hundred findings. A team that tries to fix all of them gives up within a month and starts ignoring the scanner. Triage is how you avoid that, and it is the part of this topic that separates seniors from juniors.

Ask four questions about each finding:

  • Is there a fix? "Fixable" means a newer package version resolves it. Fixable criticals are cheap to remove: bump the base or the dependency. "No fix available" findings cannot be fixed by you today; you track them.
  • How likely is exploitation? CVSS severity measures how bad it would be, not how likely. EPSS (Exploit Prediction Scoring System, from FIRST) estimates the probability of exploitation in the next 30 days. CISA's KEV catalog lists vulnerabilities known to be exploited in the wild. A "medium" in KEV deserves more urgency than a "critical" that nobody has ever exploited.
  • Is the vulnerable code reachable? A CVE in ncurses matters little in a web service with no terminal. A CVE in an XML parser that your API feeds with user uploads matters a lot. Reachability is your judgment plus your code, which is why scanners cannot do this step for you.
  • Is it in the runtime image at all? Findings in build tools vanish when you use multi-stage builds. Scan the image you ship, not the build stage.

When you decide a finding does not apply, record it instead of silently filtering it. Two formats exist. A .trivyignore file lists IDs with an optional expiry, so exceptions get revisited:

.trivyignore
# zlib inflate bug: we never decompress untrusted input. Owner: platform team.
CVE-2025-0003 exp:2026-12-01

VEX (Vulnerability Exploitability eXchange) is the standard, machine-readable version: a signed statement that product X is "not_affected" by CVE Y, with a justification such as "vulnerable code not in execute path". Trivy reads VEX with --vex, and Docker Scout can attach VEX statements to images. Vendors now publish VEX alongside images so customers' scanners stop flagging issues the vendor already analyzed.

This policy runs the four questions over a scan result and honors exceptions only until they expire. The CVE IDs are invented.

Pythontriage.py
from datetime import date TODAY = date(2026, 10, 22) findings = [ # id, package, severity, fixed_in, epss, in_kev ("CVE-2026-0001", "openssl", "CRITICAL", "3.5.4", 0.92, True), ("CVE-2026-0002", "libxml2", "HIGH", "2.14.6", 0.03, False), ("CVE-2025-0003", "zlib", "CRITICAL", None, 0.01, False), ("CVE-2026-0004", "jinja2", "MEDIUM", "3.1.7", 0.40, False), ("CVE-2025-0005", "ncurses", "HIGH", None, 0.02, False),] # .trivyignore-style exceptions: id -> (expires, reason)ignores = { "CVE-2025-0003": (date(2026, 12, 1), "not reachable: we never call inflate on untrusted input"), "CVE-2025-0005": (date(2026, 9, 30), "terminal library, no TTY in prod"),} def decide(cve, sev, fixed, epss, kev): if cve in ignores: expires, reason = ignores[cve] if expires >= TODAY: return f"ACCEPTED until {expires}: {reason}" # an expired exception falls through and is judged again if kev or (fixed and sev == "CRITICAL"): return "BLOCK release" if fixed and (sev == "HIGH" or epss >= 0.1): return "FIX this sprint" if fixed: return "batch with next base bump" return "WATCH: no fix yet, re-check weekly" for cve, pkg, sev, fixed, epss, kev in findings: print(f"{cve} {pkg:<8} {sev:<8} -> {decide(cve, sev, fixed, epss, kev)}")
Output
Press Run (⌘ Enter) to see what happens.

Look at the jinja2 line. It is only medium severity, but its high EPSS score moves it up to this sprint. The ncurses exception expired in September, so it is judged again and lands on the watch list. Change TODAY to 2026-12-02 and the zlib exception expires too.

Predict the outputPython

What does this print?

from datetime import date

today = date(2026, 10, 22)
ignores = {"CVE-A": date(2026, 9, 30), "CVE-B": date(2026, 12, 1)}
found = ["CVE-A", "CVE-B", "CVE-C"]

still_failing = [c for c in found if c not in ignores or ignores[c] < today]
print(still_failing)
Need a nudge? Hints walk you through it.
Quick check
Your gate blocks on a CRITICAL CVE in a library with no fixed version available, and the release is urgent. What is the best response?
Need a nudge? A hint rules out a wrong answer.

SBOMs: the ingredients list

An SBOM (software bill of materials) is the package list a scanner builds, saved as a document: every package, version, license, and an identifier called a purl (package URL, like pkg:pypi/jinja2@3.1.6). Two formats dominate. SPDX (a Linux Foundation project, also an ISO standard) grew out of license compliance. CycloneDX (OWASP) grew out of security use and also covers services and VEX. Most tools read and write both.

Why bother saving it? Because of the Monday morning question. With an SBOM per image stored next to the image, "which images contain zlib 1.3.1?" is a query over documents you already have, not a rescan of a thousand images. Regulation also pushes this way. US Executive Order 14028 (2021) led federal buyers to require SBOMs from software suppliers, and the EU Cyber Resilience Act requires manufacturers of products with digital elements to produce an SBOM, with its obligations phasing in through 2027. Enterprise customers increasingly ask for one in security questionnaires.

You can generate one at build time or after the fact:

docker buildx build --sbom=true --push -t ghcr.io/acme/api:sha-7f3c2a1 .syft ghcr.io/acme/api:sha-7f3c2a1 -o spdx-json=sbom.spdx.json -o cyclonedx-json=sbom.cdx.jsongrype sbom:./sbom.spdx.json

--sbom=true makes BuildKit run a Syft-based scanner and attach an SPDX document to the image as an attestation. By default it only scans the final stage. The last line shows the payoff: Grype can check a saved SBOM against today's vulnerability data without pulling the image again.

Provenance: proving where an image came from

An SBOM says what is inside. Provenance says how it was made: which source repository and commit, which builder, which build steps and inputs. It is the answer to "did this image really come from our CI, from main, from the commit we reviewed?"

SLSA (Supply-chain Levels for Software Artifacts) is the framework that grades this. Roughly: Build L1 means provenance exists; L2 means a hosted build platform generated and signed it; L3 means the build platform is hardened so even the build's own steps cannot forge it. Docker Hardened Images, for example, ship with SLSA Build Level 3 provenance.

BuildKit attaches provenance by default in mode=min: timestamps, the frontend, source repository and revision, platform, and materials such as base image digests. mode=max adds the full build definition, the Dockerfile itself, and the values of build arguments.

docker buildx build --provenance=mode=max --sbom=true --push -t ghcr.io/acme/api:sha-7f3c2a1 .

One practical gotcha: attestations need a registry. --load into the classic local image store drops them, so build and push, then inspect with docker buildx imagetools inspect ghcr.io/acme/api:sha-7f3c2a1 --format "{{ json .SBOM.SPDX }}".

Signing with cosign, without keys

Provenance and SBOMs are only worth something if nobody can swap the image underneath them. Sigstore cosign signs the image's digest, and the modern way is keyless: no long-lived private key to store, rotate or leak.

Keyless signing in GitHub Actions
CI jobFulcio CARekor logRegistrypush image, get digest sha256:4c1e...OIDC token + new public keyshort-lived certificaterecord signaturestore signature next to image

Sign the digest, never a tag. A tag can be moved to other content later; a digest is the content.

1/5

In a workflow the signing step is one line, with id-token: write permission so the job can request an OIDC token:

cosign sign --yes ghcr.io/acme/api@sha256:4c1e9f0b...

Verification checks who signed, not just that someone did. Anyone can get a valid Sigstore signature for their own identity, so a verify without identity checks proves nothing:

cosign verify ghcr.io/acme/api@sha256:4c1e9f0b... \  --certificate-identity https://github.com/acme/api/.github/workflows/release.yml@refs/heads/main \  --certificate-oidc-issuer https://token.actions.githubusercontent.com

cosign attest signs other documents, such as an SBOM or a scan result, and binds them to the same digest. How cosign stores signatures in the registry (older tag-based .sig objects or the newer OCI referrers mechanism covered in Registries and Image Distribution) depends on the version and the registry; check the cosign docs for yours.

Enforcing it at deploy time

A signature nobody checks is decoration. The check belongs at the last gate: the cluster's admission control. Kyverno and the Sigstore policy-controller run as admission webhooks in Kubernetes and reject any pod whose image is not signed by an allowed identity.

kyverno-verify-images.yaml
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: only-signed-acme-images
spec:
  rules:
    - name: verify-signature
      match:
        any:
          - resources:
              kinds: [Pod]
      verifyImages:
        - imageReferences: ["ghcr.io/acme/*"]
          failureAction: Enforce
          mutateDigest: true
          attestors:
            - entries:
                - keyless:
                    subject: "https://github.com/acme/*/.github/workflows/release.yml@refs/heads/main"
                    issuer: "https://token.actions.githubusercontent.com"
                    rekor:
                      url: https://rekor.sigstore.dev

mutateDigest: true rewrites ghcr.io/acme/api:sha-7f3c2a1 to the verified digest in the pod spec, so the node runs exactly what was checked. Kyverno is moving image verification to a newer ImageValidatingPolicy type, so check the Kyverno docs for the current form before you copy this. On AWS, AWS Signer can sign ECR images through the Notation tool; check the AWS docs for how verification is enforced on your platform. Pair the signature policy with a rule that only images from your own registry may run at all.

Keeping base images fresh

Most CVEs in your image are in the base, not your code. Two habits keep them down:

  • Automate base bumps. Pin the base by digest for reproducibility and let Renovate or Dependabot open a PR when a new digest is published for that tag. Merge those like any other dependency update, with tests.
  • Rebuild on a schedule even when code does not change. A weekly scheduled CI run rebuilds, rescans and re-signs, picking up patched packages. An image built once and deployed for a year accumulates every CVE published in that year.

Also watch the base's support window. Debian, Alpine and language runtimes each have end-of-life dates, after which "no fix available" becomes permanent. When Debian 13 shipped in 2025, images still on Debian 12 started a countdown, and a scanner will not warn you about that until the findings pile up.

The whole pipeline

From commit to admitted pod
Git commit: reviewed on mainGit commitreviewed on mainBuild: SBOM + provenanceBuildSBOM + provenanceRegistry: by digestRegistryby digestScan gate: fixable criticalsScan gatefixable criticalscosign sign: keyless OIDCcosign signkeyless OIDCAdmission: verify identityAdmissionverify identitycheckoutpushpull digestpasssignaturepull

CI builds from a reviewed commit. BuildKit attaches an SBOM and provenance that names this repository and commit.

1/5

Here is that design as a GitHub Actions workflow. It pushes first, scans the pushed digest, and signs only on a pass. An image that failed the scan sits unsigned in the registry, and admission will refuse it.

.github/workflows/release.yml
name: release
on:
  push:
    branches: [main]
 
permissions:
  contents: read
  packages: write
  id-token: write # lets cosign request an OIDC token
 
env:
  IMAGE: ghcr.io/acme/api
 
jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: docker/setup-buildx-action@v3
      - uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - id: build
        uses: docker/build-push-action@v6
        with:
          push: true
          tags: ${{ env.IMAGE }}:sha-${{ github.sha }}
          sbom: true
          provenance: mode=max # safe only because no secrets are build args
      - name: Scan the pushed digest
        uses: aquasecurity/trivy-action@v0.36.0 # pin to the release's full commit SHA
        with:
          image-ref: ${{ env.IMAGE }}@${{ steps.build.outputs.digest }}
          severity: CRITICAL
          ignore-unfixed: true
          exit-code: "1"
      - uses: sigstore/cosign-installer@v4.1.0
      - name: Sign the digest
        run: cosign sign --yes ${{ env.IMAGE }}@${{ steps.build.outputs.digest }}

That comment on the Trivy step is not pedantry. In March 2026 attackers used stolen credentials to force-push malicious code onto almost every version tag of aquasecurity/trivy-action, and the injected code stole CI secrets before running a normal-looking scan. Your security scanner is part of your supply chain too. Pin third-party actions to full commit SHAs, as Security Hygiene for Every Engineer recommends, and let Renovate keep the pins current.

Match the pairs0/5 matched

Match each artifact to the question it answers.

Choose an item, then its match on the other side.
Put it in order5 steps

Order the release steps so that only scanned images can ever run in production.

  1. Tap the steps below in the right order.
Need a nudge? A hint shows where it starts.
Key terms
SBOM
A software bill of materials: every package and version in an artifact, in SPDX or CycloneDX format.
EPSS
Exploit Prediction Scoring System: the estimated probability a CVE is exploited in the next 30 days.
KEV
CISA's Known Exploited Vulnerabilities catalog: CVEs with confirmed exploitation in the wild.
VEX
A machine-readable statement of whether a product is actually affected by a given CVE, and why.
provenance
An attestation describing how an artifact was built: source, commit, builder and steps.
SLSA
Supply-chain Levels for Software Artifacts: a framework grading how trustworthy a build's provenance is.
keyless signing
Sigstore signing with a short-lived certificate tied to an OIDC identity, recorded in the Rekor log.