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

Offline Rekor bundle generation and verification #247

Merged
merged 40 commits into from
Nov 2, 2022

Conversation

woodruffw
Copy link
Member

@woodruffw woodruffw commented Oct 11, 2022

WIP.

Closes #52.

Closes #194.

@woodruffw woodruffw added the component:verification Core verification functionality label Oct 11, 2022
@woodruffw woodruffw self-assigned this Oct 11, 2022
@woodruffw woodruffw marked this pull request as ready for review October 11, 2022 20:26
@woodruffw
Copy link
Member Author

This is ready for an initial review, but it needs some more testing before merge (I haven't actually confirmed offline bundles work yet, only that the changes don't break online verification).

My plan was to implement #194 in this PR as well, to complete the whole picture (and round out testing). But I can do that separately and use a bundle generated by cosign instead, if we'd like to keep the diff small(er).

@asraa
Copy link
Contributor

asraa commented Oct 11, 2022

But I can do that separately and use a bundle generated by cosign instead, if we'd like to keep the diff small(er).

I may not necessarily totally us cosign's scheme... I'm not really a fan of the duplicated fields as I mentioned in #194 (comment)

But I hear the burden of implementing something twice. On the other hand, I think keeping it absolutely minimal to just the Rekor entry stored offline would allow building up to the "Sigstore bundle" (which is WIP design sigstore/cosign#2204 away from the sorta-faulty cosign bundle)

The returned value here is not base64-encoded.

Signed-off-by: William Woodruff <[email protected]>
@woodruffw
Copy link
Member Author

But I hear the burden of implementing something twice. On the other hand, I think keeping it absolutely minimal to just the Rekor entry stored offline would allow building up to the "Sigstore bundle" (which is WIP design sigstore/cosign#2204 away from the sorta-faulty cosign bundle)

Makes sense. Yeah, this PR is limited to only the "Rekor" bundle, not the bigger thing that I understand (maybe incorrectly?) to be unstable/soft-deprecated on cosign's side.

README.md Outdated Show resolved Hide resolved
sigstore/_cli.py Outdated Show resolved Hide resolved
sigstore/_cli.py Outdated Show resolved Hide resolved
asraa
asraa previously approved these changes Oct 11, 2022
sigstore/_internal/rekor/client.py Outdated Show resolved Hide resolved
sigstore/_verify.py Show resolved Hide resolved
sigstore/_verify.py Outdated Show resolved Hide resolved
sigstore/_verify.py Outdated Show resolved Hide resolved
sigstore/_verify.py Outdated Show resolved Hide resolved
sigstore/_verify.py Outdated Show resolved Hide resolved
sigstore/_verify.py Show resolved Hide resolved
spec = entry_body["spec"]
expected_sig, expected_cert, expected_hash = (
spec["signature"]["content"],
load_pem_x509_certificate(
Copy link
Contributor

Choose a reason for hiding this comment

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

This field can contain either a certificate, a certificate chain, or a public key, so we'll need to handle this. Not sure if there's other parts of the code that make this assumption also.

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe this is the only place we make that assumption, since the only other places we touch hashedrekord objects directly are during log entry submission and querying.

In this case, it's okay for us to fail if we don't see a PEM-encoded certificate, right? This code only runs (currently) in the context of verification against a PEM-encoded certificate, so anything else would imply that the user has given us the wrong Rekor entry.

Copy link
Member Author

Choose a reason for hiding this comment

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

(More generally, I think this demonstrates that I probably need to invert how I'm matching against the offline Rekor entry -- instead of unpacking the body and making sure it matches the cert/sig/etc, I should pack the latter into a hashedrekord payload and make sure it's strictly equal to the claimed entry.)

Copy link
Contributor

@haydentherapper haydentherapper Oct 17, 2022

Choose a reason for hiding this comment

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

So there's no support for verification by signing key rather than cert? (If not, feature request!)

Assuming only verification by cert is currently supported, I do think we should handle a certificate chain too. I think it'd be fine to take only the first element in the chain and discard the remaining.

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct! I'll file an issue for that.

woodruffw and others added 3 commits October 14, 2022 10:02
Co-authored-by: Hayden B <[email protected]>
Signed-off-by: William Woodruff <[email protected]>
Signed-off-by: William Woodruff <[email protected]>
@woodruffw woodruffw requested review from di and jku and removed request for jku October 14, 2022 21:41
@woodruffw
Copy link
Member Author

I think this is good to go, at least on my side.

cc @di: what are your thoughts on merging this as-is, vs. waiting for the "sigstore bundle" formal to become stable? I think we could go either way, although we'll likely end up replacing/deprecating these CLI flags once the sigstore bundle is available. As such, it might make sense to avoid the deprecation period and just wait a bit here.

jku
jku previously approved these changes Oct 26, 2022
Copy link
Member

@jku jku left a comment

Choose a reason for hiding this comment

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

The rekor specific bits fly over my head a bit but this looks ok to me.

  • I think verify() needs a refactor though: it's now very long and quite complicated -- that could happen in another issue though
  • your comment WRT inverting entry matching seems reasonable: that would likely go some way towards fixing the previous complaint?

@jku
Copy link
Member

jku commented Oct 26, 2022

  • your comment WRT inverting entry matching seems reasonable: that would likely go some way towards fixing the previous complaint?

actually: inverting the entry matching maybe isn't a good idea if the rekor entry could contain full certificate chains but we are ok with just the single certificate in our verfication input ?

@woodruffw
Copy link
Member Author

  • I think verify() needs a refactor though: it's now very long and quite complicated -- that could happen in another issue though

Yes, absolutely agreed. I have that earmarked in #250.

di
di previously approved these changes Oct 28, 2022
@woodruffw
Copy link
Member Author

Not sure why DCO is stalled here...

@woodruffw woodruffw enabled auto-merge (squash) November 1, 2022 16:14
@woodruffw woodruffw dismissed stale reviews from di and jku via ea45d3e November 1, 2022 16:31
@woodruffw woodruffw requested a review from di November 1, 2022 16:37
@woodruffw
Copy link
Member Author

Needs re-app, since I added some warnings to emphasize that the Rekor bundle isn't intended to be a long-term format.

@woodruffw woodruffw merged commit 1730a99 into main Nov 2, 2022
@woodruffw woodruffw deleted the ww/offline-rekor-bundle-verification branch November 2, 2022 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:verification Core verification functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support generating offline Rekor bundles Support verifying offline Rekor bundles
6 participants