Interview's MateDocker
Interview's Mate

Docker

Compose · Networking · Security · Ops

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Docker topics
Lesson 116/ 160
06. Docker Security & Hardening

Image Signing, Verification & Supply Chain Security (Cosign, Notary)

Sign and verify images with Cosign/Notary to protect the supply chain.

AdvancedCosign · Notary3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

Bind publication, SBOM/provenance and admission policy to the same immutable digest and signer identity.

Think of it like…

A wax seal proves this box was sealed by the recognized sender; it does not promise every item inside is safe unless the included inspection attestation is checked.

Where you’ve seen it

In practice, cosign sign --yes ghcr.io/acme/api@sha256:deadbeef; cosign verify --certificate-identity-regexp=acme/actions ghcr.io/acme/api@sha256:deadbeef is the concrete move for this job: sign and verify images with Cosign/Notary to protect the supply chain. The release is not accepted until verify the OIDC issuer/identity, certificate transparency bundle and digest in a clean environment after rotating the keyless signing role confirms the result.

Words you’ll hear

Cosign
The implementation control in cosign sign --yes ghcr.io/acme/api@sha256:deadbeef; cosign verify --certificate-identity-regexp=acme/actions ghcr.io/acme/api@sha256:deadbeef for sign and verify images with Cosign/Notary to protect the supply chain.
Notary
The result to observe with verify the OIDC issuer/identity, certificate transparency bundle and digest in a clean environment after rotating the keyless signing role, rather than infer from a successful command alone.
Verify
The production boundary exposed when accepting any valid Cosign signature without constraining issuer and workflow identity, or signing once before a final rebuild.

Visual diagram

Loading interactive diagram

Theory & deep dive

Cosign control path

The concrete mechanism is cosign sign --yes ghcr.io/acme/api@sha256:deadbeef; cosign verify --certificate-identity-regexp=acme/actions ghcr.io/acme/api@sha256:deadbeef. The observable result is verify the OIDC issuer/identity, certificate transparency bundle and digest in a clean environment after rotating the keyless signing role; if those disagree, inspect the runtime evidence before changing unrelated settings.

Sign and verify images with Cosign/Notary to protect the supply chain. Keep Cosign, Notary and Verify in the same deployment record so the intent and the observed state cannot drift apart.

Concrete Cosign setup

cosign sign --yes ghcr.io/acme/api@sha256:deadbeef; cosign verify --certificate-identity-regexp=acme/actions ghcr.io/acme/api@sha256:deadbeef

Key takeaway: Prove Notary with verify the OIDC issuer/identity, certificate transparency bundle and digest in a clean environment after rotating the keyless signing role, not with command success alone.

Verify failure boundary

Signing a tag is dangerous if the tag moves; a signature proves who attested a manifest, not that the image is vulnerability-free. A private signing key on a CI runner and unaudited verification roots create another supply-chain weakness. The narrow failure to design for is accepting any valid Cosign signature without constraining issuer and workflow identity, or signing once before a final rebuild.

Accept this compromise explicitly: Keyless OIDC reduces key custody; managed keys offer offline/air-gapped control but require rotation and protection. The controlled check-verify the OIDC issuer/identity, certificate transparency bundle and digest in a clean environment after rotating the keyless signing role-also identifies the point where a different design is safer.

Deliberate failure test

Exercise this failure safely: accepting any valid Cosign signature without constraining issuer and workflow identity, or signing once before a final rebuild.

Key takeaway: Keyless OIDC reduces key custody; managed keys offer offline/air-gapped control but require rotation and protection.

How it works, step by step

Step 1 of 4
Design

1. State the boundary

Write down why the workload needs this: Signing a tag is dangerous if the tag moves; a signature proves who attested a manifest, not that the image is vulnerability-free. A private signing key on a CI runner and unaudited verification roots create another supply-chain weakness.

Bind publication, SBOM/provenance and admission policy to the same immutable digest and signer identity.
Key numbers at this step
Intent
Cosign

When to use it & trade-offs

What it is

Cosign signs or keylessly attests a release manifest digest, and verification checks the trusted identity, certificate/issuer and digest match before deployment. Notary-style trust systems also separate tag trust from arbitrary signatures, but deployment must consume their policy.

Why it matters: Signing a tag is dangerous if the tag moves; a signature proves who attested a manifest, not that the image is vulnerability-free. A private signing key on a CI runner and unaudited verification roots create another supply-chain weakness.

When to reach for it

  • The fit is strongest for this job: sign and verify images with Cosign/Notary to protect the supply chain. Pair it with verify the OIDC issuer/identity, certificate transparency bundle and digest in a clean environment after rotating the keyless signing role in the runbook.
  • Production Cosign changes should make Notary observable through cosign sign --yes ghcr.io/acme/api@sha256:deadbeef; cosign verify --certificate-identity-regexp=acme/actions ghcr.io/acme/api@sha256:deadbeef, rather than trusting the runtime default.
  • Keep a rollback example for the case where accepting any valid Cosign signature without constraining issuer and workflow identity, or signing once before a final rebuild.

