MetaMask / MetaMask/core

bug: mnemonics should never be converted to a string; `@metamask/eth-hd-keyring` converts it to a string in its `deserialize` method

Open
#5,483 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

team-accounts
Dominant language
TypeScript
Stars
413
Forks
308
Avg merge
1d 4h
Merged PRs (30d)
253

Description

Example call:
https://github.com/MetaMask/core/blob/2b8c61d2346c144154a7735782d6dffce3a387e8/packages/keyring-controller/src/KeyringController.ts#L2434

Related issue: https://github.com/MetaMask/accounts/issues/250

In the extension's `metamask-controller.js`'s `submitPassword` function we call `keyringController.submitPassword(password)` which calls its own `restoreSerializedKeyrings` method. This eventually calls into `@metamask/eth-hd-keyring`'s `deserialize` method, which ultimately converts the `mnemonic` to a string.

Here is a trace:
![Image](https://github.com/user-attachments/assets/96aad1e8-21d1-4be8-b6a3-d0b74b78462e)

Related Slack conversation: https://consensys.slack.com/archives/C087GPTR5HQ/p1741974188846359?thread_ts=1741795570.164739&cid=C087GPTR5HQ

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the KeyringController.ts call at line 2434 and trace restoreSerializedKeyrings through @metamask/eth-hd-keyring's deserialize method. Confirm where mnemonic is converted to a string and identify the relevant tests or fixtures; done means deserialization preserves the mnemonic without string conversion and the affected tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.