Immutable Container Deployments with Cosign, SBOMs, and Trivy

Infrastructure & DevOps

Deploy immutable containers with Trivy scans, Syft SBOMs, Cosign signatures, digest-pinned Kubernetes manifests, and admission-time policy checks safely.

TL;DR

  • Build one container image, identify it by digest, scan that exact artifact, generate an SBOM, sign it, and deploy the same digest.
  • A tag is a mutable pointer. A digest identifies fixed image content. Use digest references in deployment manifests to avoid a tag moving between verification and pull.
  • Trivy findings need a policy. Severity, fix availability, exploitability, package scope, and exceptions should be reviewed and versioned rather than hidden by broad ignores.
  • A signature proves that an authorized identity signed an artifact. It does not prove the artifact is safe. Verify the expected workflow identity and require the relevant signed attestations at deployment.
  • An SBOM describes discovered components. It is not a vulnerability-free certificate and may have cataloging limits.

What an immutable container release means

Container deployments often begin with a mutable tag such as latest or production. A registry administrator or pipeline can later move that tag to different image content. If a cluster resolves the tag at different times, two replicas can run different images even though their manifests show the same reference.

A digest reference pins the actual image content. Kubernetes documents that tags can move while digests are fixed, and recommends specifying an image by digest when the same version must run consistently. A secure deployment should promote the digest that was built and verified, rather than rebuilding an image for each environment. Kubernetes container image references and digests

Immutability does not make code secure. It makes the artifact identity precise. Vulnerability scanning, SBOM generation, signing, attestations, and admission policy add claims about how the artifact was evaluated and who produced it. Each claim has a different purpose and should be checked independently.

Build one artifact and capture its digest

Use a unique tag for convenient lookup, such as the source commit SHA, but resolve and save the registry digest after pushing. All later steps should use registry.example/app@sha256:.... Do not scan a local image, rebuild, and then sign a separate image under the same tag. That creates a gap between the tested bits and deployed bits.

A practical release chain looks like this:

  1. Build from a reviewed source revision with dependencies and build tools controlled.
  2. Push the image and resolve the registry digest.
  3. Scan that digest and apply a versioned vulnerability policy.
  4. Generate an SBOM from that digest and attach it as an attestation.
  5. Sign the digest using the authorized CI identity.
  6. Verify the signature and required attestations, then deploy the digest.
  7. At admission or deployment, reject images that fail the same identity and policy checks.

For a multi-architecture image, the pushed digest may identify an image index, which points to platform-specific manifests. Ensure the scanner, signature verifier, and runtime policy understand whether they are evaluating the index digest or a platform-specific manifest. Record the expected subject digest in the release metadata.

Scan with an explicit vulnerability policy

Trivy can inspect container images for operating-system and language package vulnerabilities. It also offers scanners for misconfigurations, secrets, and licenses. The scan only sees what its catalogers can discover and what its vulnerability databases know at that time. A clean report is evidence of a particular scan, not proof that the image has no exploitable flaws. Trivy container image scanning

Example policy for a release gate:

IMAGE_REF="registry.example.com/team/app@sha256:REPLACE_WITH_PUSHED_DIGEST"

trivy image \
  --scanners vuln,secret,misconfig \
  --severity HIGH,CRITICAL \
  --ignore-unfixed \
  --exit-code 1 \
  "$IMAGE_REF"

This is an illustrative gate, not a universal severity rule. --ignore-unfixed excludes findings for which Trivy reports no fix, which may be unsuitable for a strict exposure model. A critical issue with no patch can still require removing the package, mitigating the reachable path, or blocking the release. Conversely, a reported high-severity finding may not be exploitable in your runtime configuration. Define an exception process with an owner, rationale, scope, expiration, and compensating control.

Pin the scanner version and capture its vulnerability database timestamp or digest in the build record. Vulnerability databases change over time, so the same image may produce a different report on a later day. Re-scan deployed digests on a schedule and when a relevant advisory arrives. Keep scan output as a CI artifact or signed attestation if you need to verify what was evaluated at release time.

