Skip to content

Debug and PartialEq should not be derived for EncodingKey and DecodingKey #220

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

Closed
LukasKalbertodt opened this issue Nov 17, 2021 · 1 comment

Comments

@LukasKalbertodt
Copy link

Both of these types potentially contain secrets in a Vec<u8>.

Deriving Debug means the secret is printed when using that impl. It can easily happen that this type is in some other struct, which is contained in some other struct, which is then logged accidentally. And suddenly you have leaked secrets in your log file. I would recommend manually deriving Debug and not including the actual secret value. For exampled secrecy::Secret prints REDACTED instead.

The derived PartialEq will result in a non-constant-time algorithm. While unlikely, if the key is ever compared to some value that an attacker can supply, then the attacker can employ a timing attack to extract the secret. I am not sure if the PartialEq impl is ever used. If not, I would recommend removing it. Otherwise, the derived impl should be replaced with a constant-time algorithm.

@Keats
Copy link
Owner

Keats commented Nov 17, 2021

Good catch! I'll remove them in the next branch.

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

No branches or pull requests

2 participants