Investigation & Containment

Investigation

Four questions, in this order: who signed this image, what is inside it, does the cluster’s verifier see the same evidence, and which digest actually runs. Every kubectl names the cluster with --context (Chapter 01).

  1. Who signed this image? A keyless signature carries a certificate whose subject is the workflow that signed: repository, workflow file, branch. It says who signed this digest - how it was built is the provenance’s claim, which GitHub attaches too. Ask for exactly the identity you expect:

    IMAGE="ghcr.io/safeops-course/backend:$(yq '.images[0].newTag' flux/apps/backend/develop/kustomization.yaml)"
    cosign verify "$IMAGE" \
      --certificate-oidc-issuer https://token.actions.githubusercontent.com \
      --certificate-identity-regexp '^https://github\.com/safeops-course/backend/\.github/workflows/build\.yml@refs/heads/(main|develop)$' >/dev/null && echo signed-by-backend-ci
    

    Ask for the wrong one - the frontend’s workflow - and the error names the real signer: expected SAN value to match regex “…/frontend/…”, got “https://github.com/safeops-course/backend/.github/workflows/build.yml@refs/heads/main". An image with no signature at all answers no signatures found.

  2. What is inside it? The SBOM is an attestation: a document signed by the same workflow, about the same digest - one per platform the image is published for, each naming its architecture. Read the one for the architecture your cluster runs:

    ARCH="$(kubectl --context kind-sre-control-plane get nodes -o jsonpath='{.items[0].status.nodeInfo.architecture}')"
    cosign verify-attestation --type spdxjson "$IMAGE" \
      --certificate-oidc-issuer https://token.actions.githubusercontent.com \
      --certificate-identity-regexp '^https://github\.com/safeops-course/backend/\.github/workflows/build\.yml@refs/heads/(main|develop)$' \
      | jq -r --arg a "$ARCH" '.payload | @base64d | fromjson
          | select(any(.predicate.packages[].externalRefs[]?.referenceLocator; test("^pkg:oci/.*arch=" + $a)))
          | .predicate.packages[] | "\(.name) \(.versionInfo)"' | sort | head
    

    Every component the scanner found, with its version - the Go standard library the binary was built with, the Alpine packages of the base image. When a new CVE is published, this is how you know which running images contain the affected version without pulling a single one.

  3. Does the cluster’s verifier see the same evidence? cosign passing is not the question; the admission policy passing is. The policy’s own test runs Kyverno - the engine the cluster runs - against real images, offline from the cluster:

    tests/kyverno-supply-chain.test.sh
    

    It ends with Test Summary: … tests passed and 0 tests failed, and its exit status is the verdict - not piped through tail, so a failure cannot hide behind a successful last command.

    In the story, cosign found the backend’s signature and Kyverno’s older policy type did not; the frontend’s SBOM was there, but next to evidence in a newer storage format the verifier read only the newer one. Neither shows up until someone runs the verifier the cluster uses.

  4. Which digest runs? A tag can be moved in the registry; a digest cannot. The policy verifies the digest the tag resolves to at admission and writes it into the pod; the kubelet records the digest it actually pulled:

    kubectl --context kind-sre-control-plane -n develop get pods -l app=backend \
      -o jsonpath='{range .items[*]}{.spec.containers[0].image}{"  "}{.status.containerStatuses[0].imageID}{"\n"}{end}'
    

    The tag from Git with the verified digest appended (<tag>@sha256:…), and the imageID - the digest that runs. They name the same image: the kubelet pulled the digest admission verified, not whatever the tag pointed to a moment later (see Workflow). Compare them with the registry’s digest for the tag (docker buildx imagetools inspect) - and first know which digest each one is: the registry reports the multi-platform index; a container runtime may record the index, or the manifest of its own platform (also listed by imagetools inspect). On kind, containerd records the index. Different digests of the same image are not a moved tag; a registry digest that differs from the pod’s means the tag moved after the pod was admitted.

The root cause of the story is not keyless signing. It is evidence nobody verified the way the cluster would: a check that failed every image for an unrelated reason, so it never looked at a signature; and a pipeline change that altered the evidence without a test against the cluster’s verifier.

Containment

  1. Make the check able to pass. Before anything is enforced, every signed image must verify - in the report or in the policy’s test. A check that fails everything is fixed first.
  2. Fix the evidence at its source. An image that fails verification is rebuilt by its pipeline - signed and attested in the format the verifier reads - and promoted the normal way (Chapter 10). Never signed by hand, never exempted.
  3. Enforce where the evidence is clean - here, the application namespaces, once their running images verify; elsewhere the policy reports (Chapter 16’s rollout).
  4. Test the pipeline against the verifier. A change to signing - a tool version, a signing step, a new attestation - passes the policy’s test with a real image before it merges.

Every image from the platform’s own registry that runs in the application namespaces was signed by its own repository’s CI - and the proof is checked by the same verifier, every time something in the chain changes. Images from other registries are Chapter 16’s business.


Pause and Predict: The frontend image in production is signed by the right workflow, and its SBOM exists in the registry. The admission policy still refuses it. Name two places to look first.