Container security

Kubernetes Admission Control for Image Provenance

Sign container images in CI, attest how they were built, and refuse unsigned or unpinned images at admission with Kyverno and ValidatingAdmissionPolicy.

TrustIvan ·

A pipeline can scan, sign and approve an image, and none of it matters if someone can kubectl apply a pod that runs a different one. Kubernetes admission control for image provenance closes that gap: the API server asks a policy, before the pod is created, whether each image was built where you expect and signed by the identity you trust. This guide covers the pieces that make that check meaningful, from digests and keyless signing to SLSA provenance, and shows policies for Kyverno and the built-in ValidatingAdmissionPolicy, along with the failure modes to decide in advance.

What does image provenance mean?

Provenance is the verifiable answer to "where did this image come from?". In practice it has three layers, and each depends on the one before:

LayerQuestion it answersMechanism
DigestIs this the exact image?image@sha256:... references
SignatureWho vouched for this exact image?Sigstore cosign, keyless or key-based
AttestationHow, where and from what source was it built?In-toto statements, in a format such as SLSA

A tag is not provenance. payments-api:1.42.0 can be pushed again with different contents, and a signature checked against a tag tells you about whatever the tag pointed to at the time. Every check below works on digests.

Why enforce it at admission?

Because admission is the last point where every path into the cluster converges. A CI check only covers images that went through CI. A registry policy only covers images in that registry. A validating admission webhook sees every pod creation request, whether it came from a deployment controller, a Helm release, a CronJob or a person with a kubeconfig, and can refuse it before anything is scheduled.

It is not the only control you need. Admission checks the image reference at creation time; it does not stop a running container from downloading and executing something else. Provenance tells you the image is the one you built, not that what you built is safe.

How do you sign images in CI?

Sign by digest, in the workflow that built the image, with keyless signing so there is no private key to protect. On GitHub Actions the workflow's OIDC token is the identity, and Sigstore's Fulcio certificate authority issues a short-lived certificate naming the workflow:

permissions:
  contents: read
  packages: write          # push the image
  id-token: write          # request the OIDC token for signing
  attestations: write      # store the provenance attestation
  artifact-metadata: write
 
steps:
  - id: build
    uses: docker/build-push-action@v7
    with:
      push: true
      tags: ghcr.io/example/payments-api:${{ github.sha }}
 
  - uses: sigstore/cosign-installer@v4
  - run: cosign sign --yes "ghcr.io/example/payments-api@${DIGEST}"
    env:
      DIGEST: ${{ steps.build.outputs.digest }}
 
  - uses: actions/attest@v4
    with:
      subject-name: ghcr.io/example/payments-api
      subject-digest: ${{ steps.build.outputs.digest }}
      push-to-registry: true

actions/attest produces a provenance attestation in SLSA's format by default, signed through Sigstore and pushed next to the image. Artifact attestations in private repositories need a GitHub Enterprise Cloud plan and use GitHub's own Sigstore instance rather than the public one, which matters when you configure the verifier.

Check the result before writing any cluster policy:

cosign verify ghcr.io/example/payments-api@sha256:4f2b... \
  --certificate-identity-regexp '^https://github\.com/example/payments-api/\.github/workflows/release\.yml@refs/(heads/main|tags/v.+)$' \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com
 
gh attestation verify oci://ghcr.io/example/payments-api@sha256:4f2b... \
  --repo example/payments-api

The identity is the important part. Anchor the expression with ^ and $, name one workflow file, and name the refs that may release. An identity of "any workflow in the organization" accepts an image signed by a workflow that anyone in the organization can write on a branch.

How do you verify signatures with Kyverno?

Kyverno's ImageValidatingPolicy (API policies.kyverno.io/v1) verifies signatures and attestations at admission. This policy requires every image from your registry to carry a keyless signature from the release workflow and a SLSA-format provenance attestation from the same identity:

apiVersion: policies.kyverno.io/v1
kind: ImageValidatingPolicy
metadata:
  name: require-signed-payments-images
spec:
  validationActions: [Audit]        # switch to [Deny] after a clean audit period
  failurePolicy: Fail
  webhookConfiguration:
    timeoutSeconds: 15
  matchConstraints:
    resourceRules:
      - apiGroups: [""]
        apiVersions: ["v1"]
        operations: ["CREATE", "UPDATE"]
        resources: ["pods"]
  matchImageReferences:
    - glob: "ghcr.io/example/*"
  validationConfigurations:
    mutateDigest: true                # rewrite tags to the digest that was verified
    verifyDigest: true
    required: true
  attestors:
    - name: release
      cosign:
        keyless:
          identities:
            - subjectRegExp: '^https://github\.com/example/payments-api/\.github/workflows/release\.yml@refs/(heads/main|tags/v.+)$'
              issuer: "https://token.actions.githubusercontent.com"
        ctlog:
          url: "https://rekor.sigstore.dev"
  attestations:
    - name: provenance
      intoto:
        type: https://slsa.dev/provenance/v1
  validations:
    - expression: >-
        images.containers.map(image, verifyImageSignatures(image, [attestors.release])).all(e, e > 0)
      message: "image is not signed by the payments-api release workflow"
    - expression: >-
        images.containers.map(image, verifyAttestationSignatures(image, attestations.provenance, [attestors.release])).all(e, e > 0)
      message: "image has no SLSA provenance from the payments-api release workflow"

mutateDigest matters more than it looks. Without it, a pod spec that names a tag is verified against the digest the tag resolved to at admission, and the kubelet may later pull a different one. With it, the pod runs exactly the digest that was verified.

For images signed through GitHub's private Sigstore instance, the public Rekor log will not have the entry. Configure the attestor's trusted root for that instance instead, as Kyverno's documentation describes.

Sigstore's own policy-controller does the same job with a ClusterImagePolicy resource, if you would rather not run a general-purpose policy engine.

What can ValidatingAdmissionPolicy do without a webhook?

Kubernetes' built-in ValidatingAdmissionPolicy runs CEL expressions in the API server itself, with no webhook to keep available. CEL cannot fetch a signature from a registry, so it cannot verify provenance, but it can enforce the preconditions that make provenance checks meaningful:

apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
  name: images-pinned-from-our-registry
spec:
  failurePolicy: Fail
  matchConstraints:
    resourceRules:
      - apiGroups: [""]
        apiVersions: ["v1"]
        operations: ["CREATE", "UPDATE"]
        resources: ["pods"]
  variables:
    - name: images
      expression: >-
        object.spec.containers.map(c, c.image) +
        (has(object.spec.initContainers) ? object.spec.initContainers.map(c, c.image) : [])
  validations:
    - expression: >-
        variables.images.all(i, i.startsWith('ghcr.io/example/') && i.contains('@sha256:'))
      message: "images must come from ghcr.io/example and be pinned by digest"
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicyBinding
metadata:
  name: images-pinned-from-our-registry
spec:
  policyName: images-pinned-from-our-registry
  validationActions: [Deny]
  matchResources:
    namespaceSelector:
      matchExpressions:
        - key: kubernetes.io/metadata.name
          operator: NotIn
          values: ["kube-system"]

Run both: the built-in policy as a cheap, always-available floor, and the signature check for the guarantee.

Which failure modes should you decide in advance?

What happens when the verifier is down? failurePolicy: Fail refuses pods while the webhook cannot answer, including the pods that would fix the webhook. Ignore admits them unverified. Neither is safe. Choose per cluster, and if you choose Fail, exclude the namespaces the verifier and your control plane add-ons run in, and keep a documented break-glass procedure.

What about images you do not build? Base system components, operators and vendor images will not carry your signature. Give them their own attestor (many vendors sign with Sigstore) or an explicit, reviewed allowlist by digest, not an exemption by namespace that anyone with create rights in that namespace inherits.

Which pod fields carry images? Containers, init containers and ephemeral containers. Kyverno extracts images from pods and pod templates for you, but confirm which of those lists images.containers covers in the version you run, with a test pod that uses an unsigned init container. A hand-written CEL policy has to name each list itself, as the one above does for init containers.

How will you roll it out? Start every policy in audit mode, read the results for a few weeks, fix the images that fail, then enforce. A policy that blocks deployments on its first day is a policy that gets deleted on its second.

How does TrustIvan fit into admission control?

TrustIvan checks signatures when it scans an image, not at admission. During a container scan it looks for the cosign signatures and attestations published beside the image, checks each against the public keys your policies trust and against the image's digest, and records the result on the scan. A policy rule with signed_by then fails the release verdict unless one of those keys signed the image, and a registry it cannot read fails the rule rather than passing it. The limits matter for this article: only key-based signatures (cosign sign --key) are checked. Keyless signatures like the ones in the workflow above are reported as not verified, there is no Rekor transparency-log check, signatures stored in cosign 3's default OCI-referrer bundle format are not found, attestations are reported but no rule requires one, and nothing re-checks an image after the scan. For keyless provenance at admission, keep Kyverno or the Sigstore policy-controller.

TrustIvan's admission endpoint does not consult the signature result. It answers a different question: is this workload safe to run? It reads the pod the request would create and judges it against the workload and container checks of the same posture catalog a cluster collection uses, the cluster's trusted-registry list, and the open findings of each image the pod would run. A Helm chart installs the webhook and a small relay inside the cluster.

It is off by default per cluster. In warn mode, the default, problems appear in the developer's kubectl output; in deny, a check of medium severity or above, or an image with an open critical or high finding, is refused, while low-severity checks such as a mutable tag or a missing limit, and a never-scanned image, are shown but never block. A separate failure_mode setting decides what happens when TrustIvan cannot answer: a cluster connected since 2026-10-29 fails closed, and the chart's webhook defaults to failurePolicy: Fail, with kube-system and the chart's own namespace exempt, as the section above advises. The cost is the one described there: a TrustIvan outage stops deployments in every other namespace until it answers, so the opt-out (open and Ignore) is documented for clusters where availability comes first. The chart has been tested on a local k3d cluster with TrustIvan unreachable; a review through the relay to a live TrustIvan and back has not been run yet, and the documentation says so.

TrustIvan's own released images are signed keylessly from its release workflow, and the supply chain page gives the cosign verify command to check them before you admit them. For the findings an admission decision reads, see container scanning and policy and verdicts, and reading an SBOM for the inventory behind them.