How do you enforce Supply Chain Security using Sigstore Cosign and Kyverno in K8s?
❓ Interview Prompt: Explain Sigstore keyless signing, Cosign image attestation, Kyverno image verification policy, and SLSA provenance for supply chain integrity.
Supply chain attacks compromise software during the build/publish process — attackers inject malicious code into legitimate container images (e.g., SolarWinds-style attacks). Image signing proves that an image was built by a specific pipeline and hasn't been tampered with.
Sigstore + Cosign Architecture:
Sigstore is an open standard for signing software artifacts using ephemeral cryptographic keys and a public transparency log.
Kyverno Image Verification:
Kyverno's verifyImages policy verifies Cosign signatures as an admission webhook — rejecting pods with unsigned or invalid image signatures before they schedule.
Code Implementation Example
# Step 1: Sign image in GitHub Actions CI (keyless)
# - uses: sigstore/cosign-installer@v3
# - run: cosign sign --yes ghcr.io/myorg/myapp:${{ github.sha }}
# This records signature to Rekor transparency log
# Step 2: Kyverno policy — verify image signatures before scheduling
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-signed-images
spec:
validationFailureAction: Enforce # Reject unsigned images
rules:
- name: verify-image-signature
match:
any:
- resources:
kinds: [Pod]
namespaces: [production]
verifyImages:
- imageReferences:
- "ghcr.io/myorg/*" # Apply to all images from our registry
attestors:
- entries:
- keyless:
subject: "https://github.com/myorg/myrepo/.github/workflows/build.yml@refs/heads/main"
issuer: "https://token.actions.githubusercontent.com"
rekor:
url: https://rekor.sigstore.dev
# Also require SBOM attestation
attestations:
- type: https://spdx.dev/Document
attestors:
- entries:
- keyless:
subject: "https://github.com/myorg/*"Cosign keyless signing (OIDC → Fulcio certificate → Rekor log) creates verifiable supply chain provenance. Kyverno enforces image signature verification as admission webhook — blocks unsigned images.