Skip to content

Conversation

Kriys94
Copy link

@Kriys94 Kriys94 commented Oct 10, 2025

Description

This PR adds messenger allowlist support for the TokenBalancesController WebSocket integration introduced in MetaMask/core#6784.

What is the reason for the change?

The updated @metamask/assets-controllers package (v79.0.0+) includes a TokenBalancesController that can optionally receive real-time balance updates via WebSocket events from @metamask/core-backend services. Without updating the messenger allowlist, the extension throws an error: Event missing from allow list: AccountActivityService:balanceUpdated.

What is the improvement/solution?

This PR makes minimal changes to support the new TokenBalancesController capabilities:

  1. Added dependency: @metamask/core-backend (^1.0.1) for TypeScript type definitions
  2. Updated messenger allowlist in token-balances-controller-messenger.ts:
    • Added events: AccountActivityService:balanceUpdated, AccountActivityService:statusChanged, BackendWebSocketService:connectionStateChanged
    • Added action: TokenDetectionController:addDetectedTokensViaWs

⚠️ Important - No Behavior Change:

Bumping the @metamask/assets-controllers version changes nothing about TokenBalancesController behavior. The controller will continue to work exactly as it does today using HTTP polling.

Why? The WebSocket integration requires BackendWebSocketService and AccountActivityService to be initialized and connected. Since these services are not initialized in this PR, no WebSocket connection is established, and no real-time events are triggered. The TokenBalancesController gracefully detects their absence and continues using the existing HTTP polling mechanism.

This PR only updates the messenger allowlist to prevent validation errors when the controller checks for the optional WebSocket events.

Benefits:

  • ✅ Resolves messenger validation errors
  • Zero behavior change - identical HTTP polling as before
  • ✅ No runtime overhead - services are not initialized, no WebSocket connections
  • ✅ No performance impact - polling intervals unchanged
  • ✅ Future-ready for real-time balance updates when backend services are added

Open in GitHub Codespaces

Changelog

CHANGELOG entry: null

Related issues

Fixes: #[issue number if applicable]

Related:


Note

Expands TokenBalancesController messenger allowlist for WebSocket integration, adds @metamask/core-backend types, and bumps @metamask/assets-controllers to 79.0.1-preview.

  • TokenBalancesController messenger:
    • Allowlist events: AccountActivityService:balanceUpdated, AccountActivityService:statusChanged, BackendWebSocketService:connectionStateChanged.
    • Allowlist action: TokenDetectionController:addDetectedTokensViaWs.
  • Dependencies:
    • Add @metamask/core-backend (^1.0.1).
    • Update @metamask/assets-controllers to 79.0.1-preview (via resolutions).

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

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​metamask/​core-backend@​1.0.17710010090100
Added@​metamask/​profile-sync-controller@​25.1.1991008797100

View full report

Copy link

Caution

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)
Block Medium
@metamask/[email protected] has Network access.

Module: globalThis["fetch"]

Location: Package overview

From: package.jsonnpm/@metamask/[email protected]

ℹ 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 [email protected].

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/@metamask/[email protected]. 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
@metamask/[email protected] is a AI-detected potential code anomaly.

Notes: The code implements a guarded, cache-accelerated path to sign a message via an external SnapController. No explicit malware indicators detected. Primary risks relate to API design and cache semantics: entropySourceId is currently unused in the cache key, which could cause mismatches between the signing policy and cached signatures; potential replay/reuse concerns if identical messages are signed for different intents without provenance. Recommended improvements: validate message format and provenance, incorporate entropySourceId into cache keys or policy checks, add audit logging, and implement cache eviction/invalidation rules to prevent stale signatures.

Confidence: 0.75

Severity: 0.55

From: package.jsonnpm/@metamask/[email protected]

ℹ 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 [email protected].

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/[email protected]. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template size-S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants