Cipher seed MAC key is derived incorrectly #4859
Labels
A-security
Area - Security related
A-wallet
Area - related to the wallet
C-bug
Category - fixes a bug, typically associated with an issue.
Milestone
To generate an encrypted
CipherSeed
, a user-supplied passphrase is used to produce a 64-byte main key. This key is intended to be split into two keys: a 32-byte MAC key, and a 32-byte encryption key. This is implemented incorrectly, such that the last 32 bytes of the main key are used as the MAC key instead of the first 32 bytes. This means the MAC and encryption keys are identical, which is dangerous in general.Since the password key derivation function is already run twice, one fix is to run it (using 32-byte output) with a different salt for both keys, by appending a different byte flag to the original salt for each derived key. Another option is to run the key derivation function only once, and parse both derived keys at the same time; however, this might make proper zeroization more challenging (see below).
While we're at it, MAC verification should be done in constant time.
This is also a good opportunity to address the overarching topic in issue 4846 and ensure that secret data produced or handled during
CipherSeed
processing is properly zeroized. While theCipherSeed
struct itself zeroizes on drop, there are several other locations where passphrase, entropy, or other key data are not.The text was updated successfully, but these errors were encountered: