Sub topic 4
Where Cosign keeps signatures: OCI registry artifacts
This chapter assumes you can push and pull images, know that a digest identifies image content, and have signed an image with Cosign at least once. It explains where the signature goes after cosign sign runs. That knowledge helps when a signature "disappears" after an image is copied or a registry cleanup runs.
Signatures are separate artifacts
Cosign does not modify your image. An image digest covers the manifest and its layers, so changing the image would change the digest you just signed. Cosign instead pushes a second OCI artifact into the same repository. That artifact holds the signature and points at the image by digest.
The tag convention
To find the signature, Cosign takes the image digest and builds a tag from it. It replaces the colon with a dash and appends .sig. An image at sha256:3f2a... gets a signature at :sha256-3f2a....sig in the same repository.
You can ask Cosign for this location with cosign triangulate, and list everything attached to an image with cosign tree.
IMAGE=registry.example.com/team/app@sha256:<digest>
# Print the signature location Cosign will look up
cosign triangulate "$IMAGE"
# List signatures, attestations and SBOMs attached to the image
cosign tree "$IMAGE"Because the lookup starts from a digest, a tag such as :1.0.0 is first resolved to a digest. This is another reason to sign and verify by digest.
What is inside the signature artifact
The signature artifact is an ordinary OCI image manifest. You can read it with any registry client. This example uses crane, a separate tool from Cosign.
SIG=$(cosign triangulate "$IMAGE")
crane manifest "$SIG"The manifest has these parts:
- One layer, whose blob is a small JSON "simple signing" payload. It records the image's digest and repository.
- An annotation
dev.cosignproject.cosign/signaturewith the base64 signature over that payload. - For keyless signatures, annotations that carry the Fulcio certificate and its chain.
- Often an annotation with a bundle, which includes proof from the Rekor transparency log.
Verification downloads this artifact. It checks that the payload's digest matches the image you asked about, then checks the signature, and for keyless signatures the certificate.
Each new signature on the same image is added as another layer in the same .sig artifact. The artifact holds the signatures for that image, so several signers can sign one digest.
Failure modes
The signature lives in the registry, so anything that handles registry content can lose it.
| Situation | Effect | Fix |
|---|---|---|
| `docker pull` then `docker push` to another registry | Only the image moves. The `.sig` tag stays behind. | Use `cosign copy` or `crane copy` for the `.sig` tag too |
| Cleanup policy deletes untagged or old tags | The `.sig` tag may be removed, and verification then fails | Exempt `.sig` tags from retention rules |
| Registry rejects unknown media types | `cosign sign` fails on push | Use a registry that supports OCI artifacts |
| Signature kept in a different repository | `cosign verify` reports no signatures found | Set `COSIGN_REPOSITORY` consistently when signing and verifying |
# Copy an image together with its signatures
cosign copy registry.example.com/team/app:1.0.0 mirror.example.com/team/app:1.0.0
# Keep signatures in a dedicated repository
export COSIGN_REPOSITORY=registry.example.com/team/app-signatures
cosign sign --key cosign.key "$IMAGE"Exercise
You mirror an image with docker pull and docker push to a second registry. cosign verify succeeds on the original but reports "no signatures found" on the mirror. Why, and how do you fix it?
Show answer
The signature is a separate artifact tagged sha256-<digest>.sig in the original repository. docker pull and docker push copy only the image, so the mirror has no signature artifact. Copy the image with cosign copy (or crane copy for both the image and its .sig tag), or sign the image again in the mirror's repository.