You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Migrates the Bitcoin snap to the v2 Keyring API and declares the corresponding capabilities in the manifest. Also removes all v1-only keyring methods and replaces the manual routing table with the v2 dispatcher.
Rewrites KeyringHandler to implement KeyringSnapRpc (from @metamask/keyring-api/v2): adds getAccounts, getAccount, createAccounts, exportAccount, getAccountBalances, getAccountAssets, getAccountTransactions, deleteAccount, submitRequest, setSelectedAccounts, and resolveAccountAddress
Removes v1-only flows (createAccount, discoverAccounts, filterAccountChains, updateAccount) and stops emitting AccountCreated / AccountDeleted events
Folds bip44:discover into createAccounts: calls AccountUseCases.discover(), deletes the account from state if no transactions are found, and returns [] to signal end-of-discovery
Adds exportAccount with WIF private-key export (Base58Check, version byte 0x80/0xEF); uses is() not assert() to prevent the private key from appearing in a StructError message on encoding failure
Reads SUPPORTED_SCOPES directly from snap.manifest.json capabilities block (same pattern as Solana snap) instead of hardcoding the network
Switches handleKeyringRequest to the v2 dispatcher (@metamask/keyring-snap-sdk/v2)
Adds endowment:keyring.capabilities to snap.manifest.json: scopes, privateKey.exportFormats, and bip44 derive/discover flags
Sets module: "ESNext" and moduleResolution: "bundler" in packages/snap/tsconfig.json so /v2 subpath exports resolve correctly
Bumps @metamask/keyring-api → ^23.5.0, keyring-snap-sdk → ^9.2.0, snaps-sdk → ^11.2.0, snaps-cli → ^8.4.1, snaps-jest → ^10.2.0
Updates KeyringHandler.test.ts: removes v1-only describe blocks, adds exportAccount and bip44:discover coverage, mocks wif module, adds beforeEach(() => jest.resetAllMocks()) to fix mock-call accumulation between tests
References
N/A
Checklist
I've updated the test suite for new or updated code as appropriate
I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
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)
Block
Obfuscated code: npm @metamask/snaps-controllers is 90.0% likely obfuscated
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 not obfuscate their code. Consider not using packages with obfuscated code.
Mark the package as acceptable risk. To ignore this alert only
in this pull request, reply with the comment
@SocketSecurity ignore npm/@metamask/snaps-controllers@21.0.0. 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
Potential code anomaly (AI signal): npm @metamask/snaps-simulation is 62.0% likely to have a medium risk anomaly
Notes: The fragment is primarily an orchestration layer for installing/executing MetaMask Snaps and registering internal RPC/action handlers. The main high-impact risk signals are (1) direct execution of snap source code obtained from fetchSnap(), and (2) sensitive key material derivation (mnemonic/seed) from options.secretRecoveryPhrase in a clearly labeled 'withKeyringV2Unsafe' handler that passes mnemonic+seed into an externally provided operation callback. Additionally, SnapController:getSnapFile forwards caller-controlled path/encoding to getSnapFile(auxiliaryFiles, ...)—which could enable unintended file access depending on that helper’s validation. No clear malicious exfiltration or obfuscation is visible in this snippet alone.
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/@metamask/snaps-simulation@4.3.0. 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
Potential code anomaly (AI signal): npm ses is 70.0% likely to have a medium risk anomaly
Notes: The file package/dist/ses.umd.min.js contains an SES/Compartment-based module loader/runtime fragment that uses dynamic evaluation and can modify global intrinsics. While heavily obfuscated, there is no evidence of malware behavior such as data exfiltration or backdoors; the behavior aligns with sandbox hardening rather than active exploitation.
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/ses@2.2.0. 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.
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
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.
Explanation
Original PR & reviewer comments here: MetaMask/snap-bitcoin-wallet#645
Migrates the Bitcoin snap to the v2 Keyring API and declares the corresponding capabilities in the manifest. Also removes all v1-only keyring methods and replaces the manual routing table with the v2 dispatcher.
Rewrites
KeyringHandlerto implementKeyringSnapRpc(from@metamask/keyring-api/v2): addsgetAccounts,getAccount,createAccounts,exportAccount,getAccountBalances,getAccountAssets,getAccountTransactions,deleteAccount,submitRequest,setSelectedAccounts, andresolveAccountAddressRemoves v1-only flows (
createAccount,discoverAccounts,filterAccountChains,updateAccount) and stops emittingAccountCreated/AccountDeletedeventsFolds
bip44:discoverintocreateAccounts: callsAccountUseCases.discover(), deletes the account from state if no transactions are found, and returns[]to signal end-of-discoveryAdds
exportAccountwith WIF private-key export (Base58Check, version byte 0x80/0xEF); usesis()notassert()to prevent the private key from appearing in aStructErrormessage on encoding failureReads
SUPPORTED_SCOPESdirectly fromsnap.manifest.jsoncapabilities block (same pattern as Solana snap) instead of hardcoding the networkSwitches
handleKeyringRequestto the v2 dispatcher (@metamask/keyring-snap-sdk/v2)Adds
endowment:keyring.capabilitiestosnap.manifest.json:scopes,privateKey.exportFormats, andbip44 derive/discoverflagsSets
module: "ESNext"andmoduleResolution: "bundler"inpackages/snap/tsconfig.jsonso /v2 subpath exports resolve correctlyBumps
@metamask/keyring-api → ^23.5.0,keyring-snap-sdk → ^9.2.0,snaps-sdk → ^11.2.0,snaps-cli → ^8.4.1,snaps-jest → ^10.2.0Updates
KeyringHandler.test.ts: removes v1-only describe blocks, addsexportAccountandbip44:discovercoverage, mockswifmodule, addsbeforeEach(() => jest.resetAllMocks())to fix mock-call accumulation between testsReferences
N/A
Checklist