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 →
- 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...
- Optionally attach attestations: SBOM and SLSA provenance (
cosign attest). - 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"
- Deploy by digest, not tag, so what was verified is what runs.
- 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".
More on Security incidents
An AWS access key for a production IAM user was pushed to a public GitHub repo 20 minutes ago. What do you do in the first 30 minutes?AdvancedYou find pods in your cluster running a crypto miner. What do you do?AdvancedA critical CVE is announced in a library you use. You have 200 images across 40 repos. How do you find and patch everything fast?IntermediateGuardDuty reports an EC2 instance talking to a known command-and-control IP. What do you do?AdvancedYou discover an S3 bucket with customer data has been public for three months. What now?IntermediateAn engineer left the company three weeks ago and you find their access key was used yesterday. How do you respond and fix the process?Beginner