Skip to content

Fix proof of key possession generation#283

Merged
steiza merged 1 commit intosigstore:mainfrom
adityasaky:pop-subject-email
Sep 4, 2024
Merged

Fix proof of key possession generation#283
steiza merged 1 commit intosigstore:mainfrom
adityasaky:pop-subject-email

Conversation

@adityasaky
Copy link
Copy Markdown
Member

Summary

This commit updates the proof of key possession signature to prioritize email over subject when the claim is present in the token. This matches the current behaviour of Fulcio, which verifies the proof signature using the token's email claim.

Closes #282

Release Note

Updated proof of key possession signature to use email when it's present in the token.

Documentation

NONE

@adityasaky adityasaky requested a review from a team as a code owner August 28, 2024 19:24
@adityasaky
Copy link
Copy Markdown
Member Author

I've copied subjectFromClaims from sigstore/sigstore for the time being. We can't currently use the exported SubjectFromToken function because it accepts an oidc.IDToken object which is only created after the token is verified by the client. This library doesn't currently verify the token, leaving that to Fulcio. FWIW, SubjectFromToken operates on the token's bytes (tok.Claims() is a wrapper around json.Unmarshal of the token bytes). However, changing it instead to just use the token's bytes would be a breaking change, and I also haven't checked whether the token bytes are still available when the function is invoked. I suppose another question is whether cosign, etc. should continue to verify the token at all or just leave it to Fulcio as this library does.

@adityasaky adityasaky marked this pull request as draft August 28, 2024 19:32
Comment thread pkg/sign/certificate.go Outdated
Copy link
Copy Markdown
Member

@steiza steiza left a comment

Choose a reason for hiding this comment

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

I think this approach makes sense. Could we add some unit tests?

Comment thread pkg/sign/certificate.go Outdated
@adityasaky
Copy link
Copy Markdown
Member Author

Could we add some unit tests?

Happy to! I held off until there was consensus on whether subjectFromClaims should in fact be in this repo or sigstore/sigstore. Also, I think we can't test the proof of key possession signature itself, since fulcio is mocked?

@adityasaky
Copy link
Copy Markdown
Member Author

adityasaky commented Sep 3, 2024

(apologies for all the force pushes)

I think this is now ready for review, I've updated sigstore/sigstore to v1.8.9 that @haydentherapper just cut, which includes SubjectFromUnverifiedToken discussed in #283 (comment).

Hayden-IO
Hayden-IO previously approved these changes Sep 3, 2024
Copy link
Copy Markdown
Contributor

@Hayden-IO Hayden-IO left a comment

Choose a reason for hiding this comment

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

thanks!

This commit updates the proof of key possession signature to prioritize
email over subject when the claim is present in the token. This matches
the current behaviour of Fulcio, which verifies the proof signature
using the token's email claim.

Signed-off-by: Aditya Sirish <aditya@saky.in>
@adityasaky
Copy link
Copy Markdown
Member Author

Didn't realize there was another go.mod, I've updated it as well now.

Copy link
Copy Markdown
Member

@kommendorkapten kommendorkapten left a comment

Choose a reason for hiding this comment

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

👍

@steiza steiza merged commit 725e508 into sigstore:main Sep 4, 2024
@adityasaky adityasaky deleted the pop-subject-email branch September 4, 2024 15:13
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.

Proof of key possession is inconsistent with Fulcio

4 participants