Repository navigation
Description
OCI References
New March 27th 2021: The Testing section below now shows some validation to attempt to prove that this does not break existing clients.
New March 28th 2021: The Backwards Compatibility section contains how I'm defining backwards-compatibility for the purposes of this proposal.
Background
This document contains two high level proposals that allow for artifacts in a registry to be linked together.
They are meant to be mostly equivalent to the linking portion of the proposed OCI artifact manifest changes.
This document takes a different approach in a few areas:
- Backwards compatibility with existing types. We allow for the existing types (Image, Index, Descriptor) to reference each other and to be referenced, rather than only supporting the new ArtifactManifest type. Backwards compatibility is defined in more detail below.
- No other changes are included here (renames, reorganization). These proposals represent the bare minimum format and API changes required to enable linking of objects, including in a registry. While some of the renaming/reorganization may be desirable, it is also less critical and may be a point of contention that could further delay this work.
Additionally, this document contains further design and discussion for the "query" portion of the API.
This should be compatible with the OCI artifact manifest changes, and can serve as inspiration or as an addition to that proposal if we decide to move forward with that change (either instead of or in addition to this one).
We start out with the proposed API and format changes, then discuss the requirements they were designed against and the CUJs they address.
Proposed Design
This proposal accompanies a pull request which contains the actual proposed changes to the specifications and types in this repository.
We propose adding a new field and a new GET API (in the distribution-spec).
Each change is described below.
Image Spec
Refer to the linked PR for the full changes.
We propose adding a new field (reference) to the Image Manifest, Index and Descriptor types.
This field will contain a Descriptor that points to the linked object.
Here is an example:
{
"mediaType": "application/vnd.example.signature+json",
"size": 3514,
"digest": "sha256:19387f68117dbe07daeef0d99e018f7bbf7a660158d24949ea47bc12a3e4ba17",
"reference": {
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"size": 1201,
"digest": "sha256:b4f9e18267eb98998f6130342baacaeb9553f136142d40959a1b46d6401f0f2b"
}
}Distribution Spec
We propose adding a new, read-only API to the Distribution Spec to query the registry for references to a given object.
The API will look like:
GET /v2/<name>/manifests/<ref>/references
The response from this API will be a list of Descriptors that matches the existing Manifest Index specification:
{
"manifests": [
{
"mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
"size": 1201,
"digest": "sha256:b4f9e18267eb98998f6130342baacaeb9553f136142d40959a1b46d6401f0f2b"
}
]
}
There will be an accompanying PR to the distribution-spec with more details on this API if we decide to move forward.
It is currently located here to keep the entire proposal in one place.
Requirements
The proposal above was designed with the following requirements in mind.
There was also an overarching constraint to make these API changes as small as possible, but no smaller:
- Able to attach multiple notes/references to an existing object
- Able to query the registry for all notes/references attached to a specific object
- Attaching notes/references DOES NOT mutate the initial object
- Notes/references should be able to be copied with an image between repositories
- Simple to understand
- Simple to implement
Backwards Compatibility
Updated March 28th
There is no formal definition for backwards-compatible changes in this repo. Here's how I'm thinking about it:
- A reference-aware client can push objects with the reference field to reference-aware servers
- A reference-aware client can retrieve objects that have the references-field set from reference-aware servers.
- A reference-aware client should be able to push objects with the reference field to non-reference-aware servers as per https://github.com/opencontainers/image-spec/blob/master/considerations.md#extensibility, but if servers fail/error here instead this is still fine.
- A non-reference aware client can pull objects that have the references-field set from reference-aware servers, without erroring. They should not break, and should simply ignore the field.
The final bullet here is the most important one. If clients break because of a new field being present, this is not backwards-compatible.
I've verified the following clients so far:
- Oras v0.11.1
- Docker 20.10.5
- Crane v0.4.1
Please suggest others!
Testing
New March 27th 2021
I've implemented this in a patch to distribution as a testbed to try to validate whether or not clients get broken with this. My patch is here: https://github.com/dlorenc/distribution/tree/references, and a registry image is available here: gcr.io/dlorenc-vmtest2/registry:references
You can pull and run that with:
docker run -p 5000:5000 gcr.io/dlorenc-vmtest2/registry:references
I made a client to test this with. It's available in a patch to ggcr here: https://github.com/dlorenc/go-containerregistry/tree/references
There's a simple command line tool to create an object that refers to another object. With that code checked out, and the registry running, you can do:
# Copy an image into your local registry for testing
$ go run ./cmd/crane/ cp ubuntu localhost:5000/ubuntu
# Add a reference to it!
$ go run ./cmd/ref localhost:5000/ubuntu localhost:5000/ref-to-ubuntu
Creating a reference to image: localhost:5000/ubuntu at: localhost:5000/ref-to-ubuntu
# Look at the glorious, referring manifest (the object here is just ubuntu as well, so we can run it)
$ go run ./cmd/crane manifest localhost:5000/ref-to-ubuntu | jq .
{
"schemaVersion": 2,
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"config": {
"mediaType": "application/vnd.docker.container.image.v1+json",
"size": 2724,
"digest": "sha256:01b9e61b93fb6b71b7278bc7a7e8a21417536169cc7c8df18f07c0774539fd69"
},
"layers": [
<hidden for brevity>
],
"reference": {
"mediaType": "application/vnd.docker.distribution.manifest.v2+json",
"size": 943,
"digest": "sha256:c65d2b75a62135c95e2c595822af9b6f6cf0f32c11bcd4a38368d7b7c36b66f5",
"platform": {
"architecture": "amd64",
"os": "linux"
}
}
}
# Now run it!
$ docker run -it localhost:5000/ref-to-ubuntu
Unable to find image 'localhost:5000/ref-to-ubuntu:latest' locally
latest: Pulling from ref-to-ubuntu
Digest: sha256:011b3069012baf7f4a8a7f7eea5b0a545d6cd98127e1a3651513ba88e983b246
Status: Downloaded newer image for localhost:5000/ref-to-ubuntu:latest
root@8876f9f8c13f:/# It works!
Example Use Cases
Signing and verifying an image
Signing:
- User creates some payload representing the image.
- User signs this payload.
- User creates an Image containing this signature, with a meaningful
mediaTypefor this signature. This signature must contain a protected reference to the subject. - User uploads this via the normal upload flow.
Verification:
- User locates the object they wish to verify signatures for.
- User queries the new
GETAPI for references - User iterates through this looking for signature objects with the expected
mediaType - User verifies the attached signature (and included protected reference)
Attaching SBOMs to an artifact
to be filled in
More
Add more here!
Registry Implications
Registries may need to maintain a reverse index to efficiently satisfy queries for references to a given object.
Registries will need to parse and understand reference fields in order to support this.
Registries are free to implement garbage collection of referenced objects as they see fit.
Alternatives Considered
Registry only changes
We also considered proposing a design where references are NOT included on the existing types.
It would have looked like:
GET /v2/<name>/manifests/<ref>/notes
POST /v2/<name>/manifests/<ref>/notes
PUT /v2/<name>/manifests/<ref>/notes
DELETE /v2/<name>/manifests/<ref>/notes
Pros
This would not require changes to the image spec
Cons
- Requires more changes to the registry API and registries
- Only works in a registry context, does not work on a filesystem or OCI layout
- Unclear how this would work when copying objects between registries, which is a critical requirement
Activity
sargun commentedon Mar 17, 2021
Why include the size of the reference?
jonjohnsonjr commentedon Mar 17, 2021
sizeis a REQUIRED descriptor property, so we need to include it, but it's the size of the thing being referenced.Looking at this example:
{ "mediaType": "application/vnd.example.signature+json", "size": 3514, "digest": "sha256:19387f68117dbe07daeef0d99e018f7bbf7a660158d24949ea47bc12a3e4ba17", "reference": { "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json", "size": 1201, "digest": "sha256:b4f9e18267eb98998f6130342baacaeb9553f136142d40959a1b46d6401f0f2b" } }The outer descriptor is pointing to a signature of size
3514and the "subject" of that signature is the manifest list thatreferencepoints to, which is1201bytes.(For posterity), the thing being referenced happens to be
ubuntu:latestcurrently:jonjohnsonjr commentedon Mar 18, 2021
Some things I'm personally unsure about for this proposal:
plurality
The current proposal adds a singular
referenceto descriptors and image/index objects. I think this is cleaner in most cases, but it's not as concise as a list ofreferencesin certain situations.With a singular
reference, it's somewhat cumbersome to express "this manifest references M targets".naming
I like
reference(orreferences) but it's pretty abstract. If we had something slightly more concrete likesubject, I think it's easier to understand as "thesubjectdescriptor points to the subject of this content", whereasreferencecould mean anything. On the other hand,subjectmight be limiting because it's too specific, whereasreferencecould mean anything, which makes it potentially more useful.Certainly open to ideas here.
dlorenc commentedon Mar 18, 2021
I agree - but resisted making it plural because I couldn't think of a single concrete use-case for it. If anyone has any we can definitely make this plural.
imjasonh commentedon Mar 18, 2021
In addition to @jonjohnsonjr 's answer, including the size can avoid DoS attacks on services that will chase these references.
A service can look at the descriptor upfront and say "that size is too big, I'm going to stop here." Or if it decides to read the referenced blob and it turns out to be bigger than it said it would be, the service can say "this blob is bigger than it said it would be, I'm going to stop here" and avoid large responses exhausting resources.
jonjohnsonjr commentedon Mar 18, 2021
Exactly. Here's a scenario I would imagine is prevented by this:
You've been compromised such that there is a MITM between your client and the registry. Fortunately for you, you are smart and deploy everything by digest, so the attacker can't serve you arbitrary images (say, a bitcoin miner). One obvious thing the attacker can still do is just not let you pull the images, but this would likely be easily detected because your deployments would fail. Similarly, they could act as a proxy registry and just serve you images really slowly. This would be annoying, but eventually pulls would succeed or timeout. If they wanted to be even more disruptive, they could try to take down not just one service but everything on the node by flooding your disk with garbage data. If the
sizeof the content you're fetching is unknown, the attacker could set an arbitrarily largeContent-Lengthin the response and feed your client random data until you run out of disk space. By including thesizein the descriptor, we guarantee that clients know exactly how much data they should expect to fetch.sudo-bmitch commentedon Mar 22, 2021
A few that I can think of based around the image signing work.
Note with a plurality of references, GC should only prune the signature artifact when all of those references no longer exists, and not if just one of them is deleted, since the signing data for other images is still valid and useful.
There's also been discussions on Helm artifacts, and one helm chart may include references to multiple images. I'm still not sold on this particular example because you're including a fixed reference to a potentially mutable template, but the logical grouping of one artifact pointing to multiple manifests by a single artifact applies to a larger context of use cases.
sudo-bmitch commentedon Mar 22, 2021
It feels a little forced to add this to the Descriptor object, requiring an extra blob to be uploaded to create a reference. One of the advantages of the Artifact proposals is the ability to upload an artifact that is just references and perhaps some annotations, allowing the entire artifact to be pulled with a single request, rather than moving the annotation data into a separate config blob that gets pushed separately. Logically, it feels like the wrong level. You want the reference on the artifact, not on a blob or config object shipped with the artifact.
One of the controversial changes I had pushed Steve to add to the Artifact spec was the ability to inline the artifacts as part of the query response. The reason for inlining results, rather than just a list of manifests, is because the number of signatures can grow on any one image. It may be periodically resigned, and it could be signed by many entities. Those entities may be different organizations (ACME Rockets resigns the image they pulled from Wabbit Networks to use the Notary example). However they could also be done as a proof that an approval was received in a larger organization, showing that the image has passed one of several security checks from things like an image scanning tools. Most clients won't care about all of these signatures, they are looking for a single one from a known entity, that can hopefully be identified by the annotations on the signing artifact. And by inlining the results, we can turn a worst case of n x 2 pulls for signatures (where n is the number of signatures) down to a fixed 2 pulls (one for the inlined list of artifacts, one for the signature blob).
If we decide not to allow inline results, then allowing a query that filters on media type and annotations could allow this to be done on the server rather than the client sorting through the results for the desired annotations, giving us a fixed 3 pulls (one for the query, one for the signature artifact, and a final one for the signature blob).
dlorenc commentedon Mar 22, 2021
So this would sort of turn the conceptual model from "here is a list of signatures all tied to one object" over to "here is a list of signatures tied to many objects". That could make sense if you had a set of signatures that referenced a large set of images, but the signatures all had a similar lifecycle tied to each other or the key, rather than to the images they reference, like you suggested.
I'm still not convinced though - allowing this option forces people to decide up front how their signatures will be managed later. A list gives flexibility, but flexibility could create confusion. Some can be updated by themselves, some are updated by doing a "read modify update" loop on a larger "multi-signature-set" object.
I think that would be handled by downloading the Index, signing and uploading a signature for each Manifest, then signing and uploading one for the Index itself (so the overall index is signed, and each platform's manifest is signed). I'm not sure I follow the issue. Signed tags are a separate problem.
I think this is solved by the #826 proposal - the signatures can be inlined directly in the Data field of the descriptor.
I'd love both! Inlining signatures on the data field and better querying. We still don't have basic list support cross-registry, so I'd rather get something we can use first then push for better querying. Performance optimizations and the fields we'd like to query on feel premature to me still. We don't know how people will use these new fields in the real world, we can only guess.
A final note: I do like the idea of the Artifact spec. It addresses a lot of issues in the registry today. The downside, is that it addresses a lot of issues in the registry spec. It's going to take a LONG time to get accepted and supported by registries. I don't think we should have to wait for that to add improvements to the existing types.
sudo-bmitch commentedon Mar 22, 2021
An important part of both this and the artifact spec is the ability to query for artifacts linked to another artifact or manifest. That's a new API that needs to be added to make this work. As soon as we take that leap, this is no longer something we can shoehorn into existing registries, so we may as well come up with the solution that makes the most logical sense.
dlorenc commentedon Mar 22, 2021
This proposal also includes an API for linking that works for all types. I don't think all new features will be equivalent in terms of cost to roll out. This proposal was specifically designed to minimize changes required to registries.
Nothing precludes more support for filtering/querying later on.
dlorenc commentedon Mar 22, 2021
Wait - I think I misunderstood what you're saying about the "list attached objects" API. To make sure I understand:
My proposal currently returns a list of "pointers" to attached objects, where the pointers are descriptors. You're asking for an option to instead "deference" those pointers, where the returned list would be the actual full objects themselves.
Is that roughly correct?
sudo-bmitch commentedon Mar 22, 2021
I'm looking to make the queries faster, so inlining the content a descriptor points to with a dereference. If #826 allows the server to build a descriptor with the content dereferenced into the data field, then that solves my issue. But it's not clear whether this is a server (on a query) or client (on a push) generated field.
dlorenc commentedon Mar 22, 2021
Right - I think the two are actually complementary. The only challenge I can think of here with inlining data in the list response will be clients now knowing what the data types are ahead of time. It works in the artifact manifests API because referencing objects can only be one type: the artifact type.
sudo-bmitch commentedon Mar 22, 2021
If you have the descriptor, you'll have the media type and can parse the base64 encoded bytes based on that media type. Whether the content/data is unlined, I always want the descriptor with those details to both verify the decoded bytes, and to allow individual blob pulls later (e.g. head request to verify blob still exists for mirror updates).
38 remaining items
SteveLasker commentedon Jun 10, 2021
@nishakm:
This is the model being proposed in the reference type working group <- link is the visual version of PR#29 -but is easier to read
With more details here:
@jonjohnsonjr
We discussed weak references in PR#27, and it got pretty thrashed that weak references wasn't something we should pursue, at least not yet. I actually like the weak reference model, in addition to the hard references model, as it enables Helm Chart references to images in other repos, but I figured I'd reduce the scope and focus on the immediate needs for hard references PR#29.
Is this suggesting that adding a signature or sbom to the
net-monitor:v1image would prevent the deletion of thenet-monitor:v1image?The terminology does get confusing. Using names of things helps. The links above tried to address the confusion by using example names with imagery to visualize.
@michaelb990
The key thing is thinking and asking questions, so we all get smarter about the issues. Whether this is the right place for this discussion is a larger issue, but the questions and thoughts are great.
I've been trying to treat GC similar to auth. The spec doesn't call out authentication, but it's designed with the understanding that all registries implement some level of auth, for at least push, if not pull for private registries. The thought process is we design these apis with the understanding of how they'd be used, and make sure they can be used for the identified, most common scenarios. Leaving room for registries to do added value, but above a common expectation.
jonjohnsonjr commentedon Jun 10, 2021
What you are proposing is, in fact, a weak reference from a signature to an image. Can you explain what you mean by hard and weak references? It seems to diverge from how these terms are used in the industry.
No, the opposite. That the existence of an image prevents the deletion of a signature.
SteveLasker commentedon Jun 10, 2021
Again, naming is hard, and the terminology can be confusing. Early on, we tried storing a collection of references with a type (hard/weak, ..) and it was just too confusing for now.
The current use cases outline this behavior:
For the client vs registry discussions for deleting, many of us implement some level of auto-purging of content.
I think we just want to define some common semantics to help with the consistency of user expectations across registries. How each registry might add value atop those would be greatness for the users to benefit. For instance, I also found the docker hub tag history of digests really interesting and would like to see it added as a common pattern or possibly an api.
jonjohnsonjr commentedon Jun 10, 2021
Precision in terminology is important, especially when producing a specification document. I don't think it's an unreasonable expectation for us to agree on a common vocabulary. That seems like a prerequisite to having a conversation about what's being proposed.
Sorry, this wasn't clear. My second point is regarding deletion by a garbage collector. I've updated my comment.
No. A signature is valuable unto itself even if what it's referencing has been deleted. I can imagine that sometimes you do want to delete them, but the entire concept of transparency logs is built on top of the idea that having a record of what someone signed is a useful security property.
As an example: In the event of a compromise, you might want to delete an artifact because it contains a vulnerability and you don't want anyone to pull it again. However, those signatures might be useful evidence in an investigation of the breach.
tianon commentedon Sep 15, 2021
After reviewing this and opencontainers/artifacts#29 (the primary two "references" proposals), the underlying goal of both appears the same:
Functionally, the main differences appear to be:
subjectManifestvsreference)Given the similarity, can we form consensus around one of them?
(The first half feels like it might belong in the image-spec repository, but the second half is pretty clearly distribution-spec.)
dlorenc commentedon Sep 15, 2021
I think we're all still waiting for the WG proposal, which was created back in April but still hasn't been submitted for a formal vote yet: opencontainers/tob#96
dlorenc commentedon Sep 15, 2021
I agree that they're pretty much the same at this point. I think there are a few more small differences though. I wrote this up a few months ago with some summaries: https://link.medium.com/RwrXtvqgAjb
Note that since then the artifacts proposal moved over to ORAS, where it underwent more changes. I haven't carefully read it all yet so that post might be out of date.
SteveLasker commentedon Sep 16, 2021
While on first view, it may appear similar however, they are much more different when you dig into the details of the implementation, support, and expectations users may have.
As noted in opencontainers/artifacts#29, the Artifacts Spec has been working under https://github.com/oras-project/artifacts-spec/ with a draft release today.
dlorenc commentedon Sep 16, 2021
After another look, it actually looks like they're somewhat closer. The ORAS proposal has seemingly dropped the "reference type" concept that was used in the prior proposal to work around the garbage collection issue.
Now that ORAS Artifacts can reference any type, I'm not actually sure how the ORAS proposal will work around the large concerns with garbage collection previously identified with the OCI image-spec one.
SteveLasker commentedon Sep 16, 2021
@dlorenc, you might want to take the time to understand the proposal, the iterations it's taken, and the current state before making inaccurate statements.
Since it makes cosign work cleanly, without the "hack" of putting digests in the tags, I'm not sure why you're continuing the FUD campaign.
There are no workarounds, there's implicit support for the defined scenarios with clear expectations set for how lifecycle management would be implemented.
dlorenc commentedon Sep 16, 2021
I've read the proposal and much of the history and I think I understand it, but I welcome any corrections!
This isn't a productive statement.
vbatts commentedon Sep 23, 2021
Thanks @tianon for driving for consensus.
SteveLasker commentedon Sep 23, 2021
Thanks @tianon and @vbatts,
I do think there's some good convergence that can happen. As with all these things, the devil is in the details.
From a way to get the references out, I completely agree the referees API could either be converged into the distribution-spec, or enabled through an extension API.
Regarding how the reference is established, this proposal places the reference in the descriptor, which makes it hard to reconcile an artifact graph if blobs can reference other blobs.
The artifacts-spec adds the (reference) as a
subjectproperty in a manifest. This enables lifecycle management.For more details: Comparing the ORAS Artifact Manifest and OCI Image Manifest
While there have been various opinions written, we have not had a collaborative discussion on the proposals. We have a session at the OCI Summit planned for this discussion.
Can we use that to have a conversation on the topic?
sudo-bmitch commentedon Aug 28, 2022
Closing this as resolved by #934. Hopefully we covered all the use cases there.