Supply-chain security comes down to one tight loop: scan what you build, sign what you ship, and block anything unsigned or unscanned at admission. The lab wires up all three stations, picking up right where your 2.4 scan gate left off.
make core cicd secOrientation
Five distinct controls stand between a git push and a running pod in this lab, and each catches a failure mode the others miss. Being able to name all five, and what only each one stops, is the heart of this competency.
git push │ ├─ 2.4 pipeline scan gate catches known-bad before publish ├─ 5.6 signature catches tampering and untrusted builders ├─ 5.6 admission verification catches images that bypassed the pipeline entirely ├─ 5.3 Pod Security Standards catches dangerous runtime settings, regardless of provenance └─ 5.4 continuous rescanning catches CVEs published after you shipped ▼ running pod
The chain, station by station
Scanning belongs at two points, and the difference is the insight
In the pipeline (a Trivy step with --exit-code 1 --severity HIGH,CRITICAL), scanning acts as a gate: it stops a vulnerable image before it ever reaches the registry. In the cluster (Trivy Operator, section 5.4), scanning acts as surveillance: it catches brand-new CVEs disclosed after you shipped. Teams that only scan in CI are completely blind to every vulnerability published since their last deploy. Calling out both roles cleanly is a high-value exam answer.
Gate ergonomics matter just as much, because a noisy gate that breaks every build will get turned off. Filter to HIGH,CRITICAL and consider --ignore-unfixed (nobody can patch a CVE that has no fix yet). Track exceptions in an auditable ignore file with expiry dates instead of permanently lowering the bar, and make findings fail the step rather than warn: a warning in CI logs is a warning nobody reads.
Signing
cosign signs an image's digest and pushes that signature into the registry beside the image (classically as a sha256-<digest>.sig tag, or in newer versions as an OCI bundle). Signing the digest rather than the tag is what makes the trust real: tags can be moved anytime, whereas digests are content-addressed. Verifying :latest resolves it to a digest first, so someone who hijacks a tag still can't forge the signature.
Keyless mode is where modern supply chains are heading: an OIDC workload identity (like a CI job token) requests a short-lived cert from Fulcio, and both the signature and cert get written into Rekor, a public transparency log. Verifiers check the signer's identity and the log entry instead of juggling static keys you have to store and rotate. Know those three nouns cold. Meanwhile, key-pair mode works completely offline and is the best way to practice the mechanics hands-on.
Verification at admission is what makes signatures matter
Without enforcement at the door, signing is pure theater. A Kyverno image-verification policy holds your public key (or expected keyless identity), intercepts pod creation, resolves each image reference, verifies its signature, and rejects anything untrusted. Even better, it can mutate the pod's image reference into its pinned digest so the kubelet pulls the exact bytes you verified instead of whatever that mutable tag points to five minutes later. Gatekeeper handles this through external data providers (like Ratify), whereas Kyverno builds it right in.
SLSA defines levels of build provenance rigor, scaling from "we have a repeatable build" up to isolated, hermetic, attested builds. For the exam, keep the three supply-chain documents razor-sharp: provenance attests to how an artifact was built, SBOMs list what's inside it, and signatures prove who vouches for it. Three documents, one trust story; because attestations are themselves signed statements, cosign handles all three.
Stations, tools, and the flags that gate
| Station | Threat | Control | Tool words |
|---|---|---|---|
| Source | Malicious or accidental commit, leaked credential | Branch protection, signed commits, secret scanning, dependency review | gitleaks or trivy's secret scanner, Dependabot/Renovate, OpenSSF Scorecard |
| Build | Compromised or unpinned dependency, tampered build | Base images pinned by digest, hermetic reproducible builds, provenance | SLSA levels, Tekton Chains, distroless or Chainguard bases |
| Package | Known CVEs shipped, unsigned artifact | Scan gate, SBOM, signature, attestations pushed to the registry | trivy, syft/grype, cosign sign/attest |
| Deploy | Image bypassed CI, tag moved after check | Admission verification, digest pinning, registry allow-list | Kyverno ImageValidatingPolicy, Sigstore policy-controller, Gatekeeper + Ratify |
| Run | Post-deploy CVE, runtime compromise | Continuous rescanning, runtime syscall detection, PSS | Trivy Operator, Falco, Pod Security admission |
cosign flags you'll actually type
- Key-pair mode. Mint keys with
cosign generate-key-pair(or use--kms awskms://...,gcpkms://,azurekms://,hashivault://, ork8s://ns/secretto keep private keys off disk). Sign withcosign sign --key cosign.key <image@sha256:...>and check withcosign verify --key cosign.pub <image>. A passing run printsVerified OKalong with the claims lines (The cosign claims were validated,The signatures were verified against the specified public key) and the payload JSON; tags resolve to a digest first and verify againstdocker-manifest-digest. - Keyless mode. Run
cosign sign <image>with an OIDC login or CI identity token (--identity-token, using GitHub Actions'id-token: writepermission) to grab a short-lived Fulcio cert and log to Rekor. Verification always requires pinning who signed it: pass--certificate-identity <subject> --certificate-oidc-issuer <issuer URL>(or the-regexpvariants for a workflow URL likehttps://github.com/org/repo/.github/workflows/build.yaml@refs/heads/mainwith issuerhttps://token.actions.githubusercontent.com). Leave off the identity flags and cosign refuses to run, which is exactly how it prevents "signed by any random stranger" mistakes. - Offline and private setups. Pass
--insecure-ignore-tlogto skip Rekor checks when you signed with--tlog-upload=false,--offlinewhen verifying a local bundle,--certificate-chainor--ca-rootsfor a private Fulcio, and--rekor-urlfor a private Rekor. Add custom annotations at sign time via-a key=valueand require them with the same flag at verify time. - Attestations. Attach predicates via
cosign attest --predicate file --type slsaprovenance1|spdxjson|cyclonedx|vuln|custom --key ... <image>, and verify withcosign verify-attestation --type <type> --key ... <image>(add--policy policy.cueor Rego to enforce rules on predicate content, like max severity or builder ID). Inspect everything attached to an image withcosign tree <image>, and fetch payloads withcosign download attestation. - Storage formats. Signatures sit next to the image in the registry either in the legacy tag format (
sha256-<digest>.sigand.att) or as an OCI 1.1 referrer bundle (cosign v3's default). A verifier expecting one format reportsno signatures foundon an image signed in the other. The lab's--new-bundle-format=falseflag is that exact format mismatch in action.
trivy gate flags
--severity HIGH,CRITICALfilters findings;--exit-code 1actually fails the build (Trivy exits 0 by default even when it finds CVEs!);--ignore-unfixedexpands to--ignore-status affected,will_not_fix,fix_deferred,end_of_life;--scanners vuln,secret,misconfig,licenseselects scanners (secret scanning runs by default on images and slows down big scans); and--pkg-types os,librarynarrows package types..trivyignorelists one CVE ID per line with optional expiry dates likeexp:2026-12-31;.trivyignore.yaml(passed via--ignorefile) organizes vulnerabilities, misconfigurations, secrets, and licenses with statements;--ignore-policy policy.regofilters with OPA (packagetrivy, ruleignore); and--vexapplies VEX documents. Expiry dates are what keep ignore lists auditable instead of permanent blind spots.- Pipeline outputs:
--format json|sarif|cyclonedx|spdx-json|template --output file. Remember the subcommands too:trivy image --format cyclonedxemits an SBOM,trivy sbomrescans an SBOM later,trivy k8sscans a live cluster, andtrivy config/trivy fsscan manifests and repos.
Hygiene that admission cannot give you
Pin base images by digest (FROM alpine@sha256:...) and let Dependabot or Renovate bump them; use distroless or Chainguard bases so scanners find fewer CVEs and attackers find no shell; use multi-stage builds so compilers never ship; lock down registries with immutable tags, pull-through caches, and allow-lists enforced by policy on image prefixes; and commit verified dependency lockfiles. On the repository side, OpenSSF Scorecard scores these habits under named checks: Pinned-Dependencies, Token-Permissions, Branch-Protection, Signed-Releases, SBOM, Dangerous-Workflow, Vulnerabilities, and Code-Review. Whenever an exam prompt asks for pipeline controls beyond image scanning, reach straight for this checklist.
Provenance: SLSA, Tekton Chains, and the verification policies
SLSA v1.0 Build track
| Level | Requirement | Stops |
|---|---|---|
| Build L0 | Nothing | Nothing |
| Build L1 | Provenance exists: the build platform emits an attestation describing how the artifact was built (source, builder, parameters) | Accidental mistakes and doc drift, not attackers |
| Build L2 | A hosted build platform generates and signs the provenance using a key the platform holds (not the user) | Tampering after the build (forged or edited provenance) |
| Build L3 | Hardened build platform: runs are isolated from each other and user meddling, and signing keys are unreachable from build steps so a run can't forge its own provenance | Tampering during the build itself |
SLSA v1.0 defines the Build track, with later versions adding Source and build-environment tracks on the same model. Provenance takes the form of an in-toto Statement with predicateType: https://slsa.dev/provenance/v1 carrying buildDefinition (buildType, externalParameters, resolvedDependencies) and runDetails (builder.id, metadata). Verifying provenance means checking three things: the signature is valid, builder.id matches a builder you trust, and the source repo in externalParameters matches what you expect.
Tekton Chains
Tekton Chains watches finished TaskRuns and PipelineRuns, then formats, signs, and publishes provenance automatically. All settings live in the chains-config ConfigMap inside tekton-chains:
artifacts.taskrun.format/artifacts.pipelinerun.format: choosein-toto(aliasslsa/v1, emitting SLSA v0.2) orslsa/v2alpha3/slsa/v2alpha4(SLSA v1.0;v2alpha4also reads type-hinted results from StepActions). New deployments should useslsa/v2alpha3or newer.artifacts.*.storage: comma-separated targets fromtekton(stored as annotations on the run),oci(attestations beside the image),gcs,docdb,grafeas, orarchivista. Settingartifacts.oci.storage: ociis what letscosign verify-attestationfind anything on the image.artifacts.*.signer:x509(acosign.keyinside thesigning-secretsSecret, or keyless viasigners.x509.fulcio.enabled: true),kms(signers.kms.kmsref), ornone(unsigned provenance).transparency.enabled: trueuploads to Rekor (transparency.url), whilemanualuploads only runs annotated withchains.tekton.dev/transparency-upload: "true".- Type hinting is how Chains recognizes what your Task built: emit results named
IMAGE_URLandIMAGE_DIGEST(or*_IMAGE_URL/*_IMAGE_DIGESTpairs, or an*ARTIFACT_OUTPUTSobject withurianddigest). Here's the gotcha: if a Task pushes an image without emitting those results, Chains writes zero OCI attestations yet still stampschains.tekton.dev/signed: "true"because it signed the run payload itself. Check that annotation first when "Chains didn't sign my image", then check controller logs for missing results or registry auth errors. Turn onartifacts.pipelinerun.enable-deep-inspection: "true"so PipelineRun-level provenance pulls in task-level results too.
Verification at admission, three ways
| Engine | Object | The fields |
|---|---|---|
| Kyverno | ImageValidatingPolicy (policies.kyverno.io/v1) | matchImageReferences[].glob|expression; attestors[].cosign.key.data or .keyless.identities[].subject/issuer (plus subjectRegExp/issuerRegExp), .ctlog for Rekor, or .certificate; attestations[] via referrer.type or intoto.type; validations[].expression using images.containers.map(image, verifyImageSignatures(image, [attestors.x])).all(e, e > 0), verifyAttestationSignatures(image, attestations.sbom, [...]), and extractPayload(image, attestations.sbom).bomFormat == 'CycloneDX'; mutateDigest: true rewrites tags to digests, verifyDigest rejects tags, required: true fails uncovered images; credentials.secrets is required for private registries because IVP doesn't read the pod's imagePullSecrets |
| Sigstore policy-controller | ClusterImagePolicy (policy.sigstore.dev/v1beta1) | images[].glob; authorities[] with key.data, keyless.identities[].issuer/subject (+ url for Fulcio), or static.action: pass|fail; attestations[] with predicateType and a CUE/Rego policy; mode: enforce|warn. Only checks namespaces labeled policy.sigstore.dev/include: "true"; every matching policy must pass (AND) while any one authority inside a policy suffices (OR); also resolves tags to digests |
| Gatekeeper | Provider (external data) + a ConstraintTemplate calling external_data | Ratify (or cosign-gatekeeper-provider) runs in-cluster, checks signatures and attestations using its own Verifier and Store config, and returns verdicts per image so the Constraint can deny on failure. Same security guarantee, one extra moving part |
Digest pinning closes the final TOCTOU gap: verify the digest, then run that exact digest. Kyverno's mutateDigest, policy-controller's tag resolution, and Argo CD Image Updater committing digests to git all solve this. If a Deployment still says :v1 after admission, whoever can overwrite that tag still controls what runs.
"Sign this image and block unsigned ones in the cluster" means cosign plus one of the three policies above, matching the in-cluster registry name pods use (plus the engine's insecure-registry flag if the lab registry is HTTP). "Generate provenance for this pipeline" means configuring Chains plus emitting IMAGE_URL/IMAGE_DIGEST results from the Task. "Fail the build on CRITICAL CVEs without breaking on unfixable ones" means --severity CRITICAL --exit-code 1 --ignore-unfixed paired with a dated ignore file. Graders verify the artifact itself (a valid signature, a downloadable attestation, a blocked pod), so always prove the end state.
Exercises
From section 2.4, you already have build-and-scan and a built image in the registry. Trigger it again (tkn pipeline start build-and-scan --last) and read the full scan log carefully: tkn pipelinerun logs --last -t scan.
kubectl get taskrun <name> -o jsonpath='{.status.results}').Your pipeline pushed demo:v1 using its in-cluster address (kind-registry:5000), while from the host the exact same registry answers at localhost:5001. The digest is identical on both sides because a digest identifies content, not hostname:
cd $(mktemp -d) && cosign generate-key-pair # passphrase: pick one, remember it
DIGEST=$(skopeo inspect --tls-verify=false docker://localhost:5001/demo:v1 | jq -r .Digest)
cosign sign --key cosign.key --allow-http-registry -y localhost:5001/demo@$DIGEST
cosign verify --key cosign.pub --allow-http-registry localhost:5001/demo@$DIGESToutputcaptured 2026-08-26
$ cd $(mktemp -d) && cosign generate-key-pair # passphrase: pick one, remember it
Private key written to cosign.key
Public key written to cosign.pub
$ DIGEST=$(skopeo inspect --tls-verify=false docker://localhost:5001/demo:v1 | jq -r .Digest)
$ cosign sign --key cosign.key --allow-http-registry -y localhost:5001/demo@$DIGEST
Signing artifact...
Pushing signature to: localhost:5001/demo
$ cosign verify --key cosign.pub --allow-http-registry localhost:5001/demo@$DIGEST
Verification for localhost:5001/demo@sha256:33213719f2b030a8a1260d1c5358f55524f8f690a790e35b14b00c1f50b46ddf --
The following checks were performed on each of these signatures:
- The cosign claims were validated
- Existence of the claims in the transparency log was verified offline
- The signatures were verified against the specified public key
[{"critical":{"identity":{"docker-reference":"localhost:5001/demo@sha256:33213719f2b030a8a1260d1c5358f55524f8f690a790e35b14b00c1f50b46ddf"},"image":{"docker-manifest-digest":"sha256:33213719f2b030a8a1260d1c5358f55524f8f690a790e35b14b00c1f50b46ddf"},"type":"https://sigstore.dev/cosign/sign/v1"},"optional":{}}]Next, try verifying by tag instead of digest and watch cosign resolve it to the digest anyway. Then try verifying an unsigned image (localhost:5001/validate:v1 is there if you ran make validate) and read the failure message.
Kyverno's current kind for image verification is ImageValidatingPolicy (run kubectl explain imagevalidatingpolicies.spec; this API has evolved, and checking live is part of the habit). Three practical details make or break the setup:
- Kyverno pulls signatures itself from inside the cluster, so both your pod images and policy globs must use the in-cluster registry hostname (
kind-registry:5000, wired into CoreDNS and containerd), neverlocalhost:5001(inside the Kyverno pod,localhostis Kyverno itself). - Our lab registry speaks plain HTTP, and allowing that is an engine setting rather than a policy field: the lab installs Kyverno with
features.registryClient.allowInsecure=true. Without it, every check fails withserver gave HTTP response to HTTPS clientbefore it ever reads a signature. - cosign v3 defaults to its new OCI bundle format, while Kyverno's verifier currently looks for the legacy
.sigtag. Sign a second time in legacy format for Kyverno:cosign sign --key cosign.key --allow-http-registry -y --use-signing-config=false --new-bundle-format=false --tlog-upload=false localhost:5001/demo@$DIGEST. Signer/verifier version skew isn't a lab quirk; it's real-world supply-chain life, and recognizing "no signatures found" as a format mismatch is a genuinely transferable skill.
Write the policy: match pods, set matchImageReferences glob to kind-registry:5000/demo*, configure one attestor with cosign.key.data holding your cosign.pub (plus cosign.ctlog.insecureIgnoreTlog: true since the legacy signature skipped Rekor), and use Kyverno's validation expression: images.containers.map(image, verifyImageSignatures(image, [attestors.keyed])).all(e, e > 0). Then test both sides:
kubectl -n team-b run signed --image=kind-registry:5000/demo:v1 --restart=Never -- sleep 60
docker tag busybox:1.37 localhost:5001/demo:unsigned && docker push localhost:5001/demo:unsigned
kubectl -n team-b run unsigned --image=kind-registry:5000/demo:unsigned --restart=Never -- sleep 60outputcaptured 2026-11-18
$ kubectl -n team-b run signed --image=kind-registry:5000/demo:v1 --restart=Never -- sleep 60
Warning: would violate PodSecurity "restricted:latest": allowPrivilegeEscalation != false (container "signed" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container "signed" must set securityContext.capabilities.drop=["ALL"]), runAsNonRoot != true (pod or container "signed" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container "signed" must set securityContext.seccompProfile.type to "RuntimeDefault" or "Localhost")
pod/signed created
$ docker tag busybox:1.37 localhost:5001/demo:unsigned && docker push localhost:5001/demo:unsigned
The push refers to repository [localhost:5001/demo]
68fe9bff2ad4: Unavailable
68fe9bff2ad4: Mounted from validate
unsigned: digest: sha256:66a6306db78bf2dbf3487f293aa8d6990d8e506fdffab9cc43fe422becf886e4 size: 610
Info -> Not all multiplatform-content is present and only the available single-platform image was pushed
sha256:a7dbc319b1438115a207e11930dc4bb3e643dcb3ec0bdd694bb36cd8fad289ec -> sha256:66a6306db78bf2dbf3487f293aa8d6990d8e506fdffab9cc43fe422becf886e4
$ kubectl -n team-b run unsigned --image=kind-registry:5000/demo:unsigned --restart=Never -- sleep 60
Warning: would violate PodSecurity "restricted:latest": allowPrivilegeEscalation != false (container "unsigned" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container "unsigned" must set securityContext.capabilities.drop=["ALL"]), runAsNonRoot != true (pod or container "unsigned" must set securityContext.runAsNonRoot=true), seccompProfile (pod or container "unsigned" must set securityContext.seccompProfile.type to "RuntimeDefault" or "Localhost")
Error from server: admission webhook "ivpol.validate.kyverno.svc-fail" denied the request: Policy require-signed-demo failed: demo images must be signed with the platform key; verification details: image "kind-registry:5000/demo:unsigned@sha256:66a6306db78bf2dbf3487f293aa8d6990d8e506fdffab9cc43fe422becf886e4", attestor "keyed": failed to verify cosign signatures: no signatures foundkubectl -n kyverno logs deploy/kyverno-admission-controller | grep -i verif to pinpoint the real cause (registry scheme, missing .sig, or Rekor tlog check). Clean up the policy afterward so pods in other sections aren't blocked.You now have five distinct controls sitting between a git push and a running pod: the pipeline scan gate (2.4), registry signatures (here), admission verification (here), PSS (5.3), and continuous rescanning (5.4). Write one crisp line per control naming the failure class that only it catches.
Keyless verification without identity flags isn't verification at all: it just asks "did anyone on earth sign this?", so cosign flat-out refuses to run. Watch commands two and three closely: passing the wrong identity fails while printing the actual subject and issuer from the certificate, which is the quickest way to inspect an upstream image you didn't build yourself.
# no identity at all: cosign will not answer the question
cosign verify ghcr.io/sigstore/cosign/cosign:v2.4.1 2>&1 | head -3
# an identity that does not match: the error names the one that is actually on the certificate
cosign verify ghcr.io/sigstore/cosign/cosign:v2.4.1 \
--certificate-identity-regexp='^https://github.com/sigstore/cosign/.*' \
--certificate-oidc-issuer=https://token.actions.githubusercontent.com 2>&1 | head -4
# the identity the certificate really carries
cosign verify ghcr.io/sigstore/cosign/cosign:v2.4.1 \
--certificate-identity=keyless@projectsigstore.iam.gserviceaccount.com \
--certificate-oidc-issuer=https://accounts.google.com 2>&1 | head -6outputcaptured 2026-11-18
$ # no identity at all: cosign will not answer the question
$ cosign verify ghcr.io/sigstore/cosign/cosign:v2.4.1 2>&1 | head -3
Error: --certificate-identity or --certificate-identity-regexp is required for verification in keyless mode
error during command execution: --certificate-identity or --certificate-identity-regexp is required for verification in keyless mode
$ # an identity that does not match: the error names the one that is actually on the certificate
$ cosign verify ghcr.io/sigstore/cosign/cosign:v2.4.1 \
--certificate-identity-regexp='^https://github.com/sigstore/cosign/.*' \
--certificate-oidc-issuer=https://token.actions.githubusercontent.com 2>&1 | head -4
Error: no matching signatures: error verifying bundle: empty key
none of the expected identities matched what was in the certificate, got subjects [keyless@projectsigstore.iam.gserviceaccount.com] with issuer https://accounts.google.com
error during command execution: no matching signatures: error verifying bundle: empty key
none of the expected identities matched what was in the certificate, got subjects [keyless@projectsigstore.iam.gserviceaccount.com] with issuer https://accounts.google.com
$ # the identity the certificate really carries
$ cosign verify ghcr.io/sigstore/cosign/cosign:v2.4.1 \
--certificate-identity=keyless@projectsigstore.iam.gserviceaccount.com \
--certificate-oidc-issuer=https://accounts.google.com 2>&1 | head -6
Verification for ghcr.io/sigstore/cosign/cosign:v2.4.1 --
The following checks were performed on each of these signatures:
- The cosign claims were validated
- Existence of the claims in the transparency log was verified offline
- The code-signing certificate was verified using trusted certificate authority certificates--certificate-identity or --certificate-identity-regexp is required for verification in keyless mode. The second fails with none of the expected identities matched what was in the certificate, got subjects [keyless@projectsigstore.iam.gserviceaccount.com] with issuer https://accounts.google.com, handing you the real identity on a platter. Plugging that exact subject and issuer into the third command prints Verification for ... with all checks passing. That release was signed by a Google service account rather than GitHub Actions, which is why guessing the GitHub identity failed.A signature proves who built the image; an attestation proves what's inside it, signed. Attach a CycloneDX SBOM as an attestation, inspect the artifact tree, and verify and extract the predicate back out: that round trip is the entire supply-chain trust loop.
# generate-key-pair prompts for a passphrase; an empty COSIGN_PASSWORD is what makes it non-interactive
[ -f /tmp/cosign.key ] || COSIGN_PASSWORD='' cosign generate-key-pair --output-key-prefix /tmp/cosign
skopeo copy --dest-tls-verify=false docker://ghcr.io/stefanprodan/podinfo:6.7.1 docker://localhost:5001/demo:v1
trivy image --format cyclonedx --output /tmp/sbom.json localhost:5001/demo:v1
COSIGN_PASSWORD='' cosign attest --yes --predicate /tmp/sbom.json --type cyclonedx --key /tmp/cosign.key --allow-insecure-registry localhost:5001/demo:v1
cosign tree --allow-insecure-registry localhost:5001/demo:v1
cosign verify-attestation --type cyclonedx --key /tmp/cosign.pub --allow-insecure-registry localhost:5001/demo:v1 | jq -r .payload | base64 -d | jq '{predicateType, components: (.predicate.components | length)}'outputcaptured 2026-09-13
$ # generate-key-pair prompts for a passphrase; an empty COSIGN_PASSWORD is what makes it non-interactive
$ [ -f /tmp/cosign.key ] || COSIGN_PASSWORD='' cosign generate-key-pair --output-key-prefix /tmp/cosign
Private key written to /tmp/cosign.key
Public key written to /tmp/cosign.pub
$ skopeo copy --dest-tls-verify=false docker://ghcr.io/stefanprodan/podinfo:6.7.1 docker://localhost:5001/demo:v1
Getting image source signatures
Copying blob sha256:7e517c53cd4ca936c3bc3d3dc66419278a680214f37444ad0ad1b8bd65968940
Copying blob sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1
Copying blob sha256:43c4264eed91be63b206e17d93e75256a6097070ce643c5e8f0379998b44f170
Copying blob sha256:2bf70b2badb9fa00aa36d50d61c6b9cc094d7a18fb4a3c7a91ce950dd7202900
Copying blob sha256:35d14af0e611499048effc4d39a2341345f96dd9103c8c186b7cc239a687de5c
Copying blob sha256:31eaa2883f08a0ce854d061714a111f052444a3ba1b2323719cb12b872a0dbe3
Copying blob sha256:47f87f374862e0c7555781b116554936999ad2e8e4c6a4e7417688ffe57d8b88
Copying config sha256:c875de4397634b0dc138954cbe2c11b9d86d948b98b17bd9fc3227b3ad992eae
Writing manifest to image destination
$ trivy image --format cyclonedx --output /tmp/sbom.json localhost:5001/demo:v1
2026-09-13T00:11:59-04:00 INFO "--format cyclonedx" disables security scanning. Specify "--scanners vuln" explicitly if you want to include vulnerabilities in the "cyclonedx" report.
2026-09-13T00:12:00-04:00 INFO Detected OS family="alpine" version="3.20.3"
2026-09-13T00:12:00-04:00 INFO Number of language-specific files num=2
📣 Notices:
- Version 0.74.0 of Trivy is now available, current version is 0.73.0
To suppress version checks, run Trivy scans with the --skip-version-check flag
$ COSIGN_PASSWORD='' cosign attest --yes --predicate /tmp/sbom.json --type cyclonedx --key /tmp/cosign.key --allow-insecure-registry localhost:5001/demo:v1
WARNING: Image reference localhost:5001/demo:v1 uses a tag, not a digest, to identify the image to sign.
This can lead you to sign a different image than the intended one. Please use a
digest (example.com/ubuntu@sha256:abc123...) rather than tag
(example.com/ubuntu:latest) for the input to cosign. The ability to refer to
images by tag will be removed in a future release.
Using payload from: /tmp/sbom.json
Signing artifact...
$ cosign tree --allow-insecure-registry localhost:5001/demo:v1
📦 Supply Chain Security Related artifacts for an image: localhost:5001/demo:v1
└── 🔐 Signatures for an image tag: localhost:5001/demo:sha256-ed73e9871dfba28276b28daab3463cc2f9b3c15337dfe0445e8b0f79694e0cd6.sig
└── 🍒 sha256:a217ae5b0b2d194cf70785da9ff77db49a8040f86cd50d518766deecce261c91
└── 🔗 https://cyclonedx.org/bom artifacts via OCI referrer: localhost:5001/demo@sha256:53833ef158bb16c0652edf40242d2f5a0da861f0b447271c5f55170da4a294da
└── 🍒 sha256:6ff7639af536922fe0b7b8d5ee81bcd56fc432099b04a2bfb5e96fc8ef167558
└── 🔗 https://cyclonedx.org/bom artifacts via OCI referrer: localhost:5001/demo@sha256:c4ebc6c30e427e7656271ffaae5694e47c51831d2dfbcda1a306603877e4e620
└── 🍒 sha256:9f5427192055dde8d943dfcf0e35900cebacef1b820258a2d06a17da84b0ceb4
$ cosign verify-attestation --type cyclonedx --key /tmp/cosign.pub --allow-insecure-registry localhost:5001/demo:v1 | jq -r .payload | base64 -d | jq '{predicateType, components: (.predicate.components | length)}'
Verification for localhost:5001/demo:v1 --
The following checks were performed on each of these signatures:
- The cosign claims were validated
- Existence of the claims in the transparency log was verified offline
- The signatures were verified against the specified public key
{
"predicateType": "https://cyclonedx.org/bom",
"components": 114
}cosign tree shows the attestation sitting next to the image, and the decoded verified payload carries the CycloneDX predicateType with all components intact.Because tags are mutable pointers, verifying a tag at admission and letting the kubelet pull that tag later creates a race window. Setting mutateDigest tells Kyverno to rewrite the pod spec straight to the verified digest, closing the gap inside the object itself. In an ImageValidatingPolicy, it lives under validationConfigurations and defaults to true (older docs show mutateDigest: true on a classic verifyImages rule, which Kyverno 1.20 refuses).
[ -f /tmp/cosign.pub ] || COSIGN_PASSWORD='' cosign generate-key-pair --output-key-prefix /tmp/cosign
# Kyverno's verifier reads the legacy .sig tag, so the image needs a signature in that format
DIGEST=$(skopeo inspect --tls-verify=false docker://localhost:5001/demo:v1 | jq -r .Digest)
COSIGN_PASSWORD='' cosign sign --key /tmp/cosign.key --allow-http-registry -y --use-signing-config=false --new-bundle-format=false --tlog-upload=false localhost:5001/demo@$DIGEST
kubectl apply -f - <<EOF
apiVersion: policies.kyverno.io/v1
kind: ImageValidatingPolicy
metadata: { name: pin-digest }
spec:
validationActions: [Deny]
matchConstraints:
resourceRules:
- { apiGroups: [""], apiVersions: [v1], operations: [CREATE], resources: [pods] }
namespaceSelector:
matchLabels: { kubernetes.io/metadata.name: default }
matchImageReferences:
- glob: "kind-registry:5000/demo:v1"
validationConfigurations:
mutateDigest: true # the default, spelled out: rewrite the tag to the digest it verified
attestors:
- name: keyed
cosign:
key:
data: |-
$(sed 's/^/ /' /tmp/cosign.pub)
ctlog:
insecureIgnoreTlog: true
validations:
- expression: images.containers.map(image, verifyImageSignatures(image, [attestors.keyed])).all(e, e > 0)
message: the demo image must carry the lab key's signature
EOF
sleep 20
kubectl -n default run pinned --image=kind-registry:5000/demo:v1 --restart=Never
kubectl -n default get pod pinned -o jsonpath='{.spec.containers[0].image}{"\n"}'
kubectl -n default delete pod pinned --ignore-not-found
kubectl delete imagevalidatingpolicy pin-digestoutputcaptured 2026-11-18
$ [ -f /tmp/cosign.pub ] || COSIGN_PASSWORD='' cosign generate-key-pair --output-key-prefix /tmp/cosign
$ # Kyverno's verifier reads the legacy .sig tag, so the image needs a signature in that format
$ DIGEST=$(skopeo inspect --tls-verify=false docker://localhost:5001/demo:v1 | jq -r .Digest)
$ COSIGN_PASSWORD='' cosign sign --key /tmp/cosign.key --allow-http-registry -y --use-signing-config=false --new-bundle-format=false --tlog-upload=false localhost:5001/demo@$DIGEST
Flag --new-bundle-format has been deprecated, this will be the only supported format in future versions
Flag --tlog-upload has been deprecated, prefer using a --signing-config file with no transparency log services
Signing artifact...
Pushing signature to: localhost:5001/demo
$ kubectl apply -f - <<EOF
apiVersion: policies.kyverno.io/v1
kind: ImageValidatingPolicy
metadata: { name: pin-digest }
spec:
validationActions: [Deny]
matchConstraints:
resourceRules:
- { apiGroups: [""], apiVersions: [v1], operations: [CREATE], resources: [pods] }
namespaceSelector:
matchLabels: { kubernetes.io/metadata.name: default }
matchImageReferences:
- glob: "kind-registry:5000/demo:v1"
validationConfigurations:
mutateDigest: true # the default, spelled out: rewrite the tag to the digest it verified
attestors:
- name: keyed
cosign:
key:
data: |-
$(sed 's/^/ /' /tmp/cosign.pub)
ctlog:
insecureIgnoreTlog: true
validations:
- expression: images.containers.map(image, verifyImageSignatures(image, [attestors.keyed])).all(e, e > 0)
message: the demo image must carry the lab key's signature
EOF
imagevalidatingpolicy.policies.kyverno.io/pin-digest created
$ sleep 20
$ kubectl -n default run pinned --image=kind-registry:5000/demo:v1 --restart=Never
pod/pinned created
$ kubectl -n default get pod pinned -o jsonpath='{.spec.containers[0].image}{"\n"}'
kind-registry:5000/demo:v1@sha256:ed73e9871dfba28276b28daab3463cc2f9b3c15337dfe0445e8b0f79694e0cd6
$ kubectl -n default delete pod pinned --ignore-not-found
pod "pinned" deleted from default namespace
$ kubectl delete imagevalidatingpolicy pin-digest
imagevalidatingpolicy.policies.kyverno.io "pin-digest" deleted@sha256:... even though you submitted a plain tag.A CI scanner gate is really a policy choice written as CLI flags, and every flag shifts what gets blocked. Run Trivy against the exact same image three ways and watch the exit code flip without touching the image.
trivy image -q --exit-code 1 --severity CRITICAL localhost:5001/demo:v1 > /tmp/scan-strict.txt 2>&1; echo "strict exit: $?"
trivy image -q --exit-code 1 --severity CRITICAL --ignore-unfixed localhost:5001/demo:v1 > /tmp/scan-unfixed.txt 2>&1; echo "ignore-unfixed exit: $?"
# every CRITICAL id, not just the first: suppressing one of three moves no exit code
trivy image -q --severity CRITICAL --format json localhost:5001/demo:v1 | jq -r '[.Results[].Vulnerabilities // [] | .[].VulnerabilityID] | unique | .[]' > /tmp/cves.txt
cat /tmp/cves.txt
sed 's/$/ exp:2020-01-01/' /tmp/cves.txt > /tmp/.trivyignore
trivy image -q --exit-code 1 --severity CRITICAL --ignorefile /tmp/.trivyignore localhost:5001/demo:v1 > /tmp/scan-expired.txt 2>&1; echo "expired-ignore exit: $?"
sed 's/$/ exp:2099-01-01/' /tmp/cves.txt > /tmp/.trivyignore
trivy image -q --exit-code 1 --severity CRITICAL --ignorefile /tmp/.trivyignore localhost:5001/demo:v1 > /tmp/scan-live.txt 2>&1; echo "live-ignore exit: $?"
tail -5 /tmp/scan-live.txtoutputcaptured 2026-09-13
$ trivy image -q --exit-code 1 --severity CRITICAL localhost:5001/demo:v1 > /tmp/scan-strict.txt 2>&1; echo "strict exit: $?"
strict exit: 1
$ trivy image -q --exit-code 1 --severity CRITICAL --ignore-unfixed localhost:5001/demo:v1 > /tmp/scan-unfixed.txt 2>&1; echo "ignore-unfixed exit: $?"
ignore-unfixed exit: 1
$ # every CRITICAL id, not just the first: suppressing one of three moves no exit code
$ trivy image -q --severity CRITICAL --format json localhost:5001/demo:v1 | jq -r '[.Results[].Vulnerabilities // [] | .[].VulnerabilityID] | unique | .[]' > /tmp/cves.txt
$ cat /tmp/cves.txt
CVE-2025-68121
CVE-2026-31789
CVE-2026-33186
$ sed 's/$/ exp:2020-01-01/' /tmp/cves.txt > /tmp/.trivyignore
$ trivy image -q --exit-code 1 --severity CRITICAL --ignorefile /tmp/.trivyignore localhost:5001/demo:v1 > /tmp/scan-expired.txt 2>&1; echo "expired-ignore exit: $?"
expired-ignore exit: 1
$ sed 's/$/ exp:2099-01-01/' /tmp/cves.txt > /tmp/.trivyignore
$ trivy image -q --exit-code 1 --severity CRITICAL --ignorefile /tmp/.trivyignore localhost:5001/demo:v1 > /tmp/scan-live.txt 2>&1; echo "live-ignore exit: $?"
live-ignore exit: 0
$ tail -5 /tmp/scan-live.txt
└────────────────────────────────────────┴──────────┴─────────────────┴─────────┘
Legend:
- '-': Not scanned
- '0': Clean (no security findings detected)strict exits 1, and ignore-unfixed still exits 1 because every CRITICAL here already has a fix available. The expired ignorefile exits 1 too, proving past-dated entries stop suppressing automatically. Updating the expiry to 2099 flips the exit code to 0, leaving only the clean legend. Notice why we redirect output to files: piping Trivy into head or tail masks its exit code behind the pager's, and a 50-line table buries the single exit status your CI gate depends on.Self-check
Why scan in the pipeline and in the cluster?
The pipeline gate blocks known vulnerabilities before an image ever hits the registry, but it can't predict CVEs disclosed tomorrow. Continuous in-cluster scanning catches those new CVEs on images already running. CI-only leaves you blind to everything newer than your last deploy; cluster-only lets vulnerable images ship in the first place.
Why is signing by digest, not by tag, the point?
A digest uniquely identifies exact image bytes, whereas a tag is just a mutable label. Signing the digest binds the signature to those specific bytes so nobody moving the tag can forge it. Verification resolves any tag to its digest first, and a hardened admission policy rewrites the pod spec to that pinned digest so runtime can never drift from what was checked.
Signatures exist and someone still deployed an unsigned image. What was missing?
Admission-time verification. Without an enforcement point checking signatures at the door, signing is just decoration. Deploy an image-verification policy matching your registry glob in Deny mode, and double-check that its glob matches the exact in-cluster reference format pods actually use.
Kyverno reports "no signatures found" for an image you definitely signed. Three candidates?
Check three usual suspects: registry reachability and hostname (Kyverno resolves from inside the cluster, so localhost won't reach your registry), HTTP vs HTTPS scheme (plain HTTP requires the engine's insecure-registry flag), and signature format skew (a cosign v3 bundle where the verifier expects the legacy .sig tag). Also check Rekor transparency-log settings if you signed with --tlog-upload=false.
Distinguish SBOM, provenance and signature in one sentence each.
SBOM: what components and versions are inside the artifact. Provenance: how, where, and from what source it was built (a SLSA-style attestation). Signature: who cryptographically vouches for these exact bytes. Together they form one trust story, and both SBOMs and provenance are typically stored as signed attestations.
Keyless verification: which two flags are mandatory, and what does each pin?
--certificate-identity (or --certificate-identity-regexp) pins the SAN inside the Fulcio cert (a signer's email, or a CI workflow URI like https://github.com/org/repo/.github/workflows/build.yaml@refs/heads/main). --certificate-oidc-issuer pins the OIDC provider that authenticated them (like https://token.actions.githubusercontent.com). Without both, any Fulcio-issued cert from anywhere would pass, which is why cosign refuses to run without them.
Tekton Chains signs the TaskRun (annotation chains.tekton.dev/signed: "true") but cosign verify-attestation on the image finds nothing. Two configuration causes?
Either the Task didn't emit type-hinted results (IMAGE_URL and IMAGE_DIGEST, or *ARTIFACT_OUTPUTS) so Chains didn't know an OCI image was produced, or artifacts.taskrun.storage / artifacts.oci.storage omitted oci so provenance only went to the tekton backend (run annotations). Inspect the TaskRun's results, the chains-config ConfigMap, and the Chains controller logs.
What distinguishes SLSA Build L2 from L3, and which one does a signed provenance from a shared CI runner reach?
L2 requires a hosted build platform to generate and sign provenance using a platform-held key users can't touch. L3 goes further: builds must be isolated from each other and from user-controlled steps so a run can neither tamper with its own provenance nor access signing material. A shared runner where jobs can inspect each other's state or credentials tops out at L2; L3 requires ephemeral isolated builders with signing handled strictly outside the build step (like Tekton Chains signing from its own controller rather than inside the Task).
A Kyverno ImageValidatingPolicy fails on a private-registry image with an authentication error, although the pod's imagePullSecrets work. Why?
ImageValidatingPolicy doesn't read the pod's imagePullSecrets and ignores the global registry credential helper flag. You have to supply registry credentials explicitly on the policy itself via spec.credentials.secrets (Secrets in Kyverno's namespace) or credentials.providers for cloud ambient auth. Because Kyverno pulls signatures from its own pod, networking, TLS scheme (allowInsecureRegistry), and auth are all evaluated from Kyverno's side.
Docs to know your way around
- docs.sigstore.dev: cosign key-pair sign/verify, plus a quick skim of keyless (Fulcio and Rekor) so the vocabulary feels natural.
- kyverno.io:
ImageValidatingPolicyreference and examples. - slsa.dev: the Build track levels table (a five-minute read that pays off).
- Offline:
cosign --help,trivy image --help, andkubectl explain imagevalidatingpolicies.spec(the tie-breaker whenever online docs and your cluster disagree). - docs.sigstore.dev/cosign/verifying/verify (identity flags,
--check-claims, private CA options) and /cosign/verifying/attestation (CUE and Rego policies on predicates). - tekton.dev/docs/chains/config (every
chains-configkey and value) and /docs/chains/slsa-provenance (type hints and deep inspection); slsa.dev/spec/v1.0/levels for the Build track. - kyverno.io/docs/policy-types/image-validating-policy (attestors, attestations,
credentials, and CEL functions) and docs.sigstore.dev/policy-controller/overview (ClusterImagePolicy, namespace label, AND/OR rules).