When to avoid or be careful

  • Do not accept command success while the system can still fail by accepting any valid Cosign signature without constraining issuer and workflow identity, or signing once before a final rebuild.
  • Avoid erasing Verify protection merely to dodge this cost: “Keyless OIDC reduces key custody; managed keys offer offline/air-gapped control but require rotation and protection”.
  • Do not replace the evidence path-verify the OIDC issuer/identity, certificate transparency bundle and digest in a clean environment after rotating the keyless signing role-with a screenshot or a mutable tag.

cosign sign --yes ghcr.io/acme/api@sha256:deadbeef; cosign verify --certificate-identity-regexp=acme/actions ghcr.io/acme/api@sha256:deadbeef: practical choices

Explicit Cosign
Best for: Sign and verify images with Cosign/Notary to protect the supply chain, with a reviewed runbook.

Strengths: Cosign signs or keylessly attests a release manifest digest, and verification checks the trusted identity, certificate/issuer and digest match before deployment. Notary-style trust systems also separate tag trust from arbitrary signatures, but deployment must consume their policy.

Watch out: Keyless OIDC reduces key custody; managed keys offer offline/air-gapped control but require rotation and protection.

Ambient default
Best for: Short-lived Notary experiments with low blast radius.

Strengths: It can begin with cosign sign --yes ghcr.io/acme/api@sha256:deadbeef; cosign verify --certificate-identity-regexp=acme/actions ghcr.io/acme/api@sha256:deadbeef and fewer surrounding controls.

Watch out: It silently accepts accepting any valid Cosign signature without constraining issuer and workflow identity, or signing once before a final rebuild, which makes the result hard to reproduce after promotion.

Managed Verify
Best for: Teams that centralize Verify policy across many workloads.

Strengths: Signing a tag is dangerous if the tag moves; a signature proves who attested a manifest, not that the image is vulnerability-free. A private signing key on a CI runner and unaudited verification roots create another supply-chain weakness.

Watch out: The platform adds an ownership and debugging layer; retain verify the OIDC issuer/identity, certificate transparency bundle and digest in a clean environment after rotating the keyless signing role as the direct check.

Interview signals & numbers to know

When this topic comes up

  • cosign sign --yes ghcr.io/acme/api@sha256:deadbeef; cosign verify --certificate-identity-regexp=acme/actions ghcr.io/acme/api@sha256:deadbeef
  • verify the OIDC issuer/identity, certificate transparency bundle and digest in a clean environment after rotating the keyless signing role
  • Failure signature: accepting any valid Cosign signature without constraining issuer and workflow identity, or signing once before a final rebuild
  • Trade-off: Keyless OIDC reduces key custody; managed keys offer offline/air-gapped control but require rotation and protection.

Benchmarks & rules of thumb

1 digest -
unit of signature verification
2 identity dimensions -
issuer plus repository/workflow identity
0 security claims -
beyond the attestation unless policy checks them

Common mistakes & follow-ups

Common interview mistakes

  • Treating a successful cosign sign --yes ghcr.io/acme/api@sha256:deadbeef; cosign verify --certificate-identity-regexp=acme/actions ghcr.io/acme/api@sha256:deadbeef as proof and skipping verify the OIDC issuer/identity, certificate transparency bundle and digest in a clean environment after rotating the keyless signing role.
  • Accepting any valid Cosign signature without constraining issuer and workflow identity, or signing once before a final rebuild
  • Optimizing Cosign without accepting that keyless OIDC reduces key custody; managed keys offer offline/air-gapped control but require rotation and protection.

Likely interviewer follow-ups

  • Why does cosign sign --yes ghcr.io/acme/api@sha256:deadbeef; cosign verify --certificate-identity-regexp=acme/actions ghcr.io/acme/api@sha256:deadbeef address Cosign here rather than through application code?
  • How would you distinguish healthy Notary from the failure “accepting any valid Cosign signature without constraining issuer and workflow identity, or signing once before a final rebuild” using verify the OIDC issuer/identity, certificate transparency bundle and digest in a clean environment after rotating the keyless signing role?
  • When would this trade-off-“Keyless OIDC reduces key custody; managed keys offer offline/air-gapped control but require rotation and protection”-justify a different Verify design?
Interview tip: Give one concrete operation-cosign sign --yes ghcr.io/acme/api@sha256:deadbeef; cosign verify --certificate-identity-regexp=acme/actions ghcr.io/acme/api@sha256:deadbeef-and one proof-verify the OIDC issuer/identity, certificate transparency bundle and digest in a clean environment after rotating the keyless signing role. Then name the boundary: accepting any valid Cosign signature without constraining issuer and workflow identity, or signing once before a final rebuild.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Image Signing, Verification & Supply Chain Security (Cosign, Notary) with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
Software Bill of Materials (SBOM) Generation (syft, docker sbom)
Next topic
Trusted Base Images & Docker Content Trust (DCT)