Video in progress

How do you control the supply chain security of container images: who built it, what is inside, and whether it was tampered with?

I build images only inside CI, from a minimal base; I generate an SBOM and scan for CVEs; I sign the image (cosign, for example), and in the cluster I accept only signed images from the internal registry, enforced by an admission policy.

📖 Answer

You need to answer three questions: what is inside, where did it come from, and was it modified along the way.

What is inside: at build time I generate an SBOM (CycloneDX or SPDX), using cyclonedx-maven-plugin for Maven and Syft for the image. Then a scan with Trivy or Grype. The policy: a CRITICAL CVE with a fix available fails the build, and the rest go into a report. If you block everything, teams find a way to turn the scanner off.

Where it came from: only the CI runner builds, with no pushes from a developer laptop. A SLSA provenance attestation records which commit, which pipeline and which builder. Base images are also mirrored into the internal registry and pinned by digest.

Was it modified:

cosign sign --key cosign.key registry.example.uz/orders@sha256:...
cosign verify --key cosign.pub registry.example.uz/orders@sha256:...

In the cluster, Kyverno or the Sigstore policy-controller rejects a pod with an unsigned image. Keyless (OIDC) signing makes key management easier.

Java-specific points:

  • an internal proxy (Nexus/Artifactory) and checksum verification for Maven/Gradle dependencies; dependency verification in Gradle;
  • typosquatting and hijacked maintainer accounts are real, so review the addition of any new dependency;
  • a JRE or jlink runtime in the image, not a JDK: fewer binaries, fewer CVEs.

The image scanner should not run once at build time but regularly on the registry: an image that was clean yesterday shows up with a new CVE tomorrow.