How do you sign container images in GitHub Actions without managing private keys?
IntermediateScenarioSupply Chain Security
Answer
Situation read → Keyless signing with Sigstore uses the workflow's OIDC identity and a short-lived certificate from Fulcio.
What I'd do →
- Grant the job
id-token: writeandpackages: write. - Install cosign (
sigstore/cosign-installer) and sign by digest:
cosign sign --yes ghcr.io/example-org/app@sha256:<digest>
- Record the signature in the Rekor transparency log (automatic).
- Verify with identity constraints:
cosign verify ghcr.io/example-org/app@sha256:<digest> \
--certificate-identity-regexp 'https://github.com/example-org/app/.github/workflows/release.yml@.*' \
--certificate-oidc-issuer https://token.actions.githubusercontent.com
Why → No long-lived key means no key to steal.
Interview tip → Sign the digest, never the tag.
More on Supply Chain Security
What is an SBOM, and at which point in the pipeline do you generate it?BeginnerA customer asks for an SBOM for your product. What do you give them?BeginnerYou signed images in CI. How do you make sure the cluster only runs signed images?IntermediateLeadership wants "SLSA compliance". What do you propose?IntermediateWhat is typosquatting and how do you protect developers from it?BeginnerYour internal package `acme-utils` exists in a private registry. How do you prevent dependency confusion?Advanced