Protect scanner output from accidental leakage. Secret scanning can identify credentials embedded in layers. Treat the report as sensitive and rotate any exposed secret. Deleting a file in a later image layer does not erase it from earlier layers; rebuild from a clean base and revoke the credential.

Generate an SBOM for the image you will deploy

A Software Bill of Materials (SBOM) is a structured inventory of software components discovered in an artifact. Syft can generate SPDX or CycloneDX output for container images and filesystems. Scan the pushed digest, not just the source repository, so the output reflects the final image layers and installed packages. Syft SBOM generation for container images

syft "$IMAGE_REF" -o cyclonedx-json=sbom.cdx.json
trivy sbom --scanners vuln,license sbom.cdx.json

An SBOM can help answer which images contain a newly vulnerable library, support license review, and make component inventory available to incident responders. It can miss components that were not detectable by its catalogers, and package metadata may not tell you whether a vulnerable code path is reachable. Keep the Syft version and configuration with the output. Do not use the SBOM alone as a release approval.

Attach the SBOM to the image as a signed attestation. Syft documents an attestation workflow that creates an in-toto statement and supports keyless signing through Sigstore or a locally managed key. Its attestation feature is identified as experimental in the current documentation, so pin and review the tool version and format before relying on it as a stable interface. Syft SBOM attestations

An attestation ties a predicate, such as an SBOM or build provenance, to a subject digest. A consumer verifies the signature, issuer, identity, subject, and predicate type. A signature over an image does not automatically certify an accompanying SBOM unless that SBOM is separately bound into a verified attestation.

Sign the image with a verifiable CI identity

Cosign supports signing container images by digest and verifying signatures against an expected key or certificate identity. In keyless signing, CI obtains an OIDC identity token and Sigstore issues a short-lived certificate. The verifier must check the identity and OIDC issuer expected for the authorized workflow, not merely accept any valid signature. Cosign container signing · Cosign verification and identity checks

A conceptual signing and verification sequence is:

# The CI job requires only the OIDC permission needed for keyless signing.
cosign sign --yes "$IMAGE_REF"

cosign verify "$IMAGE_REF" \
  --certificate-identity "$EXPECTED_WORKFLOW_IDENTITY" \
  --certificate-oidc-issuer "https://token.actions.githubusercontent.com"

Set the expected identity to the exact repository and workflow reference used by your signing job. Protect that workflow with code review and branch controls. Give the CI token only the registry and OIDC permissions it needs. Separate untrusted pull-request builds from jobs that can sign releases or access deployment credentials.

Sign the digest after the release artifact has been built and scanned. If a new image is built later, it has a different digest and needs a new scan, SBOM, and signature. Do not treat a mutable tag as the signed identity. The signature is only as trustworthy as the identity's protection and the verification policy that runs before deployment.

SBOM generation and signatures do not establish build provenance by themselves. If you need to prove which source revision and builder produced the image, create and verify a provenance attestation with defined build parameters and a trusted workflow identity. Keep provenance and SBOM predicates distinct because they answer different questions.

Enforce verification at the deployment boundary

A pipeline that signs an image but never verifies it at deployment has no enforcement point. For Kubernetes, an admission controller can validate signatures and attestations before accepting a workload. Sigstore Policy Controller supports policies that check image signatures and attestations, and can evaluate attestations against rules. Its documentation notes the component is actively under development, so verify release maturity, compatibility, and support expectations for your cluster. Sigstore Policy Controller

A deployment policy should state which registries and repositories are allowed, which signing identity and issuer are trusted, which attestations are required, which predicate types are accepted, and how exceptions are approved. It should reject unsigned images and mismatched subjects. Test the policy with valid, unsigned, incorrectly signed, expired, and wrong-repository artifacts before enforcing it in production.

Deploy the same digest that passed CI. If deployment tooling rewrites image names or tags, confirm the final admitted object still references the verified digest. Kubernetes can pull by digest, and the digest provides stable rollback identity. Keep the previous approved digest available according to your rollback and retention policy.

