Sub topic 4
Where Cosign keeps signatures: OCI registry artifacts
This chapter assumes you can push and pull images with Docker or a similar tool. It also assumes you know what a registry repository is and what a digest is, as covered in the previous chapter. You do not need to have signed anything yet. The goal is to understand where a signature lives, so that signing, verifying, copying and troubleshooting make sense later.
The core idea: a signature is just another artifact
Cosign does not modify your image. An image's digest is the hash of its manifest, so changing the image would change the digest and break everything that refers to it. Cosign instead creates a second, small OCI artifact and pushes it to a registry. That artifact contains the signature and points at the image by digest.
Because the signature is stored as an ordinary OCI artifact, it works with any registry that accepts OCI image manifests. That includes GHCR, Docker Hub, ECR, Artifact Registry and Harbor. Nothing on the registry side needs to know what a signature is.
The default layout: a tag derived from the digest
By default, Cosign pushes the signature into the same repository as the image. It gives the signature a tag computed from the image digest. Take the image digest and replace the colon with a dash. Then append a suffix that says what kind of artifact it is.
| Artifact | Tag in the same repository |
|---|---|
| Signature | `sha256-<hex>.sig` |
| Attestation | `sha256-<hex>.att` |
| SBOM (older attach flow) | `sha256-<hex>.sbom` |
For an image registry.example.com/team/app@sha256:abc123..., the signature is at registry.example.com/team/app:sha256-abc123....sig. The tag is a lookup key. Cosign verifies an image by computing this tag from the digest and pulling it.
This is why the previous chapter stressed digests. The signature is attached to a digest, not to 1.0.0 or latest. If someone later moves the 1.0.0 tag to a different image, the new image has a different digest. Its .sig tag does not exist, so verification fails. A signed image can't be silently swapped under a tag.
Inspecting what Cosign created
You can see these artifacts yourself. The following commands assume IMAGE holds a digest reference, as in earlier chapters, and that the image has been signed.
IMAGE=registry.example.com/team/app@sha256:<digest>
# Print the location where Cosign looks for the signature
cosign triangulate "$IMAGE"
# List the signature, attestation and SBOM artifacts attached to the image
cosign tree "$IMAGE"cosign triangulate prints the ...:sha256-<hex>.sig reference. cosign tree shows every related artifact it can find. If you have crane installed, you can read the raw signature manifest:
crane manifest registry.example.com/team/app:sha256-<hex>.sigThe <hex> is the digest without the sha256: prefix. You can also list the tags and see the signature tags next to your release tags:
crane ls registry.example.com/team/appIf your registry UI shows extra tags ending in .sig after signing, those are the signatures. They are not a bug or leftover junk.
Anatomy of a signature manifest
The signature manifest is a normal OCI image manifest. It has an empty-ish config and one layer per signature. The layer's content is the signed payload, and the signature itself sits in the layer's annotations. A trimmed example looks like this:
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"config": {
"mediaType": "application/vnd.oci.image.config.v1+json",
"size": 233,
"digest": "sha256:<config-digest>"
},
"layers": [
{
"mediaType": "application/vnd.dev.cosign.simplesigning.v1+json",
"size": 250,
"digest": "sha256:<payload-digest>",
"annotations": {
"dev.cosignproject.cosign/signature": "<base64-signature>",
"dev.sigstore.cosign/certificate": "<PEM-certificate>",
"dev.sigstore.cosign/chain": "<PEM-chain>",
"dev.sigstore.cosign/bundle": "<rekor-bundle-json>"
}
}
]
}The layer's media type, application/vnd.dev.cosign.simplesigning.v1+json, marks it as a Cosign signature payload. The annotations carry the rest:
dev.cosignproject.cosign/signatureholds the base64-encoded signature over the payload.dev.sigstore.cosign/certificateanddev.sigstore.cosign/chainappear only for keyless signatures. They hold the short-lived Fulcio certificate and its chain, which a later chapter explains.dev.sigstore.cosign/bundleappears for keyless signatures. It holds the Rekor transparency log entry proof, so a verifier can check it without calling Rekor.
Key-based signatures have only the signature annotation, since there is no certificate.
The payload that gets signed
The layer blob is a small JSON document in the "simple signing" format:
{
"critical": {
"identity": {
"docker-reference": "registry.example.com/team/app"
},
"image": {
"docker-manifest-digest": "sha256:<digest>"
},
"type": "cosign container image signature"
},
"optional": null
}The signature covers these exact bytes. The field that matters is docker-manifest-digest, which binds the signature to your image content. During cosign verify, Cosign does the following:
- Computes the
.sigtag from the digest you passed in. - Pulls the signature manifest and reads each layer.
- Checks the signature annotation against the payload bytes, using your public key or the certificate.
- Confirms the digest inside the payload equals the digest you asked about.
Step 4 stops an attacker from copying a valid signature manifest for image A onto the .sig tag for image B. The signature is valid, but the digest in the payload does not match.
Multiple signatures and concurrent signing
A single image can carry several signatures, for example one from CI and one from a release manager. Cosign adds each new signature as another layer in the same signature manifest. Pushing a new layer changes the manifest, so the signature manifest's own digest changes while its tag stays the same.
Verification succeeds if at least one signature validates against the key or identity you supply. Other signatures on the image are ignored. This is how the approach scales to many signers.
Adding a layer means reading the manifest and pushing a new one under the same tag. Two jobs that sign the same digest at the same moment can race, and one signature may overwrite the other. If you sign the same digest from parallel jobs, serialize them or re-run cosign verify afterward to confirm both signatures landed.
Storing signatures in a different repository
Sometimes you cannot or should not write signatures next to the image. Teams may keep a public image repository read-only, or want signatures in a repository with different access rules. Cosign reads the COSIGN_REPOSITORY environment variable for this:
export COSIGN_REPOSITORY=registry.example.com/team/app-signatures
cosign sign --key cosign.key "$IMAGE"
cosign verify --key cosign.pub "$IMAGE"The signature tag in app-signatures is still derived from the digest of the image you named. Set the same variable when you verify, or Cosign looks in the image's own repository and finds nothing.
Consequences you will run into
Because signatures are separate artifacts with their own tags, several things behave in ways that surprise people.
- Signing needs push access. The identity running
cosign signneeds permission to push to the repository, or to the one named inCOSIGN_REPOSITORY. Reading the image is not enough. - Verifying needs pull access to the signature tag. If a pull-only credential is scoped to specific tags, verification can fail with a "no signatures found" error even though the image pulls fine.
- Copying an image does not copy its signature.
docker pullanddocker push,crane copyandskopeo copymove the image manifest and layers only. The digest stays the same, but the.sigtag stays behind. Usecosign copy SRC DSTto copy the image together with its signatures, attestations and SBOMs. Otherwise, copy the tags yourself or re-sign in the destination. - Tag immutability can block signing. If a registry forbids overwriting tags, adding a second signature to an existing
.sigtag fails. Check the registry's immutability rules. - Cleanup policies can delete signatures. Registry lifecycle rules that remove "untagged" or old tags may treat
.sigand.atttags as clutter. Deleting them leaves a running image with no verifiable signature. Exempt these tags in your retention rules. - Multi-architecture images have two levels of digest. A multi-platform image has an index digest and a digest per platform manifest. Sign the digest you will deploy, and verify that same one. Signing the index covers the index digest, not each platform manifest by itself.
A note on newer storage modes
The tag-based layout above is the long-standing default and works everywhere. The OCI 1.1 specification adds a referrers API, where a registry lists artifacts that point at a given digest through a subject field. This removes the need for the sha256-<hex>.sig naming convention. Registries that don't support the API fall back to a tag of the form sha256-<hex> that holds an index of referrers. Recent Cosign releases can use referrers and newer bundle formats, and the defaults have changed between major versions.
Check cosign version and the release notes for the version you run. Signing with one storage mode and verifying with a tool that expects another is a common cause of "no signatures found". The rest of this tutorial uses the tag-based layout, since it is easy to inspect with the commands above.
Exercise
You signed registry.example.com/team/app@sha256:aaa... and verified it successfully. A colleague then runs crane copy to copy that image to registry.internal/team/app and runs cosign verify --key cosign.pub registry.internal/team/app@sha256:aaa..., which reports no signatures found. What happened, and what are two ways to fix it?
Show answer
The image digest is the same, but crane copy copied only the image manifest and layers. The sha256-aaa....sig tag stayed in the source repository, so Cosign finds nothing at the destination. Fix it by copying with cosign copy so the signature artifacts move too, or by signing the image again in the destination repository. Setting COSIGN_REPOSITORY to point at the source signature repository also works.
Exercise
Why does moving the 1.0.0 tag to a different image cause cosign verify of a digest reference to still succeed for the original image, but verification of the new image to fail?
Show answer
The signature tag is derived from the digest, and the signed payload contains that digest. The original image's digest is unchanged, so its .sig artifact is still found and valid. The new image has a different digest, so no matching .sig tag exists for it, and verification finds no signature.