Security wants a guarantee that only images built by your CI can run in production. How do you implement it?

AdvancedScenarioSecurity incidents
Answer

Situation read → Registry restrictions aren't enough, since anyone with push access can upload an image. You need cryptographic proof of where the image came from.

What I'd do →

  1. Sign images in CI with Cosign keyless signing (GitHub OIDC identity, logged in the Sigstore transparency log).
cosign sign --yes 111122223333.dkr.ecr.ap-south-1.amazonaws.com/api@sha256:3f1c...
  1. Optionally attach attestations: SBOM and SLSA provenance (cosign attest).
  2. Enforce at admission with Kyverno (or Sigstore policy-controller): only images signed by your workflow identity are allowed.
verifyImages:
  - imageReferences: ["111122223333.dkr.ecr.ap-south-1.amazonaws.com/*"]
    attestors:
      - entries:
          - keyless:
              subject: "https://github.com/acme/*/.github/workflows/release.yml@refs/heads/main"
              issuer: "https://token.actions.githubusercontent.com"
  1. Deploy by digest, not tag, so what was verified is what runs.
  2. Roll out in audit mode first, then enforce.

Why → The signature ties the image to a specific workflow on a specific branch, so a manually pushed image is rejected.

Interview tip → Mention verifying the identity (workflow and branch), not just "is it signed".

All Real-World Interview questions Roadmap: Interview readiness

More on Security incidents