Sub topic 8
Verifying who signed: certificate identity and issuer
This chapter assumes you can build and push an image to a registry, you know what a public/private key pair and a signature are, and you have run cosign sign once in keyless mode. If not, read the keyless signing chapter first.
Why a valid signature is not enough
With key-based signing, cosign verify --key cosign.pub answers one question: was this signature made by the private key that matches this public key? You decide whom to trust by choosing which public key to pass in.
Keyless signing has no long-lived key to pass in. Each signature is made with a throwaway key, and Fulcio issues a short-lived certificate that binds the public key to an identity. Fulcio is the Sigstore certificate authority. The identity comes from an OIDC token, which is a signed statement from an identity provider such as Google, GitHub or Microsoft.
This changes what "valid" means. Anyone with a Google account can obtain a Fulcio certificate and sign an image. If your verifier only checks that the certificate chains to Fulcio, it accepts signatures from every one of those people. So keyless verification has to include a second check: does the certificate name the signer you expect?
Treat the identity check as the trust decision. The Fulcio chain and the Rekor entry prove that a signature is genuine and was recorded. The identity pins down who made it.
What is inside the certificate
A Fulcio certificate is a standard X.509 certificate. Cosign reads two pieces of information from it:
- The subject, stored in the Subject Alternative Name (SAN) extension. It is the identity of the signer. For a person it is usually an email address. For a CI job it is a URL that identifies the workflow file and the Git reference.
- The issuer, stored in a Fulcio-specific extension. It is the URL of the OIDC provider that authenticated the signer.
Both values are needed. An email address like [email protected] means different things at different providers. The issuer tells you which provider vouched for that address, and so which organisation controls it.
| Signer | Certificate identity (subject) | OIDC issuer |
|---|---|---|
| A person using Google login | `[email protected]` | `https://accounts.google.com` |
| A GitHub Actions workflow | `https://github.com/OWNER/REPO/.github/workflows/build.yml@refs/heads/main` | `https://token.actions.githubusercontent.com` |
| A Google Cloud service account | `[email protected]` | `https://accounts.google.com` |
The verification flow
When you run cosign verify on a keyless signature, Cosign does the following:
- Resolves the image reference to a digest and finds the signature artifact stored beside it in the registry.
- Extracts the certificate and checks that it chains to the Fulcio root of trust.
- Checks the signature over the image payload using the public key in the certificate.
- Looks up the matching entry in the Rekor transparency log and checks that the entry's timestamp falls inside the certificate's short validity window. This is how a certificate that expired minutes after signing can still be accepted later.
- Compares the certificate subject and issuer with the values you supplied.
If any step fails, Cosign exits with a non-zero status and prints no verified payload.
Pinning identity and issuer
The two flags that carry the trust decision are --certificate-identity and --certificate-oidc-issuer. Use them together.
cosign verify \
--certificate-identity [email protected] \
--certificate-oidc-issuer https://accounts.google.com \
"$IMAGE"Both flags require an exact string match. Cosign will not guess, and since version 2 it refuses to run a keyless verification without an identity and an issuer constraint. Older tutorials that call cosign verify "$IMAGE" with no flags describe behaviour that no longer works.
For a CI signer, pin the full workflow path and branch:
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 says: accept only signatures made by the build.yml workflow in OWNER/REPO, running on main, authenticated by GitHub Actions. A signature from a fork, another workflow or a feature branch has a different subject and fails.
Exact match versus regular expressions
Exact strings are the safest choice, but they are awkward when the Git reference changes. Release workflows often run on tags such as refs/tags/v1.2.3. For these cases Cosign offers regular-expression variants:
--certificate-identity-regexp--certificate-oidc-issuer-regexp
cosign verify \
--certificate-identity-regexp '^https://github\.com/OWNER/REPO/\.github/workflows/release\.yml@refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$' \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
"$IMAGE"Write the expression carefully:
- Anchor it with
^and$. An unanchored pattern can match inside a longer, attacker-controlled string. - Escape dots. An unescaped
.matches any character, sogithub.comwould also matchgithubXcom. - Be specific about the repository owner and name. A pattern such as
https://github.com/.*accepts every repository on GitHub, which defeats the check. - Keep the issuer exact when you can. Only loosen the part that really varies.
Picking the right identity to trust
The identity you pin should be as narrow as your release process allows. Compare these options for a GitHub-built image:
| Pinned identity | What it accepts | Risk |
|---|---|---|
| Exact workflow path on `refs/heads/main` | Only the release workflow on the main branch | Lowest. Needs updating if you move the workflow. |
| Workflow path with a tag regexp | The release workflow on version tags | Low, if tag creation is restricted by branch or tag protection. |
| Repository prefix regexp | Any workflow on any ref in the repository | Medium. Anyone who can push a branch can sign. |
| Issuer only, any identity | Anyone using that provider | Unacceptable for production. |
The narrower options only hold if the repository itself is protected. If any contributor can edit build.yml on a branch and then merge it, the identity is only as trustworthy as your branch protection and review rules. Cosign checks who signed. It does not check whether the workflow was reviewed.
Reading what Cosign verified
On success, Cosign prints a JSON array. Each element has a critical section naming the image digest, and an optional section that carries the certificate details, including the subject and issuer. You can extract them with jq:
cosign verify \
--certificate-identity [email protected] \
--certificate-oidc-issuer https://accounts.google.com \
"$IMAGE" 2>/dev/null | jq -r '.[0].critical.image."docker-manifest-digest"'Compare the printed digest with the one you expected. The critical.image field is what the signature actually covers. If you verified a tag and the tag moved, this digest shows what you really checked. That is one more reason to verify by digest.
Common errors
| Message or symptom | Likely cause | Fix |
|---|---|---|
| `none of the expected identities matched what was in the certificate` | The subject or issuer differs from your flags. The error lists the values found in the certificate. | Compare the listed values with your flags. Check for a different branch, workflow file name, or trailing characters. |
| `no matching signatures` | No signature exists for this digest, or you passed a different digest than the one signed. | Confirm the signed digest. Check that the signature was pushed to the same repository. |
| `expected identity ... and issuer` flags missing | You ran a keyless verification with no constraints. | Add `--certificate-identity` and `--certificate-oidc-issuer`, or their regexp forms. |
| Identity matches locally but fails in a cluster policy | The policy uses a different issuer string or a regexp that is too strict. | Print the certificate values with the successful local command, then copy them into the policy. |
| Verification fails for a signature made when the workflow ran on a tag | You pinned `refs/heads/main` but the job ran on `refs/tags/...`. | Pin the reference the job actually ran on, or use a regexp for tags. |
When a mismatch happens, read the error output first. Cosign prints the identity and issuer that it found, and that value is usually the quickest route to the fix. Do not paste the found values into your flags without asking whether you trust them.
Checks that complement identity
Identity pinning answers "who". Combine it with other checks when risk calls for it:
- Verify by digest, so that the signature is bound to specific content.
- Use
--certificate-github-workflow-repositoryand related flags to check GitHub-specific certificate extensions, such as the repository or the workflow trigger. - Verify attestations as well as signatures when you need claims about how an image was built.
- Keep the Rekor check enabled. Skipping it removes the proof that the signature existed during the certificate's validity window.
Exercise
A teammate verifies an image with --certificate-oidc-issuer https://token.actions.githubusercontent.com and --certificate-identity-regexp 'https://github.com/.*'. Verification succeeds. Why is this not a safe release check, and what would you change?
Show answer
The regexp is unanchored and matches any repository on GitHub, so a workflow in any user's repository, including an attacker's, produces a certificate that passes. The issuer check only proves the token came from GitHub Actions. Change it to an exact identity or an anchored, escaped regexp that names the owner, repository, workflow file and ref, for example ^https://github\.com/OWNER/REPO/\.github/workflows/release\.yml@refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$.
Exercise
You sign an image from a workflow on refs/heads/main. Later cosign verify fails and reports a certificate identity ending in @refs/heads/feature-x. What happened, and should you fix the verify command?
Show answer
The image was signed by a run on the feature-x branch, not on main. The verify command did its job by rejecting a signer outside the pinned identity. Do not loosen the flags. Find out why the feature branch signed an image you intended to release, then re-run the release from main and verify that digest.