Skip to content

Zeroize transient seed material in Mnemonic::new - #9

Open
mahzoun wants to merge 1 commit into
ProtonWallet:mainfrom
mahzoun:fix/zeroize-mnemonic-entropy
Open

Zeroize transient seed material in Mnemonic::new#9
mahzoun wants to merge 1 commit into
ProtonWallet:mainfrom
mahzoun:fix/zeroize-mnemonic-entropy

Conversation

@mahzoun

@mahzoun mahzoun commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

What

Mnemonic::new created two plaintext secrets and dropped them in place, leaving raw seed material in memory (notably WASM linear memory) until later overwritten:

  • the raw 32-byte entropy buffer (crates/bitcoin/src/mnemonic.rs)
  • the intermediate mnemonic-phrase String produced by generated_key.to_string()

This change wipes the entropy buffer with zeroize() once it has been consumed to derive the mnemonic, and holds the intermediate phrase in a Zeroizing<String> so it is cleared as soon as it is parsed.

Scope

Defense-in-depth, minimal change. It does not alter behaviour: the mnemonic stored on the struct and the values intentionally exported through the public API (as_string/as_words, WIF) are unchanged — those are by-design plaintext exports and out of scope here.

Notes

  • zeroize (1.9) was already present transitively in Cargo.lock; this promotes it to a direct dependency of andromeda-bitcoin.
  • cargo check -p andromeda-bitcoin is clean and the existing mnemonic unit tests pass.

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.

1 participant