Cosign and container image signing (sigstore)

Updated November 1, 2026

cosign signs container images. Sigstore is an ecosystem: rekor (transparency log), fulcio (a CA for keyless OIDC). Signatures are stored as OCI objects next to the image. Verify is part of admission control in k8s through policy-controller or Kyverno.

Why sign an image

A container image is just a tar.gz with a manifest, and anyone can push it under the same tag. If an attacker gains access to the registry or swaps the image on an intermediate hop, your k8s pulls it without a second thought. There are no authenticity checks by default.

Real attacks: SolarWinds, codecov, ua-parser-js. All supply chain cases where a trusted artifact turned out to be a compromise.

Signing an image solves:

  1. Authenticity: the image was created by someone we trust
  2. Integrity: the image was not changed after signing (the signature covers the digest)
  3. Non-repudiation: the signer cannot deny it (when recorded in a transparency log)

sigstore, the ecosystem

Earlier people used Notary v1 (Docker Content Trust). It never took off: complex, requires key management, integrates poorly. In 2021 the Linux Foundation launched sigstore, a modern alternative.

Components:

ComponentPurpose
cosignCLI for sign/verify
fulciofree CA that issues short-lived (x509) certificates based on an OIDC token
rekorappend-only transparency log of all signatures (like certificate transparency)
policy-controller / gatekeeper / kyvernoenforcement in k8s

The idea is no long-lived keys. The signer authenticates through OIDC (GitHub Actions, GCP, any OIDC IdP), fulcio issues a cert valid for 10 minutes, cosign signs with it, and the signature plus cert plus log entry are published. Verification means checking the signature against the cert, the cert against the fulcio root, and inclusion in rekor.

Signing methods

1. keyless (OIDC-based), recommended

# Sign
cosign sign ghcr.io/myorg/myapp:v1.2.3
# A browser opens, OIDC login follows, fulcio issues a cert,
# the signature is pushed to the registry, and the log entry goes to rekor

# Verify (cosign 2.0+: keyless verify is the default, COSIGN_EXPERIMENTAL is not needed)
cosign verify \
  --certificate-identity 'https://github.com/myorg/myapp/.github/workflows/release.yml@refs/heads/main' \
  --certificate-oidc-issuer 'https://token.actions.githubusercontent.com' \
  ghcr.io/myorg/myapp:v1.2.3

Identity is the OIDC subject, which for GitHub Actions is the workflow path. This way verify checks that the signature was made by a specific workflow, not by anyone with registry access.

2. static keypair

When OIDC is unavailable (air-gap, on-prem without OIDC):

cosign generate-key-pair                 # cosign.key + cosign.pub
cosign sign --key cosign.key ghcr.io/myorg/myapp:v1.2.3
cosign verify --key cosign.pub ghcr.io/myorg/myapp:v1.2.3

The downside is that you have to protect cosign.key. One option is KMS: --key gcpkms://projects/.../keys/... or awskms://....

3. KMS-backed key

cosign sign --key awskms:///alias/cosign-key ghcr.io/myorg/myapp:v1

The key never leaves KMS, and the cloud provider does the signing. This is the best compromise between keyless (slick) and static (control).

Where the signature lives

cosign pushes the signature as a separate OCI object into the same registry, by convention under the tag sha256-<digest>.sig:

ghcr.io/myorg/myapp:v1.2.3              ← image
ghcr.io/myorg/myapp:sha256-abc...sig    ← signature
ghcr.io/myorg/myapp:sha256-abc...att    ← attestation (optional)

No schema, no database. A registry can store any OCI blob, so everything works with any registry (ECR, GHCR, Artifactory, ACR, Harbor, Quay).

Attestations, more than just a signature

cosign can sign arbitrary claims about an image, not only the digest. This is an attestation in the in-toto format:

# Sign an SBOM (CycloneDX/SPDX)
cosign attest --predicate sbom.spdx.json --type spdx \
  ghcr.io/myorg/myapp:v1.2.3

# SLSA provenance (where it was built from)
cosign attest --predicate provenance.json --type slsaprovenance \
  ghcr.io/myorg/myapp:v1.2.3

# Custom predicate
cosign attest --predicate vuln-scan.json --type custom \
  ghcr.io/myorg/myapp:v1.2.3

Verify:

cosign verify-attestation --type slsaprovenance \
  --certificate-identity ... ghcr.io/myorg/myapp:v1.2.3

Use case: "trust only an image with SLSA provenance level 3, with a recent vuln-scan, and built from the main branch of our repo".

Enforcement in k8s

