Skip to content

feat: prove new SIWE identifiers with recovery mutations - #11151

Merged
huggingbot merged 15 commits into
mainfrom
feat/mfa-recovery-siwe-enrollment
Nov 11, 2026
Merged

huggingbot merged 15 commits into
mainfrom
feat/mfa-recovery-siwe-enrollment

Conversation

@huggingbot

@huggingbot huggingbot commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Explanation

Stacked on #11149. SIWE wallets prove control themselves (Auth doesn't vouch for them).

  • applyMutation takes IdentifierAuthorization[], sharing one challenge per escrow.
  • Each SIWE identifier an escrow hasn't enrolled gets a proof, including at register. SIWE is exempt from the approvedIdentifiers check.

References

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

@huggingbot
huggingbot force-pushed the feat/mfa-recovery-get-identifiers branch from 325168d to 8e5ddad Compare October 28, 2026 09:46
@huggingbot
huggingbot force-pushed the feat/mfa-recovery-siwe-enrollment branch from 3c2e40c to 77ec26a Compare October 28, 2026 13:11
@huggingbot
huggingbot marked this pull request as ready for review October 28, 2026 14:12
@huggingbot
huggingbot requested review from a team as code owners October 28, 2026 14:12
huggingbot and others added 7 commits October 29, 2026 15:39
Add getIdentifiers to the controller and CubistEscrowProvider (escrow #8),
and pass the operation's AuthController token to generateChallenge (escrow #10).

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Send identifierAuthorizations as a list sharing one challenge per escrow
(escrow #7): one proof per SIWE identifier the escrow has not enrolled,
plus the enrolled-identifier proof for updates.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@huggingbot
huggingbot force-pushed the feat/mfa-recovery-siwe-enrollment branch from 8e373aa to 023dfc5 Compare October 29, 2026 07:42
@huggingbot
huggingbot force-pushed the feat/mfa-recovery-get-identifiers branch from cc92526 to 3d6bb9b Compare October 29, 2026 07:42
@ieow

ieow commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

@metamaskbot publish-preview

@ieow

ieow commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

The two-identifier minimum can be bypassed with SIWE address casing. The new code treats SIWE addresses as case-insensitive when matching enrolled identifiers. But countDistinctIdentifiers and isApprovedSubset still compare exact strings. So register(secret, [WALLET, walletLowercase]) passes the MIN_IDENTIFIERS check locally even though it's one wallet.

@ieow

ieow commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

The SIWE namespace check accepts junk. getSiweNamespace runs String() on whatever the verifier holds. A verifier of {} with namespace "undefined:undefined" passes register (confirmed). It should require domain to be a non-empty string and chainId to be a positive integer. It should also reject a domain that contains a colon, which would make domain:chainId ambiguous.

@huggingbot

Copy link
Copy Markdown
Member Author

The two-identifier minimum can be bypassed with SIWE address casing. The new code treats SIWE addresses as case-insensitive when matching enrolled identifiers. But countDistinctIdentifiers and isApprovedSubset still compare exact strings. So register(secret, [WALLET, walletLowercase]) passes the MIN_IDENTIFIERS check locally even though it's one wallet.

fixed here

@huggingbot

Copy link
Copy Markdown
Member Author

The SIWE namespace check accepts junk. getSiweNamespace runs String() on whatever the verifier holds. A verifier of {} with namespace "undefined:undefined" passes register (confirmed). It should require domain to be a non-empty string and chainId to be a positive integer. It should also reject a domain that contains a colon, which would make domain:chainId ambiguous.

fixed here

Base automatically changed from feat/mfa-recovery-get-identifiers to main November 10, 2026 02:00
…e-enrollment

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	packages/mfa-recovery-controller/CHANGELOG.md
#	packages/mfa-recovery-controller/src/MfaRecoveryController.ts
#	packages/mfa-recovery-controller/src/escrow-providers/cubist-escrow-provider.test.ts
#	packages/mfa-recovery-controller/src/escrow-providers/cubist-escrow-provider.ts
#	packages/mfa-recovery-controller/src/identifier-auth.ts
@ieow

ieow commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

A mutation can get stuck with no way out. PR https://github.com/consensys-vertical-apps/cubist-secret-escrow/pull/7 rejects malformed SIWE input with an error, not a deny. The core client then leaves the operation in the writing phase, where abort() isn't allowed and resume() keeps failing. These cases hit it:

The same address twice in different case.
A malformed address or domain.
A domain or chain ID that isn't on the allowlist.
More than 16 identifiers.
A proof missing for a new wallet, or sent twice for the same wallet.
Anything other than exactly one enrolled-identifier proof.
Only conflicts with stored state (version mismatch, already registered, identifier owned by another profile) come back as a deny.

@ieow

ieow commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

@metamaskbot publisth-preview

Co-authored-by: Cursor <cursoragent@cursor.com>
@huggingbot

Copy link
Copy Markdown
Member Author

A mutation can get stuck with no way out. PR consensys-vertical-apps/cubist-secret-escrow#7 rejects malformed SIWE input with an error, not a deny. The core client then leaves the operation in the writing phase, where abort() isn't allowed and resume() keeps failing. These cases hit it:

The same address twice in different case. A malformed address or domain. A domain or chain ID that isn't on the allowlist. More than 16 identifiers. A proof missing for a new wallet, or sent twice for the same wallet. Anything other than exactly one enrolled-identifier proof. Only conflicts with stored state (version mismatch, already registered, identifier owned by another profile) come back as a deny.

fixed here

Co-authored-by: Cursor <cursoragent@cursor.com>
@ieow

ieow commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

nits:
Bad SIWE input isn't caught before signing. SIWE wallets now skip Auth's approved-list check, but the controller doesn't copy the escrow's SIWE checks: address format, domain characters, duplicates after lowercasing, and at most 16 identifiers. Bad input only fails at the escrow, after the user has signed every wallet prompt. Since e690af6, the user then also has to wait for the approval to expire before they can abort.

If the app calls resume() automatically, for example on unlock or at startup, each attempt does this:

It asks for a new approval, which means another MFA prompt.
It asks for every wallet signature again.
It fails at the escrow again, because the input is still bad.
It saves the new approval, which moves its expiry forward.
So every resume() resets the wait before abort() is allowed. An app that resumes more often than the approval lifetime keeps the user stuck, with repeated MFA and wallet prompts, until they stop resuming and wait it out. Nothing in the error tells the user or the app that the input is the problem.

@ieow

ieow commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

nits
Extra SIWE proofs only matter when escrows are out of sync. If escrow A (N+1) already has the wallet and escrow B (N) doesn't, A errors on the extra proof and B denies the version. Nothing is applied, but #isUnapplied needs every escrow at expectedVersion, so abort() stays refused.

ieow
ieow previously approved these changes Nov 10, 2026

@ieow ieow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@huggingbot

Copy link
Copy Markdown
Member Author

nits: Bad SIWE input isn't caught before signing. SIWE wallets now skip Auth's approved-list check, but the controller doesn't copy the escrow's SIWE checks: address format, domain characters, duplicates after lowercasing, and at most 16 identifiers. Bad input only fails at the escrow, after the user has signed every wallet prompt. Since e690af6, the user then also has to wait for the approval to expire before they can abort.

If the app calls resume() automatically, for example on unlock or at startup, each attempt does this:

It asks for a new approval, which means another MFA prompt. It asks for every wallet signature again. It fails at the escrow again, because the input is still bad. It saves the new approval, which moves its expiry forward. So every resume() resets the wait before abort() is allowed. An app that resumes more often than the approval lifetime keeps the user stuck, with repeated MFA and wallet prompts, until they stop resuming and wait it out. Nothing in the error tells the user or the app that the input is the problem.

fixed here

@huggingbot

Copy link
Copy Markdown
Member Author

nits Extra SIWE proofs only matter when escrows are out of sync. If escrow A (N+1) already has the wallet and escrow B (N) doesn't, A errors on the extra proof and B denies the version. Nothing is applied, but #isUnapplied needs every escrow at expectedVersion, so abort() stays refused.

fixed here

@ieow

ieow commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

nits:
resume() now drops writes that failed for temporary reasons (medium, design). The new check can't tell a permanent failure (bad input) from a temporary one (the device or escrows were offline when the write was sent). If a device goes offline mid-write and resumes after the approval expires, the mutation is cleared instead of completed. Before, the rule was that writing always finishes through resume(). A future caller that has already changed local state, for example a client that switched to the new secret during updateRecoverySecret, would need to handle this and redo the operation. No package in core uses the controller yet, so now is the time to decide. Options:
Clear only when every escrow failed with the same error that isn't a network failure.
Or document clearly that an expired, unapplied writing mutation is dropped.

@ieow ieow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@huggingbot
huggingbot added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit 3dacebb Nov 11, 2026
43 checks passed
@huggingbot
huggingbot deleted the feat/mfa-recovery-siwe-enrollment branch November 11, 2026 02:53
Naz-Ovh pushed a commit to 0x-fork/metamask-core that referenced this pull request Nov 14, 2026
## Explanation

- Add `RecoveryRegistrationLockProvider` and `acquireLock` / `renewLock`
/ `releaseLock`.
- Acquire or renew the lease before every approval. The 6-minute lease
outlives the 5-minute approval, and escrows reject expired approvals, so
another operation can only take the lease once this one's approvals are
dead.
- Persist `lockId` so retries and restarts reuse the lease. Release is
blocked while a mutation is pending.

Client flow: `acquireLock` → read → change Auth identifiers → mutate /
`resume` → `releaseLock`.

## References

- Stacked on MetaMask#11151
- Registration API:
consensys-vertical-apps/va-mmcx-recovery-registration-service-api#21

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants