Skip to content

fix(money-account-api-data-service): validate SIWE challenge before signing - #11112

Merged
ffmcgee725 merged 2 commits into
mainfrom
fix/MUSD-1490-validate-siwe-challenge-message
Oct 27, 2026
Merged

ffmcgee725 merged 2 commits into
mainfrom
fix/MUSD-1490-validate-siwe-challenge-message

Conversation

@ffmcgee725

@ffmcgee725 ffmcgee725 commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Explanation

The service currently checks only that the challenge response has nonce and message, then asks the keyring to sign challenge.message verbatim, so a modified challenge can produce a signature over content the user never saw. This rebuilds the Money Account SIWE template from the challenge nonce and parsed issuedAt and requires an exact match, so a wrong domain, URI, address, statement, version, chain ID, nonce, or timestamp is rejected before signing. The 5-minute window, 60-second future-skew allowance, and template fields are pinned to the API's buildSiweMessage.

References

Fixes MUSD-1490

Related: MUSD-1483

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
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

High Risk
Changes VBA SIWE authentication so invalid or tampered challenge messages are rejected before wallet signing, which is security-critical for transfer access.

Overview
Adds client-side SIWE challenge validation so VBA auth no longer signs whatever the challenge endpoint returns after a shallow shape check.

A new siwe-message module rebuilds the Money Account API SIWE template (domain/URI from env, pinned statement, chain ID 143, 5‑minute TTL, 60s future skew) and requires an exact match on domain, URI, address, statement, version, chain ID, nonce, and timestamps before KeyringController:signPersonalMessage runs. Mismatches, malformed nonces, expiry, or extra/missing lines throw MoneyAccountApiResponseValidationError without retrying the challenge fetch.

Constants document the pinned API contract; unit and fetchVbaTransfers tests cover rejection paths and confirm signing is skipped for invalid challenges.

Reviewed by Cursor Bugbot for commit cf62fcc. Bugbot is set up for automated code reviews on this repo. Configure here.

@ffmcgee725
ffmcgee725 marked this pull request as ready for review October 27, 2026 10:17
@ffmcgee725
ffmcgee725 requested review from a team as code owners October 27, 2026 10:17
@ffmcgee725
ffmcgee725 added this pull request to the merge queue Oct 27, 2026
Merged via the queue into main with commit c8cec09 Oct 27, 2026
65 checks passed
@ffmcgee725
ffmcgee725 deleted the fix/MUSD-1490-validate-siwe-challenge-message branch October 27, 2026 11:27
@ffmcgee725 ffmcgee725 mentioned this pull request Oct 27, 2026
gaohan1994 pushed a commit to gaohan1994/core that referenced this pull request Oct 28, 2026
## Packages

-
[`@metamask/money-account-api-data-service@2.3.1`](https://github.com/MetaMask/core/blob/release/1370.0.0/packages/money-account-api-data-service/CHANGELOG.md#231)
(patch)

### `@metamask/money-account-api-data-service`

#### Changed

- Bump `@metamask/utils` from `^12.0.0` to `^12.0.1`
([MetaMask#11107](MetaMask#11107))

#### Fixed

- Validate VBA SIWE challenge messages against the expected Money
Account template before signing, rejecting a message whose domain, URI,
address, statement, version, chain ID, nonce, or timestamps do not match
([MetaMask#11112](MetaMask#11112))

### Dependency notes

Other changed packages (`@metamask/base-data-service`,
`@metamask/controller-utils`, `@metamask/messenger`) were marked
`intentionally-skip` in the release spec: their current published
versions satisfy this package's dependency ranges, and their pending
changes are not required by
[MetaMask#11112](MetaMask#11112).

The sole dependent of this package,
`@metamask/money-account-balance-service`, had its dependency range
updated from `^2.3.0` to `^2.3.1` in lockstep.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> The release ships SIWE pre-sign validation for VBA auth; behavior
changes for invalid or tampered challenges are security-relevant even
though this PR only versions and documents that fix.
> 
> **Overview**
> This PR cuts **release 1370.0.0** by bumping the root monorepo version
and publishing **`@metamask/money-account-api-data-service@2.3.1`**
(patch). The diff is release wiring only: package versions, changelogs,
`yarn.lock`, and a dependent range update on
**`@metamask/money-account-balance-service`** (`^2.3.0` → `^2.3.1`).
> 
> **2.3.1** (documented in the changelog, not new code in this diff)
includes a **`@metamask/utils`** bump to `^12.0.1` and a **security
fix** that validates VBA SIWE challenge messages against the expected
Money Account template before signing, rejecting mismatches in domain,
URI, address, statement, version, chain ID, nonce, or timestamps
([MetaMask#11112](MetaMask#11112)).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
c1fef7b. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
darkwing pushed a commit to darkwing/metamask-mobile that referenced this pull request Oct 29, 2026
…38371)

## **Description**

Bumps `@metamask/money-account-api-data-service` from `2.3.0` to
`2.3.1`, the release that validates Money Account SIWE challenges before
signing
([MetaMask/core#11112](MetaMask/core#11112),
shipped in core release `1370.0.0`).

`2.3.1` rebuilds the expected SIWE message from the challenge nonce and
the parsed `Issued At`, and requires an exact match before the service
calls `KeyringController:signPersonalMessage`. A challenge with a wrong
domain, URI, address, statement, version, chain ID, nonce, or timestamp
— or an expired/future challenge — now throws
`MoneyAccountApiResponseValidationError` instead of producing a
signature over content the user never approved.

No mobile source changes are required: `moneyAccountApiDataServiceInit`
already passes the `Env` derived from `MM_API_ENV`, and the service
derives its SIWE domain/URI from the same `MONEY_ACCOUNT_API_URL_MAP`.
The lockfile resolves a single copy of the package for both the direct
dependency and `@metamask/money-account-balance-service`.

## **Changelog**

CHANGELOG entry: null

## **Related issues**

Refs:
[MUSD-1490](https://consensyssoftware.atlassian.net/browse/MUSD-1490)
Refs:
[MUSD-1483](https://consensyssoftware.atlassian.net/browse/MUSD-1483)
Refs: [MetaMask/core#11112](MetaMask/core#11112)

## **Manual testing steps**

```gherkin
Feature: Money Account VBA transfers authenticate with a validated SIWE challenge

  Scenario: Valid challenge loads VBA activity
    Given a Money Account with VBA transfers and the VBA activity feature flags enabled
    When the user opens Money activity
    Then pending and completed VBA transfers load as before

  Scenario: Tampered challenge is rejected before signing
    Given the Money Account API returns a challenge message that does not match the SIWE template
    When the service requests VBA transfers
    Then no personal_sign request is made
    And the transfers query fails with MoneyAccountApiResponseValidationError
```

Automated coverage for both scenarios lives in the core package
(`money-account-api-data-service`). Mobile unit tests for the service
init, messenger, and Money VBA hooks pass. Not manually tested on
device; this is a draft PR.

## **Screenshots/Recordings**

### **Before**

N/A — dependency bump, no UI change.

### **After**

N/A — dependency bump, no UI change.

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

#### Performance checks (if applicable)

- [x] I've tested on Android
- [x] I've tested with a power user scenario
- [x] I've instrumented key operations with Sentry traces for production
performance metrics

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.

<!-- Generated with the help of the pr-description AI skill -->


[MUSD-1490]:
https://consensyssoftware.atlassian.net/browse/MUSD-1490?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Pulls in stricter pre-sign SIWE validation on Money Account API auth
paths; valid flows should be unchanged, but any API/challenge mismatch
will fail earlier with no personal_sign prompt.
> 
> **Overview**
> Bumps **`@metamask/money-account-api-data-service`** from `2.3.0` to
**`2.3.1`** in `package.json` and `yarn.lock` only—no mobile app source
changes.
> 
> The new release tightens **Money Account SIWE authentication**: before
calling `KeyringController:signPersonalMessage`, the service rebuilds
the expected SIWE message from the challenge nonce and `Issued At` and
requires an exact match. Tampered or invalid challenges (wrong domain,
URI, address, nonce, timestamps, etc.) now throw
**`MoneyAccountApiResponseValidationError`** instead of signing content
the user never approved.
> 
> Existing wiring (e.g. `moneyAccountApiDataServiceInit` with
`MM_API_ENV` → `Env`) stays the same; VBA transfers and other Money API
flows pick up the validation automatically.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
fd76adf. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

This branch was previously deployed

1 inactive deployment
default-branch — cf62fcc7 Deployed Oct 27, 2026 by ffmcgee725 via Determine whether this PR is a release PR #6091
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.

2 participants