From 42b20b3afda90ba9ee4cbc18209f40d606398b81 Mon Sep 17 00:00:00 2001 From: Tyler Chong Date: Thu, 5 Nov 2026 10:23:23 +0800 Subject: [PATCH 1/4] fix(money-account-mfa-whitelist): allow a Redeemer caveat on single-use deposit delegations Co-Authored-By: Claude Opus 5.5 --- .../money-account-mfa-whitelist/CHANGELOG.md | 4 ++ .../money-account-mfa-whitelist/README.md | 16 ++++---- .../src/delegation.ts | 9 ++-- .../src/get-mfa-requirement.test.ts | 41 +++++++++++++++++++ .../tests/fixtures.ts | 14 ++++++- 5 files changed, 72 insertions(+), 12 deletions(-) diff --git a/packages/money-account-mfa-whitelist/CHANGELOG.md b/packages/money-account-mfa-whitelist/CHANGELOG.md index 7d25ecbcecd..45d0c646a3d 100644 --- a/packages/money-account-mfa-whitelist/CHANGELOG.md +++ b/packages/money-account-mfa-whitelist/CHANGELOG.md @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bump `@metamask/abi-utils` from `^2.0.4` to `^3.0.0` ([#11356](https://github.com/MetaMask/core/pull/11356)) - Bump `@metamask/utils` from `^12.0.1` to `^12.0.2` ([#11474](https://github.com/MetaMask/core/pull/11474)) +### Fixed + +- Whitelist single-use vault deposit delegations that carry a `Redeemer` caveat ([#XXXXX](https://github.com/MetaMask/core/pull/XXXXX)) + ## [0.2.0] ### Added diff --git a/packages/money-account-mfa-whitelist/README.md b/packages/money-account-mfa-whitelist/README.md index 735dbffe493..0fdc6504b0c 100644 --- a/packages/money-account-mfa-whitelist/README.md +++ b/packages/money-account-mfa-whitelist/README.md @@ -52,14 +52,14 @@ if (requirement.mfaRequired) { ### Whitelist rules -| Rule | Method | Payload | -| --------------------------- | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `chomp-authentication` | `signPersonalMessage` | `CHOMP Authentication `, within `maxMessageAge` of now | -| `rewards-binding` | `signPersonalMessage` | `metamask-rewards:money-account-binding::
:` for the signing account, within `maxMessageAge` of now | -| `card-sign-in` | `signPersonalMessage` | A SIWE message for `cardSignInDomain` and the Money Account chain, signed by the account, that is not expired | -| `eip7702-authorization` | `signEip7702Authorization` | An authorization to `EIP7702StatelessDeleGatorImpl` on the Money Account chain | -| `vault-standing-delegation` | `signTypedData` (V4) | A root delegation to the CHOMP delegate with exactly a `ValueLte(0)`, an `ERC20TransferAmount` of mUSD or vault shares, and a `Redeemer` of that vault's adapter | -| `vault-deposit-delegation` | `signTypedData` (V4) | A single-use root delegation (`LimitedCalls(1)`, optionally with one `Timestamp` deadline) whose exact executions are `mUSD.approve(boringVault, amount)` followed by `teller.deposit(mUSD, amount, minimumMint, 0x0)` | +| Rule | Method | Payload | +| --------------------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `chomp-authentication` | `signPersonalMessage` | `CHOMP Authentication `, within `maxMessageAge` of now | +| `rewards-binding` | `signPersonalMessage` | `metamask-rewards:money-account-binding::
:` for the signing account, within `maxMessageAge` of now | +| `card-sign-in` | `signPersonalMessage` | A SIWE message for `cardSignInDomain` and the Money Account chain, signed by the account, that is not expired | +| `eip7702-authorization` | `signEip7702Authorization` | An authorization to `EIP7702StatelessDeleGatorImpl` on the Money Account chain | +| `vault-standing-delegation` | `signTypedData` (V4) | A root delegation to the CHOMP delegate with exactly a `ValueLte(0)`, an `ERC20TransferAmount` of mUSD or vault shares, and a `Redeemer` of that vault's adapter | +| `vault-deposit-delegation` | `signTypedData` (V4) | A single-use root delegation (`LimitedCalls(1)`, optionally with one `Timestamp` deadline and one `Redeemer` allowlist) whose exact executions are `mUSD.approve(boringVault, amount)` followed by `teller.deposit(mUSD, amount, minimumMint, 0x0)` | Every delegation must be signed by the delegator, use the root authority, and be verified by the pinned `DelegationManager` on the Money Account chain. diff --git a/packages/money-account-mfa-whitelist/src/delegation.ts b/packages/money-account-mfa-whitelist/src/delegation.ts index 2bf12a42e3a..9bca7eb7c31 100644 --- a/packages/money-account-mfa-whitelist/src/delegation.ts +++ b/packages/money-account-mfa-whitelist/src/delegation.ts @@ -265,8 +265,9 @@ function getStandingDelegationRequirement( /** * Checks a single-use transaction delegation: exactly `LimitedCalls(1)`, one * exact-execution caveat pinning a vault deposit and, optionally, one - * `Timestamp` deadline, in any order. A deadline only narrows when the - * delegation can be redeemed. + * `Timestamp` deadline and one `Redeemer` allowlist, in any order. A deadline + * and a redeemer allowlist only narrow when and by whom the delegation can be + * redeemed. * * Withdrawals, payments and Card approvals use the same shape with other * calls, so they require MFA. @@ -286,8 +287,10 @@ function getSingleUseDelegationRequirement( config.contracts.LimitedCallsEnforcer, ); const timestamp = findOnlyCaveat(caveats, config.contracts.TimestampEnforcer); + const redeemer = findOnlyCaveat(caveats, config.contracts.RedeemerEnforcer); const [exactExecution, ...unexpected] = caveats.filter( - (caveat) => caveat !== limitedCalls && caveat !== timestamp, + (caveat) => + caveat !== limitedCalls && caveat !== timestamp && caveat !== redeemer, ); if (!limitedCalls || !exactExecution || unexpected.length > 0) { return requireMfa('Single-use delegation caveats are not whitelisted'); diff --git a/packages/money-account-mfa-whitelist/src/get-mfa-requirement.test.ts b/packages/money-account-mfa-whitelist/src/get-mfa-requirement.test.ts index b5b95b51eb6..58f1d461e67 100644 --- a/packages/money-account-mfa-whitelist/src/get-mfa-requirement.test.ts +++ b/packages/money-account-mfa-whitelist/src/get-mfa-requirement.test.ts @@ -1125,6 +1125,36 @@ describe('getMfaRequirement', () => { }, ); + it.each([ + ['the extension', false], + ['Mobile', true], + ])( + 'whitelists a deposit with a deadline and relay redeemers, with caveats ordered as %s orders them', + async (_client, mobileOrder) => { + expect( + await evaluateDelegation( + buildSingleUseDelegation(buildDepositCalls(), { + mobileOrder, + deadline: 1_800_000_000, + redeemers: [RECIPIENT, MUSD], + }), + ), + ).toStrictEqual(whitelistedAs('vault-deposit-delegation')); + }, + ); + + it('requires MFA for a withdrawal with relay redeemers', async () => { + expect( + await evaluateDelegation( + buildSingleUseDelegation(buildWithdrawCalls(), { + redeemers: [RECIPIENT], + }), + ), + ).toStrictEqual( + mfaRequired('Delegation executions are not a vault deposit'), + ); + }); + it('requires MFA for a withdrawal with a deadline', async () => { expect( await evaluateDelegation( @@ -1447,6 +1477,17 @@ describe('getMfaRequirement', () => { caveats.push(deadline, deadline); }, ], + [ + 'there are two redeemer allowlists', + (caveats: UnsignedDelegation['caveats']): void => { + const redeemer = { + enforcer: CONTRACTS.RedeemerEnforcer, + terms: createRedeemerTerms({ redeemers: [RECIPIENT] }), + args: '0x' as Hex, + }; + caveats.push(redeemer, redeemer); + }, + ], [ 'there is only LimitedCalls and a deadline', (caveats: UnsignedDelegation['caveats']): void => { diff --git a/packages/money-account-mfa-whitelist/tests/fixtures.ts b/packages/money-account-mfa-whitelist/tests/fixtures.ts index f72d783940e..fdc902b2859 100644 --- a/packages/money-account-mfa-whitelist/tests/fixtures.ts +++ b/packages/money-account-mfa-whitelist/tests/fixtures.ts @@ -275,6 +275,8 @@ export function wrapInExecute(calls: Execution[]): Execution { * Mobile does, instead of `LimitedCalls` first, as the extension does. * @param options.deadline - Adds a `Timestamp` caveat after `LimitedCalls` * that expires at this Unix time, as the transaction controller does. + * @param options.redeemers - Adds a `Redeemer` caveat after the deadline that + * limits redemption to these addresses, as Mobile's gasless relay does. * @returns The unsigned delegation. */ export function buildSingleUseDelegation( @@ -282,7 +284,8 @@ export function buildSingleUseDelegation( { mobileOrder = false, deadline, - }: { mobileOrder?: boolean; deadline?: number } = {}, + redeemers, + }: { mobileOrder?: boolean; deadline?: number; redeemers?: Hex[] } = {}, ): UnsignedDelegation { const limitedCalls = { enforcer: CONTRACTS.LimitedCallsEnforcer, @@ -321,6 +324,15 @@ export function buildSingleUseDelegation( args: '0x' as Hex, }, ]), + ...(redeemers === undefined + ? [] + : [ + { + enforcer: CONTRACTS.RedeemerEnforcer, + terms: createRedeemerTerms({ redeemers }), + args: '0x' as Hex, + }, + ]), ...(mobileOrder ? [] : [exactExecution]), ], salt: `0x${'ab'.repeat(32)}`, From fe82ebbb3cb48d08efa0aeec5b49ba8cd32ddfe7 Mon Sep 17 00:00:00 2001 From: Tyler Chong Date: Thu, 5 Nov 2026 10:38:39 +0800 Subject: [PATCH 2/4] docs(money-account-mfa-whitelist): add changelog PR link Co-Authored-By: Claude Opus 5.5 --- packages/money-account-mfa-whitelist/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/money-account-mfa-whitelist/CHANGELOG.md b/packages/money-account-mfa-whitelist/CHANGELOG.md index 45d0c646a3d..18f4eb0ce41 100644 --- a/packages/money-account-mfa-whitelist/CHANGELOG.md +++ b/packages/money-account-mfa-whitelist/CHANGELOG.md @@ -14,7 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Whitelist single-use vault deposit delegations that carry a `Redeemer` caveat ([#XXXXX](https://github.com/MetaMask/core/pull/XXXXX)) +- Whitelist single-use vault deposit delegations that carry a `Redeemer` caveat ([#11310](https://github.com/MetaMask/core/pull/11310)) ## [0.2.0] From 7d10e15fcbcd103b6ce7f60cc140afe2e7b5da85 Mon Sep 17 00:00:00 2001 From: Tyler Chong Date: Fri, 13 Nov 2026 16:43:16 +0800 Subject: [PATCH 3/4] feat(money-account-mfa-whitelist): whitelist the CHOMP successor association message Co-Authored-By: Claude Opus 5.5 --- .../money-account-mfa-whitelist/CHANGELOG.md | 4 + .../money-account-mfa-whitelist/README.md | 18 +-- .../src/get-mfa-requirement.test.ts | 120 ++++++++++++++++++ .../src/personal-message.ts | 111 ++++++++++++++-- .../money-account-mfa-whitelist/src/types.ts | 5 + .../tests/fixtures.ts | 3 + 6 files changed, 241 insertions(+), 20 deletions(-) diff --git a/packages/money-account-mfa-whitelist/CHANGELOG.md b/packages/money-account-mfa-whitelist/CHANGELOG.md index 18f4eb0ce41..c1be6fa0247 100644 --- a/packages/money-account-mfa-whitelist/CHANGELOG.md +++ b/packages/money-account-mfa-whitelist/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Whitelist CHOMP's successor association message for `chompSignInDomain`, so migrating to the MPC Money Account no longer asks for MFA ([#11310](https://github.com/MetaMask/core/pull/11310)) + ### Changed - Bump `@metamask/abi-utils` from `^2.0.4` to `^3.0.0` ([#11356](https://github.com/MetaMask/core/pull/11356)) diff --git a/packages/money-account-mfa-whitelist/README.md b/packages/money-account-mfa-whitelist/README.md index 0fdc6504b0c..e07e87b211c 100644 --- a/packages/money-account-mfa-whitelist/README.md +++ b/packages/money-account-mfa-whitelist/README.md @@ -36,6 +36,7 @@ const config = { }, ], cardSignInDomain: 'link.metamask.io', + chompSignInDomain: 'chomp.api.cx.metamask.io', }; const requirement = getMfaRequirement( @@ -52,14 +53,15 @@ if (requirement.mfaRequired) { ### Whitelist rules -| Rule | Method | Payload | -| --------------------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `chomp-authentication` | `signPersonalMessage` | `CHOMP Authentication `, within `maxMessageAge` of now | -| `rewards-binding` | `signPersonalMessage` | `metamask-rewards:money-account-binding::
:` for the signing account, within `maxMessageAge` of now | -| `card-sign-in` | `signPersonalMessage` | A SIWE message for `cardSignInDomain` and the Money Account chain, signed by the account, that is not expired | -| `eip7702-authorization` | `signEip7702Authorization` | An authorization to `EIP7702StatelessDeleGatorImpl` on the Money Account chain | -| `vault-standing-delegation` | `signTypedData` (V4) | A root delegation to the CHOMP delegate with exactly a `ValueLte(0)`, an `ERC20TransferAmount` of mUSD or vault shares, and a `Redeemer` of that vault's adapter | -| `vault-deposit-delegation` | `signTypedData` (V4) | A single-use root delegation (`LimitedCalls(1)`, optionally with one `Timestamp` deadline and one `Redeemer` allowlist) whose exact executions are `mUSD.approve(boringVault, amount)` followed by `teller.deposit(mUSD, amount, minimumMint, 0x0)` | +| Rule | Method | Payload | +| ----------------------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `chomp-authentication` | `signPersonalMessage` | `CHOMP Authentication `, within `maxMessageAge` of now | +| `rewards-binding` | `signPersonalMessage` | `metamask-rewards:money-account-binding::
:` for the signing account, within `maxMessageAge` of now | +| `card-sign-in` | `signPersonalMessage` | A SIWE message for `cardSignInDomain` and the Money Account chain, signed by the account, that is not expired | +| `chomp-successor-association` | `signPersonalMessage` | CHOMP's SIWE message for `chompSignInDomain` that links the signing account as successor of one predecessor, on the Money Account chain, that is not expired | +| `eip7702-authorization` | `signEip7702Authorization` | An authorization to `EIP7702StatelessDeleGatorImpl` on the Money Account chain | +| `vault-standing-delegation` | `signTypedData` (V4) | A root delegation to the CHOMP delegate with exactly a `ValueLte(0)`, an `ERC20TransferAmount` of mUSD or vault shares, and a `Redeemer` of that vault's adapter | +| `vault-deposit-delegation` | `signTypedData` (V4) | A single-use root delegation (`LimitedCalls(1)`, optionally with one `Timestamp` deadline and one `Redeemer` allowlist) whose exact executions are `mUSD.approve(boringVault, amount)` followed by `teller.deposit(mUSD, amount, minimumMint, 0x0)` | Every delegation must be signed by the delegator, use the root authority, and be verified by the pinned `DelegationManager` on the Money Account chain. diff --git a/packages/money-account-mfa-whitelist/src/get-mfa-requirement.test.ts b/packages/money-account-mfa-whitelist/src/get-mfa-requirement.test.ts index 58f1d461e67..b1f2d6ac242 100644 --- a/packages/money-account-mfa-whitelist/src/get-mfa-requirement.test.ts +++ b/packages/money-account-mfa-whitelist/src/get-mfa-requirement.test.ts @@ -15,6 +15,7 @@ import { describe, it, expect } from 'vitest'; import { CARD_SIGN_IN_DOMAIN, + CHOMP_SIGN_IN_DOMAIN, CHAIN_ID, CONFIG, CONTRACTS, @@ -188,6 +189,35 @@ function buildCardSignInMessage( return `${domain} wants you to sign in with your Ethereum account:\n${address}\n\nProve address ownership\n\nURI: ${uri}\nVersion: 1\nChain ID: ${chainId}\nNonce: 5f2c1e0a-nonce\nIssued At: ${issuedAt}\nExpiration Time: ${expirationTime}`; } +const PREDECESSOR = '0xc1c732b47c6604f94ae69db0a34ced0b03f1fbe8'; + +function buildChompSuccessorMessage( + overrides: Partial<{ + domain: string; + address: string; + successor: string; + predecessor: string; + resourcePredecessor: string; + uri: string; + chainId: string; + issuedAt: string; + expirationTime: string; + }> = {}, +): string { + const { + domain = CHOMP_SIGN_IN_DOMAIN, + address = MONEY_ACCOUNT, + successor = MONEY_ACCOUNT.toLowerCase(), + predecessor = PREDECESSOR, + resourcePredecessor = predecessor, + uri = `https://${domain}/`, + chainId = '143', + issuedAt = new Date(NOW).toISOString(), + expirationTime = new Date(NOW + 5 * MINUTE).toISOString(), + } = overrides; + return `${domain} wants you to sign in with your Ethereum account:\n${address}\n\nAssociate ${successor} as the successor of ${predecessor} for CHOMP Money Account migration.\n\nURI: ${uri}\nVersion: 1\nChain ID: ${chainId}\nNonce: f60ff0d2a6c02b70ce5106097dabd163\nIssued At: ${issuedAt}\nExpiration Time: ${expirationTime}\nRequest ID: bcde79a3-12a8-419a-b404-579f7b5f69c3\nResources:\n- urn:chomp:profile:79678b20-061e-4246-a1de-5dc1a8074564\n- urn:chomp:purpose:ASSOCIATE_SUCCESSOR\n- urn:chomp:predecessor:${resourcePredecessor}`; +} + const whitelistedAs = (rule: string): MfaRequirement => ({ mfaRequired: false, rule }) as MfaRequirement; @@ -545,6 +575,96 @@ describe('getMfaRequirement', () => { }); }); + describe('CHOMP successor association', () => { + it('whitelists a fresh association of the Money Account as successor', () => { + expect(evaluateMessage(buildChompSuccessorMessage())).toStrictEqual( + whitelistedAs('chomp-successor-association'), + ); + }); + + it('requires MFA when no CHOMP domain is configured', () => { + expect( + evaluateMessage(buildChompSuccessorMessage(), { + ...CONFIG, + chompSignInDomain: undefined, + }), + ).toStrictEqual( + mfaRequired('Sign-in message is not for the CHOMP domain'), + ); + }); + + it('requires MFA for another domain', () => { + expect( + evaluateMessage( + buildChompSuccessorMessage({ domain: 'evil.example' }), + ), + ).toStrictEqual( + mfaRequired('Sign-in message is not for the CHOMP domain'), + ); + }); + + it('requires MFA when the URI does not match the domain', () => { + expect( + evaluateMessage( + buildChompSuccessorMessage({ uri: 'https://evil.example/' }), + ), + ).toStrictEqual( + mfaRequired('Sign-in message URI does not match its domain'), + ); + }); + + it.each([ + ['signer', { address: RECIPIENT }], + ['successor', { successor: RECIPIENT }], + ])('requires MFA when the %s is another address', (_name, overrides) => { + expect( + evaluateMessage(buildChompSuccessorMessage(overrides)), + ).toStrictEqual( + mfaRequired('Sign-in message is not for the Money Account'), + ); + }); + + it('requires MFA when the statement and resources name different predecessors', () => { + expect( + evaluateMessage( + buildChompSuccessorMessage({ resourcePredecessor: RECIPIENT }), + ), + ).toStrictEqual(mfaRequired('Sign-in message names two predecessors')); + }); + + it('requires MFA for another chain', () => { + expect( + evaluateMessage(buildChompSuccessorMessage({ chainId: '59144' })), + ).toStrictEqual( + mfaRequired('Sign-in message is not for the Money Account chain'), + ); + }); + + it('requires MFA when the message has expired', () => { + expect( + evaluateMessage( + buildChompSuccessorMessage({ + issuedAt: new Date(NOW - 3 * MINUTE).toISOString(), + expirationTime: new Date(NOW - MINUTE).toISOString(), + }), + ), + ).toStrictEqual(mfaRequired('Sign-in message is expired or not fresh')); + }); + + it('requires MFA for another purpose', () => { + expect( + evaluateMessage( + buildChompSuccessorMessage().replace( + 'urn:chomp:purpose:ASSOCIATE_SUCCESSOR', + 'urn:chomp:purpose:ASSOCIATE', + ), + ), + ).toStrictEqual( + mfaRequired('Message does not match a whitelisted format'), + ); + }); + }); + describe('card provider sign-in', () => { it('whitelists a fresh sign-in message for the Money Account', () => { expect(evaluateMessage(buildCardSignInMessage())).toStrictEqual( diff --git a/packages/money-account-mfa-whitelist/src/personal-message.ts b/packages/money-account-mfa-whitelist/src/personal-message.ts index fb356872b86..db0f23925f0 100644 --- a/packages/money-account-mfa-whitelist/src/personal-message.ts +++ b/packages/money-account-mfa-whitelist/src/personal-message.ts @@ -36,6 +36,29 @@ const CARD_SIGN_IN_PATTERN = new RegExp( 'u', ); +/** Signed by `MoneyAccountUpgradeController` to link the MPC Money Account to the account it replaces. */ +const CHOMP_SUCCESSOR_PATTERN = new RegExp( + [ + '^(?\\S+) wants you to sign in with your Ethereum account:', + '(?
0x[0-9a-fA-F]{40})', + '', + 'Associate (?0x[0-9a-fA-F]{40}) as the successor of (?0x[0-9a-fA-F]{40}) for CHOMP Money Account migration\\.', + '', + 'URI: (?\\S+)', + 'Version: 1', + 'Chain ID: (?\\d+)', + 'Nonce: \\S+', + 'Issued At: (?\\S+)', + 'Expiration Time: (?\\S+)', + 'Request ID: \\S+', + 'Resources:', + '- urn:chomp:profile:\\S+', + '- urn:chomp:purpose:ASSOCIATE_SUCCESSOR', + '- urn:chomp:predecessor:(?0x[0-9a-fA-F]{40})$', + ].join('\n'), + 'u', +); + type PersonalMessageContext = { address: Hex; config: MfaWhitelistConfig; @@ -59,6 +82,31 @@ function parseIsoTimestamp(value: string): number | undefined { return time; } +/** + * Whether a sign-in message was issued recently and has not expired. + * + * @param groups - The named groups, with `issuedAt` and `expirationTime`. + * @param now - The current time in milliseconds. + * @param maxMessageAge - The maximum message age in milliseconds. + * @returns Whether the message is fresh. + */ +function isFreshSignIn( + groups: Record, + now: number, + maxMessageAge: number, +): boolean { + const issuedAt = parseIsoTimestamp(groups.issuedAt); + const expirationTime = parseIsoTimestamp(groups.expirationTime); + return ( + issuedAt !== undefined && + expirationTime !== undefined && + isFresh(issuedAt, now, maxMessageAge) && + expirationTime > issuedAt && + expirationTime - issuedAt <= maxMessageAge && + now <= expirationTime + ); +} + /** * Checks the card provider sign-in message. It only proves ownership of the * address; funding the card needs a separate approval, which requires MFA. @@ -89,28 +137,62 @@ function getCardSignInRequirement( return requireMfa('Sign-in message is not for the Money Account chain'); } - const issuedAt = parseIsoTimestamp(groups.issuedAt); - const expirationTime = parseIsoTimestamp(groups.expirationTime); + if (!isFreshSignIn(groups, now, maxMessageAge)) { + return requireMfa('Sign-in message is expired or not fresh'); + } + + return whitelisted('card-sign-in'); +} + +/** + * Checks the CHOMP message that links the MPC Money Account, as successor, to + * the Money Account it replaces. Moving the funds needs the predecessor's own + * signature, so this only links the two addresses. + * + * @param groups - The named groups of {@link CHOMP_SUCCESSOR_PATTERN}. + * @param context - The request context. + * @param context.address - The Money Account address. + * @param context.config - The whitelist config. + * @param context.maxMessageAge - The maximum message age in milliseconds. + * @param context.now - The current time in milliseconds. + * @returns Whether MFA is required. + */ +function getChompSuccessorRequirement( + groups: Record, + { address, config, maxMessageAge, now }: PersonalMessageContext, +): MfaRequirement { + const { chompSignInDomain } = config; + if (!chompSignInDomain || groups.domain !== chompSignInDomain) { + return requireMfa('Sign-in message is not for the CHOMP domain'); + } + if (groups.uri !== `https://${chompSignInDomain}/`) { + return requireMfa('Sign-in message URI does not match its domain'); + } if ( - issuedAt === undefined || - expirationTime === undefined || - !isFresh(issuedAt, now, maxMessageAge) || - expirationTime <= issuedAt || - expirationTime - issuedAt > maxMessageAge || - now > expirationTime + !isSameHex(groups.address, address) || + !isSameHex(groups.successor, address) ) { + return requireMfa('Sign-in message is not for the Money Account'); + } + if (!isSameHex(groups.predecessor, groups.resourcePredecessor)) { + return requireMfa('Sign-in message names two predecessors'); + } + if (groups.chainId !== String(hexToNumber(config.chainId))) { + return requireMfa('Sign-in message is not for the Money Account chain'); + } + if (!isFreshSignIn(groups, now, maxMessageAge)) { return requireMfa('Sign-in message is expired or not fresh'); } - return whitelisted('card-sign-in'); + return whitelisted('chomp-successor-association'); } /** * Determines whether a personal message requires MFA. * - * Whitelisted are the CHOMP authentication message, the card provider - * sign-in message and the Rewards binding message, each with a fresh - * timestamp. At worst, signing them without MFA lets someone tie the Money + * Whitelisted are the CHOMP authentication message, the CHOMP successor + * association message, the card provider sign-in message and the Rewards + * binding message, each with a fresh timestamp. At worst, signing them without MFA lets someone tie the Money * Account to another CHOMP profile or Rewards subscription, which can deny * service but not move funds. * @@ -146,6 +228,11 @@ export function getPersonalMessageMfaRequirement( : requireMfa('Rewards binding timestamp is not fresh'); } + const chompSuccessor = CHOMP_SUCCESSOR_PATTERN.exec(text)?.groups; + if (chompSuccessor) { + return getChompSuccessorRequirement(chompSuccessor, context); + } + const cardSignIn = CARD_SIGN_IN_PATTERN.exec(text)?.groups; if (cardSignIn) { return getCardSignInRequirement(cardSignIn, context); diff --git a/packages/money-account-mfa-whitelist/src/types.ts b/packages/money-account-mfa-whitelist/src/types.ts index 965740a50b0..b52a22e9f31 100644 --- a/packages/money-account-mfa-whitelist/src/types.ts +++ b/packages/money-account-mfa-whitelist/src/types.ts @@ -54,6 +54,11 @@ export type MfaWhitelistConfig = { * link host). The sign-in message requires MFA when this is not set. */ cardSignInDomain?: string; + /** + * The domain of the CHOMP sign-in message that links the MPC Money Account + * to the account it replaces. The message requires MFA when this is not set. + */ + chompSignInDomain?: string; /** * How far, in milliseconds, a signed message's timestamp may be from the * current time. Defaults to five minutes. diff --git a/packages/money-account-mfa-whitelist/tests/fixtures.ts b/packages/money-account-mfa-whitelist/tests/fixtures.ts index fdc902b2859..ff16d9e909b 100644 --- a/packages/money-account-mfa-whitelist/tests/fixtures.ts +++ b/packages/money-account-mfa-whitelist/tests/fixtures.ts @@ -76,6 +76,8 @@ export const PREMIUM_VAULT = { export const CARD_SIGN_IN_DOMAIN = 'link.metamask.io'; +export const CHOMP_SIGN_IN_DOMAIN = 'chomp.example.com'; + export const NOW = Date.parse('2026-10-09T12:00:00.000Z'); export const CONFIG: MfaWhitelistConfig = { @@ -85,6 +87,7 @@ export const CONFIG: MfaWhitelistConfig = { chompDelegateAddress: CHOMP_DELEGATE, vaults: [VAULT, PREMIUM_VAULT], cardSignInDomain: CARD_SIGN_IN_DOMAIN, + chompSignInDomain: CHOMP_SIGN_IN_DOMAIN, }; export const MAX_UINT256 = 2n ** 256n - 1n; From 6937b3aa1d66e12ff4a3fac97637560510c40b70 Mon Sep 17 00:00:00 2001 From: Tyler Chong Date: Mon, 16 Nov 2026 17:16:32 +0800 Subject: [PATCH 4/4] fix(money-account-mfa-whitelist): add chomp-successor-association to MfaWhitelistRule Co-Authored-By: Claude Opus 5.5 --- .../src/get-mfa-requirement.test.ts | 7 +++++-- packages/money-account-mfa-whitelist/src/types.ts | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/money-account-mfa-whitelist/src/get-mfa-requirement.test.ts b/packages/money-account-mfa-whitelist/src/get-mfa-requirement.test.ts index b1f2d6ac242..4a48e2839b7 100644 --- a/packages/money-account-mfa-whitelist/src/get-mfa-requirement.test.ts +++ b/packages/money-account-mfa-whitelist/src/get-mfa-requirement.test.ts @@ -46,6 +46,7 @@ import type { MfaSignerContext, MfaRequirement, MfaWhitelistConfig, + MfaWhitelistRule, MoneyAccountSignatureRequest, } from './types.js'; @@ -218,8 +219,10 @@ function buildChompSuccessorMessage( return `${domain} wants you to sign in with your Ethereum account:\n${address}\n\nAssociate ${successor} as the successor of ${predecessor} for CHOMP Money Account migration.\n\nURI: ${uri}\nVersion: 1\nChain ID: ${chainId}\nNonce: f60ff0d2a6c02b70ce5106097dabd163\nIssued At: ${issuedAt}\nExpiration Time: ${expirationTime}\nRequest ID: bcde79a3-12a8-419a-b404-579f7b5f69c3\nResources:\n- urn:chomp:profile:79678b20-061e-4246-a1de-5dc1a8074564\n- urn:chomp:purpose:ASSOCIATE_SUCCESSOR\n- urn:chomp:predecessor:${resourcePredecessor}`; } -const whitelistedAs = (rule: string): MfaRequirement => - ({ mfaRequired: false, rule }) as MfaRequirement; +const whitelistedAs = (rule: MfaWhitelistRule): MfaRequirement => ({ + mfaRequired: false, + rule, +}); const mfaRequired = (reason: string): MfaRequirement => ({ mfaRequired: true, diff --git a/packages/money-account-mfa-whitelist/src/types.ts b/packages/money-account-mfa-whitelist/src/types.ts index b52a22e9f31..0e60615a9d8 100644 --- a/packages/money-account-mfa-whitelist/src/types.ts +++ b/packages/money-account-mfa-whitelist/src/types.ts @@ -109,6 +109,7 @@ export type MoneyAccountSignatureRequest = export type MfaWhitelistRule = | 'chomp-authentication' | 'card-sign-in' + | 'chomp-successor-association' | 'rewards-binding' | 'eip7702-authorization' | 'vault-standing-delegation'