-
Notifications
You must be signed in to change notification settings - Fork 56
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
fix: Allow empty passwords for encrypted pem files #381
Conversation
After doing some more testing, there seems to be another spot that's preventing this from working with empty password cosign generated keys. Working on figuring that out |
19cb687
to
4192dd0
Compare
Ok so I found the other issue, there was apparently a hard check for the example test cosign pem: {"kdf":{"name":"scrypt","params":{"N":65536,"r":8,"p":1},"salt":"/67J9VwY8a6ravOCALfO1P3NGD4Xsk6/M9hNbaXC7+A="},"cipher":{"name":"nacl/secretbox","nonce":"/ht529R6XgnAFmUz/u4jyQTMeom4T6MT"},"ciphertext":"ZJYYk2GQaZgJtHzS0JtUnMhSnQWsnGpD3a5B23weYKodDo2dxUNexEIDp88FRC3jURM4b56EHEcnVUZaDL3cgfkN7Meeo18VYSvZmwI7XhRZs119G6yifi8HqZFbgI3mQwNv0EDp1DzL4wfIZ0pyP+xA/3lNy9myfRd6R3RhGHyIkz5QxxrvZ0uTvGTLNrgKHus/sSn+5ZKl/Q=="} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with the changes done to allow empty passwords.
@Xynnn007: would you mind taking a look too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic looks good to me. I relooked inside the cosign code and behavior and ensure that if no password is given, still a encrypted privatekey will be given rather than a plaintext privatekey. The encryption key is derived from ""
with scrypt.
@woodruffw brought this up in the sigstore clients meeting today. Two points to consider here:
Also, perhaps the behavior in cosign should be changed. |
Signed-off-by: Gerald Pinder <[email protected]>
Signed-off-by: Gerald Pinder <[email protected]>
(Thanks @loosebazooka! I forgot to comment on this earlier.)
To elaborate a bit more on this concern: IMO there's a security risk with enabling people to encrypt with the empty password, insofar as the "encrypted" version is indistinguishable from a version with an actual, strong password. In other words: a user who lacks a full picture of the system may assume that any PEM blob with the I think the "fix" involves both
(2) is arguably a slippery slope towards "weak" password/entropy testing, which is an anti-pattern. But IMO stopping at empty passwords is perfectly fine; that's the point of having a strong memory-hard hash function like |
What would happen to the users who have already generated a cosign key with an empty password? Would that just stop working all of a sudden? Would those users then have to create new keys and then update their users to know that they have a different key? I feel like changing that now could break compatibility with previous use cases. At the end of the day, this is y'all's project, so it's your decision. I just want to voice my concerns. |
There would definitely need to be a transition period here, at least for
For Do you think that would accomodate your use case? |
Not really as we have hundreds of users of our system that has been relying on using those empty cosign passwords. I don't see why breaking user-space to remove something that |
For compatibility, we probably can judge the reading logic of the keys by pem header, s.t.
case 2 is for compability. For key generation logic, we could turn to new logic, s.t. empty password still derive a key to encrypt. |
I can add that logic in another commit. Are there any changes that you think I should make to my first two commits? |
Any update on whether this will be merged in? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! More comments about code style.
Cool, I can work on these this weekend |
Alright, got the tests updated. |
…password is given Signed-off-by: Gerald Pinder <[email protected]>
Got the last few comments resolved |
@gmpinder Thanks for your adopting the suggestions! Let's see how CI works |
Good. Passed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. ptal @flavio
Awesome! Would you be able to get these changes out in a |
Summary
I've been working on integrating this crate into my CLI program and I ran into a situation where pem files generated by the cosign tool with an empty password couldn't be loaded. I was getting an invalid key type error, so I dug into why that was and found that the keys were being processed differently if the password had no length. Removing that constraint allowed my empty password cosign keys to be loaded properly. I'm hoping this change will be accepted so that this rust implementation is a bit closer to parity with the cosign cli tool.
Closes #380
Release Note
cosign
Documentation
N/A