Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guidance on subject[*].name uniqueness with Image Indexes #348

Open
lcarva opened this issue Apr 18, 2024 · 16 comments
Open

Guidance on subject[*].name uniqueness with Image Indexes #348

lcarva opened this issue Apr 18, 2024 · 16 comments
Labels

Comments

@lcarva
Copy link

lcarva commented Apr 18, 2024

I have a case where I have an OCI Image Index (aka Manifest List) which references two platform-specifix OCI Image Manifests. In total, there are three image references. The digest of each image is obviously unique.

I am generating an attestation, of type SLSA Provenance, that captures how those images are built. I want to include all three image references in the subject because 1) it accurately represents that these images were built through the same "pipeline"; and 2) I can use cosign to attach the same attestation to each of the three image references, allowing either to be verified independently.

For the subject[*].name, it seems reasonable to me to use the OCI repository, e.g. registry.local/namespace/repo. Given that a tag is not a requirement, there are cases where it is not available. A common use case is to tag the OCI Image Index, but not the OCI Image Manifests. With this approach, the subject[*].name for my three image references all have the same name. This poses a problem because the spec states the subject[*].name:

MUST be ... unique within subject.

I could include the digest in the name but that seems redundant since that's what subject[*].digest is for.

Any guidance would be greatly appreciated!

@marcelamelara
Copy link
Contributor

PTAL @in-toto/attestation-maintainers

@TomHennen
Copy link
Contributor

What distinguishes these three images? They are different, but what's different about them? Is it the architecture they support?

You mention the name might reasonably be registry.local/namespace/repo but is there some additional information after that in practice? E.g. registry.local/namespace/repo/foo, registry.local/namespace/repo/bar, registry.local/namespace/repo/baz?

@lcarva
Copy link
Author

lcarva commented Jun 7, 2024

What distinguishes these three images? They are different, but what's different about them? Is it the architecture they support?

Yes. It's the platform. For example, one of the images is for linux/amd64 while another is for linux/arm64.

You mention the name might reasonably be registry.local/namespace/repo but is there some additional information after that in practice? E.g. registry.local/namespace/repo/foo, registry.local/namespace/repo/bar, registry.local/namespace/repo/baz?

For multi-arch images they usually all live in the same repository. The Image Index references them via digest not a full image reference. I don't know if it's even possible to reference an Image Manifest from an Image Index across repositories. If it is, it is likely a non-standard implementation specific feature of certain registries.

@TomHennen
Copy link
Contributor

Do you happen to know the platform? Could you put the platform in the name field? That would seem to be the most helpful for users? Alternatively, how much do you need to distinguish them using name?

@lcarva
Copy link
Author

lcarva commented Jun 7, 2024

It's possible to inspect an Image Index and an Image Manifest to pull additional information from it. The platform, however, is an optional attribute. I have seen, recent, cases where the platform is completely omitted because it was not relevant.

I do have concerns with requiring SLSA Provenance generators to perform these additional queries. It will quickly overwhelm some existing systems. For example, instances of Tekton Chains (for which I maintain and use extensively) would require additional resources.

It's also important to note that I could have a process that builds two Image Manifests for the same platform, for whatever reason. I don't necessarily need to tag these (although that would be unusual). This means the only attribute that distinguishes them is the digest.

@TomHennen
Copy link
Contributor

What's your ideal solution? Having two different entries in subject with the same name? They'd still only be distinguished by digest but I guess users would know what 'repo' they go to?

That's sort of the use case for [resourceUri](https://slsa.dev/spec/v1.0/verification_summary#fields:~:text=the%20verification%20occurred.-,resourceUri,-string%20(ResourceURI) in the VSA.

The reason, I think, provenance doesn't cover this is that we typically (and perhaps incorrectly) assumed that the builder doesn't actually know the final destination of the artifact. E.g. yes, the builder might build the container image in a registry, but is that the final location or a staging location and it will eventually be promoted elsewhere? Since the VSA is computed when it's published to a specific location it would know the name.

That being said... I don't know how much the uniqueness requirement actually matters in the statement layer.

