Zeroize transient seed material in Mnemonic::new - #9
Open
mahzoun wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Mnemonic::newcreated two plaintext secrets and dropped them in place, leaving raw seed material in memory (notably WASM linear memory) until later overwritten:entropybuffer (crates/bitcoin/src/mnemonic.rs)Stringproduced bygenerated_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 aZeroizing<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 inCargo.lock; this promotes it to a direct dependency ofandromeda-bitcoin.cargo check -p andromeda-bitcoinis clean and the existingmnemonicunit tests pass.