-
Notifications
You must be signed in to change notification settings - Fork 11
Fix wordlist corruption from secure wipe of shared BIP39 string objects #335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,7 +82,10 @@ def update_pending_mnemonic(self, word: str, index: int): | |
| """ | ||
| if index >= len(self._pending_mnemonic): | ||
| raise Exception(f"index {index} is too high") | ||
| self._pending_mnemonic[index] = word | ||
| # Create an independent copy so that wipe_list() in | ||
| # discard_pending_mnemonic() won't corrupt the shared | ||
| # global wordlist strings via wipe_string/ctypes.memset. | ||
| self._pending_mnemonic[index] = "".join(word) | ||
|
Comment on lines
84
to
+88
|
||
|
|
||
|
|
||
| def get_pending_mnemonic_word(self, index: int) -> str: | ||
|
|
@@ -146,7 +149,9 @@ def init_pending_slip39_share(self, num_words: int | None = None): | |
| def update_pending_slip39_share(self, word: str, index: int): | ||
| if index >= len(self._pending_slip39_share): | ||
| raise Exception(f"index {index} is too high") | ||
| self._pending_slip39_share[index] = word | ||
| # Create an independent copy so that wipe_list() won't | ||
| # corrupt the shared global SLIP-39 wordlist strings. | ||
| self._pending_slip39_share[index] = "".join(word) | ||
|
|
||
| def get_pending_slip39_word(self, index: int) -> str: | ||
| if index < len(self._pending_slip39_share): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
detect_segment_type() repeats s.strip().lower().split() three times. Consider normalizing once (e.g., precompute the split words list) to reduce duplication and keep the seed-type checks easier to maintain.