Skip to content

OCPNODE-2018: Add OCI Referrers API support for signature discovery - #1111

Open
saschagrunert wants to merge 1 commit into
podman-container-tools:mainfrom
saschagrunert:ocpnode-2018-referrers-api
Open

OCPNODE-2018: Add OCI Referrers API support for signature discovery#1111
saschagrunert wants to merge 1 commit into
podman-container-tools:mainfrom
saschagrunert:ocpnode-2018-referrers-api

Conversation

@saschagrunert

@saschagrunert saschagrunert commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Ref #221

Add support for the OCI Distribution Spec 1.1 Referrers API for both reading and writing sigstore signatures.

Reading: Query GET /v2/<name>/referrers/<digest> with pagination support, fall back to the referrers tag schema for registries without native API support, filter by sigstore artifact types, and deduplicate signatures found across both the referrers and cosign tag sources.

Writing: Push each sigstore signature as an individual OCI artifact manifest with a subject field pointing to the target image. Uses an empty config (application/vnd.oci.empty.v1+json) and the signature payload as a single layer. Deduplicates by precomputing the artifact manifest digest and checking against existing referrers before uploading. Maintains the referrers tag schema index for registries without native API support. The referrers write is best-effort so a failure does not block the established cosign tag path.

Both paths are gated on the existing use-sigstore-attachments flag in registries.d configuration.

Consumer PRs for CI testing:

@github-actions github-actions Bot added the image Related to "image" package label Aug 24, 2026
@saschagrunert
saschagrunert force-pushed the ocpnode-2018-referrers-api branch 4 times, most recently from 8e22885 to 4930321 Compare August 24, 2026 15:12
@saschagrunert
saschagrunert marked this pull request as ready for review August 24, 2026 15:12

@mtrmac mtrmac left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I do think we need this support.

A literally 2-minute look.

Once we add this, I think we need to add write support as well; e.g. skopeo copy needs to not break validity of signed images.

That might need a registries.d configuration option to choose which destination to use. (And then we need to be rather careful about “amplification”, we should not end up with repeated copies of the same image adding an unbounded number of signature objects, e.g. if each copy read from old+new APIs and wrote all signatures to new, we might be adding the “old” signatures to the new API on every copy.)

Comment thread image/docker/docker_image_src.go Outdated
Comment on lines +794 to +795
// where signers publish via both mechanisms, duplicate signatures may appear. This is acceptable
// because signature consumers handle duplicates gracefully.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, yes — but IIRC the OpenShift integrated registry has a pretty small limit (because the signatures are stored in the API server) that is not difficult to hit. Is that going to be a problem?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Changed to use the cosign tag path only as fallback: if the Referrers API (or its tag schema fallback) finds signatures, the legacy cosign tag is skipped entirely. This avoids duplicates and the extra network request.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s not obviously correct… what happens if, for a digest with referrer signatures, an old version of skopeo copy --sign-by-sigstore… adds new signatures, to the cosign path?

I haven’t spent much time thinking about this but I think we will need to actually deduplicate individual objects. (And for writes… I don’t know, that’s harder. Leave all existing signatures as they are? Implement an option to write everything to referrers? (to write everything to cosign-v2 tags, as well?)?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the approach: both referrers and the cosign tag path are now always checked, and signatures are deduplicated by content digest afterward (deduplicateSigstoreSignatures hashes each signature's serialized blob). This handles the case where an old skopeo adds new signatures to the cosign path while referrers already exist.

For the write side, I agree that's a separate concern. I'd suggest handling it in a follow-up: leave existing signatures as they are for now, and add a registries.d option for choosing the write destination later.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the write side, I agree that's a separate concern.

To be clearer I think the missing write support is a blocker for merging this; not something that can wait.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, write support has been added now. Signatures are pushed as individual OCI artifact manifests with subject, empty config, and the payload as a single layer. Dedup by precomputed manifest digest, tag schema index maintained for non-native registries. The referrers write is best-effort to avoid blocking the cosign tag path.

Comment thread image/docs/signature-protocols.md Outdated
@saschagrunert
saschagrunert force-pushed the ocpnode-2018-referrers-api branch from 4930321 to 594894b Compare August 24, 2026 15:15

@harche harche left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. Could you add unit tests for the cases called out inline, including Referrers pagination via Link?

Comment thread image/docker/docker_client.go Outdated
Comment thread image/docker/docker_image_src.go
@saschagrunert
saschagrunert force-pushed the ocpnode-2018-referrers-api branch 7 times, most recently from 71276f9 to 65b5097 Compare August 25, 2026 07:39
@saschagrunert
saschagrunert force-pushed the ocpnode-2018-referrers-api branch 3 times, most recently from b5a0eb5 to 42b2aa0 Compare August 26, 2026 07:07
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

image Related to "image" package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants