Closes #662 - #854
Merged
Nanle-code merged 5 commits intoAug 31, 2026
Merged
Conversation
|
@mansur-codes Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Collaborator
|
@mansur-codes Please fix the CI checks failure!!! |
Contributor
Author
|
Please review and merge |
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.
Description
Minimizes the in-memory lifetime of seed phrases, passphrases, and secret keys by wrapping them in
Zeroizingwrappers from thezeroizecrate. When these values go out of scope, their backing memory is overwritten with zeros before the allocator reclaims it, closing the window where a memory scrape could recover live key material.Closes #662
Type of Change
Changes Made
zeroize = { version = "1", features = ["derive"] }toCargo.tomlas a direct dependency (was already an indirect dep at v1.9.0 viaargon2)encrypt_secretanddecrypt_secretinsrc/utils/crypto.rsto store Argon2-derived AES keys inZeroizing<[u8; 32]>so key bytes are overwritten on drop; updated prompt functions to returnResult<Zeroizing<String>>keypair_from_phraseinsrc/utils/mnemonic.rsto wrap the BIP39 seed, raw ed25519 private key, and all SLIP-0010 intermediate key/chain pairs inZeroizingwrappers; return type changed toResult<(String, Zeroizing<String>)>SigningRequest.local_secretinsrc/utils/wallet_signer.rstoOption<Zeroizing<String>>andresolve_local_secretto returnResult<Zeroizing<String>>; updated all callsites across commands, horizon, and multisig modulesdocs/WALLET_IMPORT_SECURITY.mdcovering what is zeroized, the mechanism used, and caveats for WASM, heap realloc, and swapTesting
How has this been tested?
Test Coverage
keypair_secret_key_is_wrapped_in_zeroizingconfirms the returned secret key derefs correctly to a validS...strkey after wrappingzeroizing_array_explicit_call_clears_all_bytesverifies aZeroizing<[u8; 32]>initialized to0xFFreads as all zeros after an explicit.zeroize()call;aes_key_zeroizes_on_dropreads the stack slot viaread_volatileafter drop and asserts all zerosencrypt_error_path_still_compiles_with_zeroizing_keypasses a zeromem_costArgon2 config (which Argon2 rejects) and confirms the key is zeroized even on the error path;bad_phrase_returns_error_without_panickingconfirms an invalid mnemonic checksum returnsErrwithout touching any secret materialResults:
Code Quality Checklist
cargo fmt)cargo clippy -- -D warnings)Breaking Changes
Internal return types changed (
Zeroizing<String>instead ofStringfor secret values), but all public-facing CLI behavior is identical. Callsites within the crate were updated as part of this PR.Documentation
docs/WALLET_IMPORT_SECURITY.mdupdated with a new section on secret material lifetime and zeroization.Additional Context
zeroizeusesvolatile_writeplus a compiler fence to prevent the optimizer from eliding the zeroing pass. This is effective on native targets. The WASM build does not handle raw secret material directly so the weaker volatile guarantees there are not a practical gap. See the documentation section for full caveats on heap realloc and swap.