Skip to content

feat: add Ethereum MPC keyring - #627

Draft
matthiasgeihs wants to merge 9 commits into
mainfrom
mg/mpc-keyring
Draft

feat: add Ethereum MPC keyring#627
matthiasgeihs wants to merge 9 commits into
mainfrom
mg/mpc-keyring

Conversation

@matthiasgeihs

Copy link
Copy Markdown

Summary

  • Add @metamask/eth-mpc-keyring: a 2-party client/server MPC keyring with DKLS23 TSS, cloud backup sync, and vendored MFA wallet libs
  • Support create/import init, key-share rotate/check/sync, and signing (transactions, personal_sign, typed data, EIP-7702 authorizations)
  • Replaces the earlier WIP in feat: add MPC keyring #440 with a cleaned history rebased on main

Test plan

  • yarn workspace @metamask/eth-mpc-keyring test
  • yarn workspace @metamask/eth-mpc-keyring build
  • Smoke-check create/import and signing against a staging cloud/relayer if available

Made with Cursor

matthiasgeihs and others added 2 commits September 2, 2026 15:41
Introduce a 2-party client/server MPC keyring with DKLS23 TSS, cloud backup sync, and vendored MFA wallet libs.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@matthiasgeihs
matthiasgeihs requested a review from a team as a code owner September 2, 2026 13:54
@matthiasgeihs

Copy link
Copy Markdown
Author

Replaces #440 with a cleaned history rebased onto main.

@socket-security

socket-security Bot commented Sep 2, 2026

Copy link
Copy Markdown

@socket-security

socket-security Bot commented Sep 2, 2026

Copy link
Copy Markdown

Warning

MetaMask internal reviewing guidelines:

  • Do not ignore-all
  • Each alert has instructions on how to review if you don't know what it means. If lost, ask your Security Liaison or the supply-chain group
  • Copy-paste ignore lines for specific packages or a group of one kind with a note on what research you did to deem it safe.
    @SocketSecurity ignore npm/PACKAGE@VERSION
Action Severity Alert  (click "▶" to expand/collapse)
Warn Medium
Network access: npm centrifuge in module globalThis["fetch"]

Module: globalThis["fetch"]

Location: Package overview

From: packages/keyring-eth-mpc/package.jsonnpm/@metamask/mfa-wallet-network@0.0.0npm/centrifuge@5.7.2

ℹ Read more on: This package | This alert | What is network access?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should remove all network access that is functionally unnecessary. Consumers should audit network access to ensure legitimate use.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/centrifuge@5.7.2. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn Low
Potential code anomaly (AI signal): npm @protobufjs/codegen is 72.0% likely to have a medium risk anomaly

Notes: No direct malicious behavior (e.g., exfiltration, persistence, or credential theft) is evident in this module. However, it is inherently a dynamic code execution utility: it constructs JavaScript source from caller-influenced templates/body and scope, then executes it using the Function constructor. If any upstream input can influence templates or accumulated body, this module can enable code injection/RCE in the caller’s context. Treat as high-risk when used with untrusted data; otherwise it functions as a formatter/codegen helper.

Confidence: 0.72

Severity: 0.52

From: packages/keyring-eth-mpc/package.jsonnpm/@metamask/mfa-wallet-network@0.0.0npm/@trezor/connect-web@9.6.1npm/@protobufjs/codegen@2.0.5

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@protobufjs/codegen@2.0.5. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn Low
Potential code anomaly (AI signal): npm protobufjs is 61.0% likely to have a medium risk anomaly

Notes: The analyzed code segment is a standard RPC service wrapper (protobufjs style) with conventional input validation, encoding/decoding, event emission, and end handling. No malicious behavior is evident, and there are no observable security vulnerabilities beyond ordinary library-level error handling. It does not exhibit data exfiltration, backdoors, or other anti-security patterns.

Confidence: 0.61

Severity: 0.55

From: packages/keyring-eth-mpc/package.jsonnpm/@metamask/mfa-wallet-network@0.0.0npm/protobufjs@7.6.6

ℹ Read more on: This package | This alert | What is an AI-detected potential code anomaly?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: An AI system found a low-risk anomaly in this package. It may still be fine to use, but you should check that it is safe before proceeding.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/protobufjs@7.6.6. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@cursor
cursor Bot requested review from ccharly and hmalik88 September 2, 2026 14:03

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 4 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1027e20. Configure here.

Comment thread packages/keyring-eth-mpc/src/mpc-keyring.ts Outdated
return toEthSig(signature, hash, keyShare.publicKey);
} catch (error) {
this.#applyKeyState({ ...state, tssSetup: null });
throw error;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sign overwrites concurrent key updates

High Severity

#signHash snapshots #state and later writes that snapshot back with #applyKeyState. rotateKeyShares and syncKeyShare are not on #signQueue, so a rotation or sync that finishes during signing is overwritten with the stale keyShare and backupId, desynchronizing the client from the server.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1027e20. Configure here.

...state,
keyShare,
backupId,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Rotation can desynchronize key shares

High Severity

rotateKeyShares commits the new server share in the MPC session before the client persists that share. If storeKeyShareBackup fails afterward, #state still holds the old share while the server has the new one, and neither a retry nor syncKeyShare can repair the mismatch.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1027e20. Configure here.

Comment thread packages/keyring-eth-mpc/src/mpc-keyring.ts
matthiasgeihs and others added 4 commits September 2, 2026 16:12
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Pass convertV so recovery id 27|28 becomes yParity or EIP-155 v.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Risk: high. Not approved — this adds a new Ethereum MPC keyring with TSS signing, cloud backup, and vendored MFA libraries, which is above the low-risk approval threshold. Human review is needed.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router

matthiasgeihs and others added 2 commits September 2, 2026 16:48
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@matthiasgeihs
matthiasgeihs marked this pull request as draft September 2, 2026 14:50
Replace backupId with shareEpoch so create/rotate append and activate
epochs only after backup readiness, matching the robust MPC architecture.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant