Skip to content

Kyverno: image signed, but with the wrong key – pod rejected

Securitytested on kind, Kyverno ImageValidatingPolicy, cosign

"Signed" is not enough. The policy checks who signed – and whether a signed SBOM is attached to the image. Two images, two different rejections.

Symptom

kubectl -n shop run $r -l app=$r --image=kind-registry:5000/shop/$r:1.31 \
    --dry-run=server -o name 2>&1 | sed 's/.*denied the request: //'
Policy verify-shop-images failed: Image ist nicht mit dem Lab-Key signiert.
Policy verify-shop-images failed: Keine signierte SPDX-SBOM am Image.

Two images in the same registry: evil is signed with a foreign key, nosbom with the right key but without attestation. The German policy messages mean "image is not signed with the lab key" and "no signed SPDX SBOM on the image".

Diagnosis

The message to the client is the policy's message. The admission controller log shows the technical reason.

COSIGN_PASSWORD=x cosign sign --registry-cacert certs/registry.crt --key fremd.key \
  --signing-config offline.json -y localhost:5001/shop/evil@$DIGEST 2>/dev/null

Causes

Lab keyWrong key

evil was signed with fremd.key ("foreign key"). The policy only knows the public lab key and rejects any other signature.

SBOMAttestation missing

nosbom carries the right signature but no signed SPDX SBOM. The policy requires both.

Fix

Sign the image with the lab key and attach the SBOM as an attestation – then deploy by digest.
cosign sign --registry-cacert certs/registry.crt --key cosign.key \
  --signing-config offline.json -y localhost:5001/shop/nosbom@$DIGEST 2>/dev/null

Don't: Creating a PolicyException for the image without finding out who signed it – this exact case is the attack the policy is meant to stop.

▶
Break it yourself and find it – free
Kyverno & NetworkPolicies hands-on, Day 10: registry with TLS, cosign offline, SBOM attestation, ImageValidatingPolicy and failure cases.
Go to day 10 →

FAQ

Why is the message in German?

The message is written freely in the policy. Developers immediately see what is missing instead of a technical cosign message.

Why deploy by digest?

A tag can be pointed at another image. The digest pins exactly the verified image.

Related error patterns

More