@lcarva
Copy link
Author

lcarva commented Jun 7, 2024

What's your ideal solution? Having two different entries in subject with the same name? They'd still only be distinguished by digest but I guess users would know what 'repo' they go to?

I can see a couple of solutions.

One would be to just remove the requirement for the name to be unique. I don't know how much value that actually provides, but I may not have the full context. When I verify the SLSA Provenance, I do not rely on the name. The value is purely informative in the use cases I've dealt with. The digest is the attribute to match.

Another possible solution would be to stop using the OCI repo as the name. Instead, SLSA Provenance generators like Tekton Chains could generate a unique name, e.g. something that includes the Task/Pipeline name and the corresponding result name (build-container-IMAGES-0, build-container-IMAGES-1, ko-FOO-IMAGE). Although this approach does not require a change in the spec, I do think that it obscures the subjects, making them less informative.

@TomHennen
Copy link
Contributor

So, another option is to just leave 'name' blank? It's not required.

@lcarva
Copy link
Author

lcarva commented Jun 10, 2024

Good point!

I do think there's value in setting the OCI repository name somewhere when dealing with container images. What would be a good place for that? Maybe the uri field? Example:

{
  "uri": "oci://registry.local/namespace/repo@sha256:abc...",
  "digest": {
    "sha256": "abc..."
  }
}

A bit repetitive to include the digest twice, but otherwise it seems reasonable. WDYT?

@TomHennen
Copy link
Contributor

Seems very reasonable. I also think you can do this without any changes to the spec?

@SantiagoTorres
Copy link
Member

SantiagoTorres commented Jun 11, 2024

fwiw, Name can be a PURL, as of ITE-4: https://github.com/in-toto/ITE/tree/master/ITE/4. You don't need to change the name to 'uri' but rather treat is as an opaque descriptor, or a URI if it follows the right scheme. In theory you can use a GUN as per Docker/OCI, or a PURL, or really anything else.

ETA: in practice you could refer to the tag, and keep the has in the digest bit. Instead of:

{
  "uri": "oci://registry.local/namespace/repo@sha256:abc...",
  "digest": {
    "sha256": "abc..."
  }
}

You could:

{
  "name": "oci://registry.local/namespace/repo:my-tag",
  "digest": {
    "sha256": "abc..."
  }
}

The reason this is valuable is that it still allows you to avoid confusion-type attacks (i.e., libraries will check the hash on the digest but not on the name, and vice-versa), and would still allow you to associate different attestations to the same element.

@TomHennen
Copy link
Contributor

fwiw, Name can be a PURL, as of ITE-4: https://github.com/in-toto/ITE/tree/master/ITE/4. You don't need to change the name to 'uri' but rather treat is as an opaque descriptor, or a URI if it follows the right scheme. In theory you can use a GUN as per Docker/OCI, or a PURL, or really anything else.

Right! I suppose now that the example includes the digest, there's no longer any issue with the uniqueness requirement, so this could go in name now too.

@SantiagoTorres
Copy link
Member

there's no longer any issue with the uniqueness requirement, so this could go in name now too.

Yup, this is also true!

@lcarva
Copy link
Author

lcarva commented Jun 11, 2024

Regarding oci://registry.local/namespace/repo:my-tag, a tag for an Image Manifest is optional, especially if the Image Manifest is referenced by an Image Index. If we omit the tag, then the name will not be unique.

@SantiagoTorres
Copy link
Member

Regarding oci://registry.local/namespace/repo:my-tag, a tag for an Image Manifest is optional, especially if the Image Manifest is referenced by an Image Index. If we omit the tag, then the name will not be unique.

At that point I wonder it'd be easier to then lean on the descriptor spec from OCI and use that instead?

(all in all, I'm not arguing against the oci://whatever@sha256:whateverelse, I'm just trying to prod at the idea and see what other options are there :))

@lcarva
Copy link
Author

lcarva commented Jun 11, 2024

At that point I wonder it'd be easier to then lean on the descriptor spec from OCI and use that instead?

I'm not sure what you mean. Can you clarify?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants