Sub topic 8
Verifying who signed: certificate identity and issuer
This chapter assumes you can push images to a registry, know what a digest is, and have seen keyless signing with cosign sign. You should also know that a signature proves a private key signed some data, and nothing more.
Why a valid signature is not enough
With keyless signing, anyone with an OIDC account can obtain a Fulcio certificate and sign an image. An attacker with a free account can sign a malicious image, and the signature will be cryptographically valid. Verification must therefore answer a second question: who signed it?
Cosign answers this by reading the Fulcio certificate attached to the signature. The certificate carries two facts you can check:
| Field | Meaning | Cosign flag |
|---|---|---|
| Subject Alternative Name (SAN) | The identity that logged in, such as an email or a workflow URL | `--certificate-identity` |
| OIDC issuer extension | The provider that vouched for that identity | `--certificate-oidc-issuer` |
Both values are needed. The same identity string can exist at different providers, so the issuer pins down which provider made the claim.
Exact match for a person
The simplest case is a human signer:
cosign verify \
--certificate-identity [email protected] \
--certificate-oidc-issuer https://accounts.google.com \
"$IMAGE"If either value differs by even one character, verification fails. Cosign requires you to supply an identity and an issuer. It will not guess them.
Exact match for a CI workflow
For a GitHub Actions signer, the identity is not an email. It is the URL of the workflow file plus the Git ref that ran it. The issuer is the GitHub Actions token service.
cosign verify \
--certificate-identity https://github.com/OWNER/REPO/.github/workflows/build.yml@refs/heads/main \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
ghcr.io/OWNER/REPO@sha256:<digest>This pins three things: the repository, the workflow file, and the branch. A fork, a different workflow, or a feature branch gets a different identity and fails the check.
Matching with regular expressions
Sometimes the ref changes, for example when you sign release tags. Cosign offers regular-expression variants of both flags:
cosign verify \
--certificate-identity-regexp '^https://github\.com/OWNER/REPO/\.github/workflows/build\.yml@refs/(heads/main|tags/v.*)$' \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
ghcr.io/OWNER/REPO@sha256:<digest>Anchor the expression with ^ and $, and escape dots. An unanchored pattern such as github.com/OWNER can match https://evil.example/github.com/OWNER. Prefer exact flags whenever the identity is known in advance.
Inspecting what was signed
To see the identity that actually signed an image, decode the certificate from a verification result. Run verification with the flags you expect, then read the output:
cosign verify \
--certificate-identity-regexp '.*' \
--certificate-oidc-issuer-regexp '.*' \
"$IMAGE" | jq '.[0].optional'The optional section shows the issuer, the subject, and, for GitHub Actions, extra claims such as the repository and commit. Use this only for investigation, then copy the exact values into your real verification command.
Common errors
no matching signatures: the image has no signature, or you passed a tag whose digest changed. Verify by digest.none of the expected identities matched: the identity or issuer differs from the certificate. Check the ref (refs/heads/mainversusrefs/tags/v1.0.0) and the workflow file path.certificate-identity or certificate-identity-regexp is required: you ran a keyless verification without identity flags.- Verification with
--keyfails on a keyless image: keyless signatures have no long-lived public key to supply. Use the identity flags instead.
Exercise
A teammate verifies images with --certificate-identity-regexp 'github.com/acme/app' --certificate-oidc-issuer https://token.actions.githubusercontent.com. Name two problems with this check and give a better command for an image built by .github/workflows/release.yml on main in acme/app.
Show answer
The pattern is unanchored, so a string like https://evil.example/github.com/acme/app also matches. It also does not pin the workflow file or branch, so any workflow or ref in that repository passes. A better command is cosign verify --certificate-identity https://github.com/acme/app/.github/workflows/release.yml@refs/heads/main --certificate-oidc-issuer https://token.actions.githubusercontent.com ghcr.io/acme/app@sha256:<digest>.