Skip to content

fix: enforce mnemonic validation#450

Merged
gantunesr merged 15 commits intomainfrom
gar/chore/srp-validation
Feb 2, 2026
Merged

fix: enforce mnemonic validation#450
gantunesr merged 15 commits intomainfrom
gar/chore/srp-validation

Conversation

@gantunesr
Copy link
Member

@gantunesr gantunesr commented Jan 31, 2026

The HdKeyring class accepts mnemonics during deserialization without validating that they are valid BIP39 mnemonics. This means invalid mnemonics (words not in the BIP39 wordlist or invalid checksums) could be passed in and would fail later in the key derivation process with unclear error messages.

This PR adds a isValidMnemonic private method that validates mnemonics using validateMnemonic from @metamask/scure-bip39 before processing them.


Note

Medium Risk
Adds strict BIP39 validation during deserialize/mnemonic initialization, which can cause previously-accepted (but invalid) secret recovery phrases to fail earlier and may impact restoration flows.

Overview
HdKeyring now validates provided mnemonics against the BIP39 english wordlist and checksum (via validateMnemonic) before deriving the seed, throwing Eth-Hd-Keyring: Invalid secret recovery phrase provided on failure.

Tests were expanded to cover invalid word counts, invalid words, invalid checksums, and mnemonic inputs in Buffer/Uint8Array/serialized forms; the changelog notes the new enforcement.

Written by Cursor Bugbot for commit 5075bae. This will update automatically on new commits. Configure here.

@gantunesr gantunesr requested a review from a team as a code owner January 31, 2026 02:34
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

@gantunesr gantunesr changed the title chore: add mnemonic validation method fix: enforce mnemonic validation Feb 2, 2026
@gantunesr gantunesr added this pull request to the merge queue Feb 2, 2026
Merged via the queue into main with commit dc745f1 Feb 2, 2026
38 checks passed
@gantunesr gantunesr deleted the gar/chore/srp-validation branch February 2, 2026 15:46
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.

4 participants