Admission controllers and deployment gates have different failure modes. Decide whether policy service unavailability blocks new workloads or allows them through. For critical workloads, define a fail-closed or controlled break-glass policy, alert on every exception, and ensure already-running pods are assessed when trust policy changes.

Make the release evidence reviewable

Store a release record containing the source commit, build workflow identity, image digest, scanner version and database metadata, scan result, SBOM digest, attestation references, signature identity, and deployment environment. Make the record searchable by image digest. An SBOM attached to a tag can become ambiguous if the tag moves; a subject digest avoids that confusion.

Keep an exception register for accepted findings. Each entry should include the CVE or policy finding, affected package, image digest or bounded image family, business owner, security reviewer, expiry date, and remediation plan. Expired exceptions should fail the next release gate or trigger an explicit review.

Rebuild from a trusted base when a critical component changes. Updating a base-image tag does not update an image already built from it. Rebuild, rescan, regenerate the SBOM, sign the new digest, and deploy it through the same policy path. Track deployed image digests and compare them to the approved release inventory.

Measure time from advisory publication to affected-image identification, patched build, and production rollout. Track unverified deployments, exception age, scan failures, and admission denials. These measures show whether the control is operating, not merely whether a YAML workflow exists.

Common mistakes that weaken the pipeline

Scanning one image and deploying another

A scan against app:commit is meaningless if the tag is overwritten before deployment. Resolve the digest immediately after pushing and carry that immutable reference through scanning, signing, attestation, manifest rendering, and rollout.

Using a signature as a safety verdict

A signature establishes that a trusted identity signed an artifact with a particular digest. It does not say that the artifact passed a vulnerability policy or came from the intended source unless the verifier checks those claims.

Ignoring findings forever

A broad ignore rule without an owner or expiration can hide a real risk. Keep exceptions narrow and reviewable. Include the reason, affected image scope, expiration, and mitigation.

Publishing an SBOM without verifying its subject

Verify that the attestation subject matches the image digest being deployed. A correct SBOM for an older digest does not describe a rebuilt image. Require the expected predicate type and identity as part of admission policy.

Overprivileging the signing workflow

A compromised build step can misuse any token available to the job. Use narrow permissions, isolate untrusted workflows, pin or lock action dependencies, and audit the code that handles registry and deployment credentials. GitHub recommends workflow dependency lockfiles where available or pinning third-party actions to full commit SHAs. GitHub Actions secure use reference

Frequently asked questions

Does signing a container image prove it is safe?

No. A signature proves that an identity signed specific image content, subject to the verification policy. It does not establish that the image has no vulnerabilities. Verify the expected signer and separately evaluate required scan and provenance attestations.

Should production Kubernetes manifests use image tags or digests?

Use a digest when you need the manifest to identify fixed image content. A tag can move to a different image, while a digest pins the exact content. A human-readable tag can be retained alongside the digest for traceability.

Does an SBOM prove an image contains no vulnerable components?

No. An SBOM lists components a tool discovered. Vulnerability scanners compare those components with changing advisory databases, and cataloging or reachability can be incomplete. Use the SBOM for inventory and run a separately defined vulnerability policy.

Should every high-severity Trivy finding block a release?

Set the gate from your risk model. Consider severity, fix availability, exploitability, exposure, and deployment context. If you create an exception, record an owner, reason, scope, expiry, and mitigation rather than suppressing findings globally.

Promote the artifact you actually verified

An immutable pipeline follows one digest from build to runtime. The scanner evaluates that artifact, the SBOM describes that artifact, the signature authenticates that artifact, and deployment policy admits that artifact only when the expected identity and evidence are present. This creates a reviewable chain without claiming that any single tool eliminates supply chain risk.

If you are adding image signing, vulnerability gates, or admission-time verification, talk with our DevSecOps team about defining the threat model, exception process, and rollout policy for your deployment platform.

Dumb Potato Editorial

Putting this into practice?

Share the problem you’re solving and the tradeoffs you’re weighing with our engineering team.

See how we help with cloud and devops

Discuss your project