A signature is useless if nobody verifies it. In k8s the place to do that is the admission controller:

sigstore policy-controller

apiVersion: policy.sigstore.dev/v1beta1
kind: ClusterImagePolicy
metadata: { name: must-be-signed-by-myorg }
spec:
  images:
  - glob: "ghcr.io/myorg/**"
  authorities:
  - keyless:
      url: https://fulcio.sigstore.dev
      identities:
      - issuer: https://token.actions.githubusercontent.com
        subjectRegExp: 'https://github.com/myorg/.+'

Any pod that tries to pull ghcr.io/myorg/... without a signature is rejected at admission.

Kyverno

apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata: { name: verify-images }
spec:
  validationFailureAction: Enforce
  rules:
  - name: check-image
    match:
      any: [{ resources: { kinds: [Pod] } }]
    verifyImages:
    - imageReferences: ["ghcr.io/myorg/*"]
      attestors:
      - entries:
        - keyless:
            subject: "https://github.com/myorg/myapp/.github/workflows/release.yml@refs/heads/main"
            issuer: "https://token.actions.githubusercontent.com"

CI integration (GitHub actions, a typical example)

# .github/workflows/release.yml
permissions:
  id-token: write       # for OIDC
  contents: read
  packages: write
jobs:
  build-sign:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: sigstore/cosign-installer@v3
    - uses: docker/login-action@v3
      with: { registry: ghcr.io, username: ${{ github.actor }}, password: ${{ secrets.GITHUB_TOKEN }} }
    - run: |
        docker buildx build --tag ghcr.io/myorg/myapp:${{ github.sha }} --push .
    - run: |
        cosign sign --yes ghcr.io/myorg/myapp:${{ github.sha }}

--yes skips the interactive confirm. The OIDC token is taken from the GitHub Actions environment automatically.

Cosign vs notary v2 vs GPG

cosignnotary v2GPG
Keyless OIDCyesnono
StorageOCI registryOCI registryoutside the registry
Transparency logrekor (built-in)optionalno
Signatures as OCI artifactsyes (with the _.sig tag, OCI 1.1 referrers)yes (referrers)no
Adoptionde facto standard in 2026in the OCI 1.1 speclegacy

In 2026 practically the whole industry stack has chosen cosign. Notary v2 is present in the OCI Distribution 1.1 spec as an alternative artifact type.

When things go wrong

  • Error: no matching signatures: the image was signed by a different identity or a different issuer. Check --certificate-identity and --certificate-oidc-issuer carefully.
  • Verify hangs at Searching rekor: rekor.sigstore.dev is unreachable. Fallback: --insecure-ignore-tlog (BUT you lose the transparency check, so not for prod).
  • signature not found: the signature was pushed to one registry, and the image was copied to another without the signature. Use cosign copy src dst (it copies image + signature + attestations).
  • unable to verify signed entity: the fulcio root cert is out of date, update cosign.
  • OIDC failure in CI: permissions: id-token: write was forgotten, or federated identity is not configured in the registry.
  • Air-gap deployment: you need a self-hosted fulcio + rekor or static keys through KMS.
  • Signatures bloat the registry: each image tag adds about +200KB for the signature. Not critical, but noticeable across thousands of tags.

SLSA, a related initiative

SLSA (Supply-chain Levels for Software Artifacts) is a standard of levels for "how well your build is protected". L1 means provenance exists, L2 means it is signed, L3 means the build runs on an isolated builder, L4 means hermetic.

cosign attest with an SLSA predicate is the main mechanism for publishing provenance to satisfy L2/L3 requirements. GitHub Actions plus cosign plus slsa-github-generator gives SLSA L3 out of the box.

Commands

  • cosign sign ghcr.io/myorg/app:v1: Sign an image through keyless OIDC. A browser opens for authentication.
  • cosign sign --key cosign.key ghcr.io/myorg/app:v1: Sign with the static-key variant, for air-gap or without OIDC.
  • cosign verify --certificate-identity foo --certificate-oidc-issuer bar img:tag: Verify a signature with mandatory validation of the signer identity.
  • cosign attest --predicate sbom.json --type spdx ghcr.io/myorg/app:v1: Attach an SBOM as a signed attestation to the image.
  • cosign tree ghcr.io/myorg/app:v1: Show all signatures and attestations associated with the image.
  • cosign copy ghcr.io/myorg/app:v1 internal-registry/app:v1: Copy an image together with its signatures and attestations to another registry.
  • cosign generate-key-pair --kms awskms:///alias/cosign: Generate a key in AWS KMS. The private key never leaves KMS.

See also