Skip to content

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

@LukasKalbertodt

Description

@LukasKalbertodt

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions