chore: add blockaid filter logic for spl tokens#7923
Open
sahar-fehri wants to merge 6 commits intomainfrom
Open
chore: add blockaid filter logic for spl tokens#7923sahar-fehri wants to merge 6 commits intomainfrom
sahar-fehri wants to merge 6 commits intomainfrom
Conversation
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
packages/assets-controllers/src/MultichainAssetsController/MultichainAssetsController.ts
Show resolved
Hide resolved
Comment on lines
45
to
47
| const mockHandleFetch = ControllerUtils.handleFetch as jest.MockedFunction< | ||
| typeof ControllerUtils.handleFetch | ||
| >; |
Contributor
There was a problem hiding this comment.
nit - we can use jest.mocked and avoid type assertions.
const mockHandleFetch = jest.mocked(ControllerUtils.handleFetch)
packages/assets-controllers/src/MultichainAssetsController/MultichainAssetsController.test.ts
Outdated
Show resolved
Hide resolved
packages/assets-controllers/src/MultichainAssetsController/MultichainAssetsController.test.ts
Outdated
Show resolved
Hide resolved
packages/assets-controllers/src/MultichainAssetsController/MultichainAssetsController.ts
Show resolved
Hide resolved
Prithpal-Sooriya
previously approved these changes
Feb 13, 2026
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions. |
Prithpal-Sooriya
approved these changes
Feb 13, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Adds Blockaid token security scanning to MultichainAssetsController to filter out spam, malicious, and warning SPL tokens before they are stored in state.
(Related: https://consensys.slack.com/archives/C04J5RRJYTE/p1770216744026999)
New
#filterBlockaidSpamTokensmethod — Groups incoming token assets by chain, calls the Blockaid bulk scan endpoint(/token/scan-bulk), and removes any token flagged as Spam, Malicious, or Warning. Native assets (slip44) are passed through without scanning.Fail-open behavior — If the Blockaid API request fails or a token has no result in the response, the token is kept (not filtered out).
Filtering is applied in two flows:
accountAssetListUpdated— newly added tokens are scanned before being persisted.accountAdded— the full asset list retrieved from the snap is scanned before initial storage.References
Checklist
Note
Medium Risk
Touches asset-detection state updates and introduces a new external API dependency/timeout path; while it fails open, scan results can change which tokens get persisted and displayed.
Overview
Adds Blockaid token security filtering to automatic multichain asset detection.
MultichainAssetsControllernow bulk-scans newly detected CAIP-19 assets withassetNamespacetoken(e.g. SPL tokens) viahttps://security-alerts.api.cx.metamask.io/token/scan-bulkand only persists tokens ratedBenign, leaving native assets (e.g.slip44) unscanned.Filtering is applied when a non-EVM account is added and when handling
AccountsController:accountAssetListUpdatedadditions, usingtimeoutFetchwith a 10s timeout and fail-open behavior (API errors/timeouts/missing results keep tokens). Tests and changelog were updated to cover spam/malicious/warning cases, timeouts/errors, and ensuring curatedaddAssetsremains unfiltered.Written by Cursor Bugbot for commit 0d08f8b. This will update automatically on new commits. Configure here.