Skip to content

Add support for DSSE envelope for attestation in imagetools - #2194

Merged
tonistiigi merged 2 commits into
docker:masterfrom
LaurentGoderre:sbom-dsse
Feb 29, 2024
Merged

tonistiigi merged 2 commits into
docker:masterfrom
LaurentGoderre:sbom-dsse

Conversation

@LaurentGoderre

@LaurentGoderre LaurentGoderre commented Jan 15, 2024 •

Copy link
Copy Markdown
Member

When running docker buildx imagetools inspect --format '{{ JSON .SBOM }} and the attestations use the application/vnd.in-toto+json mime type, the In-TOTO predicate is returned. However, then the attestation are wrapped in a DSSE envelope using the application/vnd.in-toto.spdx+dsse mime type, the same command returns and empty object ({}).

The changes add support for the DSSE mime type and base64 decode the envelope and returnb the payload object to stay consistent with images that do not use a wraper.

Comment thread util/imagetools/loader.go Outdated
for _, layer := range mfst.manifest.Layers {
if layer.MediaType == "application/vnd.in-toto+json" && layer.Annotations["in-toto.io/predicate-type"] == "https://spdx.dev/Document" {
if (layer.MediaType == "application/vnd.in-toto+json" ||
layer.MediaType == "application/vnd.in-toto.spdx+dsse") &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you have an image we can look at with this mime type?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@tonistiigi tonistiigi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Supporting this for imagetools inspect is not a big issue I think but generally I don't see why the DSSE envelope should be needed for OCI structures. There is already envelope for referring to data in the form of OCI descriptor, it works natively and doesn't have the base64 overhead and obfuscation issues.

Comment thread util/imagetools/loader.go Outdated
return nil, err
}

decoded, err := base64.StdEncoding.DecodeString(dsse.Payload)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should the payload be trusted if signatures (format) have not been verified?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

One could argue it should be trusted at the same level as one that isn't signed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is there a mechanism in place to throw warnings for imagetools inspect commands? if so, adding a warning that the statements haven't been verified would help here

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

could potentially use logrus here to print a warning along the lines of warning: sbom statements are not verified until if/when this code checks signatures. I haven't seen many examples in the code base other than

logrus.Warningf("Unknown flag name %q", name)

@tonistiigi tonistiigi added this to the v0.13.0 milestone Feb 26, 2024

@tonistiigi tonistiigi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this shouldn't be SBOM specific and if we support this wrapper it should be same for provenance as well. Hopefully most of the code could be shared.

@LaurentGoderre

Copy link
Copy Markdown
Member Author

@tonistiigi is the provenance signed as well?

@tonistiigi

Copy link
Copy Markdown
Member

If you are talking about attestations signed by buildkit then none of them are signed atm. Afaics these are for inspecting images from custom tooling. If SBOM can be wrapped with DSSE in this case then I don't see why provenance wouldn't as well.

@LaurentGoderre

Copy link
Copy Markdown
Member Author

@tonistiigi the DSSE is used for signing the attestation so provenance should only need a DSSE envelope if it is signed as well.

@colinhemmings

Copy link
Copy Markdown
Collaborator

@LaurentGoderre are you just looking to sign the SBOM? Is there a reason why not just sign both SBOM and provenance attestations?

@LaurentGoderre

Copy link
Copy Markdown
Member Author

@colinhemmings I am not sure if we are, I was asking.

@whalelines

Copy link
Copy Markdown

@tonistiigi said:

I think this shouldn't be SBOM specific and if we support this wrapper it should be same for provenance as well. Hopefully most of the code could be shared.

I agree here. Any format imagetools supports should also be supported when it is wrapped in a DSSE. SBOM, provenance, and whatever else imagetools supports that can be wrapped in a DSSE.

Comment thread util/imagetools/loader.go Resolved
…tools

Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
@LaurentGoderre

Copy link
Copy Markdown
Member Author

@tonistiigi @whalelines I made more generic so it can be expanded to other DSSE formats.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
@tonistiigi
tonistiigi merged commit e273a53 into docker:master Feb 29, 2024
@LaurentGoderre
LaurentGoderre deleted the sbom-dsse branch March 1, 2024 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants