Repository navigation
feat: detect and repair lagging recovery escrows - #11200
Conversation
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>
Acquire or renew the registration-service lease before every approval. The 6-minute lease outlives the 5-minute approval, so another operation can only take the lease after this one's approvals have expired. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Fold repairReplicas into resume(identifier): with no pending mutation, it copies the highest escrow record to escrows one version behind. Drop abort while writing: local approval expiry does not prove a delayed write cannot land, since the device clock may run ahead of the escrow's. Co-authored-by: Cursor <cursoragent@cursor.com>
- Require every escrow and one version for getIdentifiers (replica_lagging) - Probe escrows moved off expectedVersion without identifier proofs, even with receipts, so resumed writes never fork and clear without the original identifier or SIWE wallet - Clear with mutation_superseded, unsent, when a renewed approval no longer covers the payload and every remaining escrow moved - Reject updates whose identifier is not enrolled on every escrow (identifier_not_enrolled) - Let resume(identifier) authorize a pending update with another enrolled identifier - Reuse the pre-write escrow reads to find new SIWE identifiers
- Move receipt fetching, approval renewal and enrollment checks into #prepareWrite, so #replicateMutation only does the write - Name the 1FA/2FA approvals #authorizeRead/#authorizeWrite; renew an expired write approval in #reauthorizeWrite - Rename getMutationReceipts to getAppliedMutationReceipts, records to escrowIdentifiers, and unanimousMutationRejection to getRejectionFromEveryEscrow (moved to replica-utils) - planRepair returns the operation to replay and the lagging escrows - Test that an unapplied mutation stays pending when renewing its approval fails
…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
…t' into feat/mfa-recovery-locks Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # packages/mfa-recovery-controller/CHANGELOG.md
Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # packages/mfa-recovery-controller/CHANGELOG.md # packages/mfa-recovery-controller/src/MfaRecoveryController.test.ts # packages/mfa-recovery-controller/src/MfaRecoveryController.ts # packages/mfa-recovery-controller/src/identifier-auth.ts
…at/mfa-recovery-reconciliation Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # packages/mfa-recovery-controller/README.md # packages/mfa-recovery-controller/src/MfaRecoveryController-method-action-types.ts # packages/mfa-recovery-controller/src/MfaRecoveryController.ts # packages/mfa-recovery-controller/src/state-machine.ts
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…at/mfa-recovery-reconciliation Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # packages/mfa-recovery-controller/src/MfaRecoveryController.test.ts
…onciliation Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # packages/mfa-recovery-controller/CHANGELOG.md # packages/mfa-recovery-controller/src/MfaRecoveryController.test.ts # packages/mfa-recovery-controller/src/MfaRecoveryController.ts
|
A half-applied mutation gets cleared when the remaining escrows reject (functional). The old guard "no receipts yet" is gone. So if escrow A already returned a receipt and escrow B now throws MutationRejectedError, the pending mutation is cleared: MfaRecoveryController.ts The PR's reasoning is that such a mutation "is obsolete or was already repaired". But #prepareWrite has just confirmed that every remaining escrow is still at expectedVersion. If one had moved, the code would have taken the receipt or mutation_superseded path. So a rejection here can't mean "already repaired". It means some other refusal: the Cubist provider turns any policy Deny into MutationRejectedError, such as a bad identifier proof or approval timing. The result is that A ends up at newVersion and B at expectedVersion. The error tells the caller to start a new mutation, but that will fail with replica_lagging, so the user is pushed into repair, with two 2FA prompts. Before this PR, the mutation stayed writing and could be resumed. |
|
Receipts fetched from escrows are never saved before the flow continues (functional, and the docs say otherwise). #withAppliedMutationReceipts (lines 838–853) returns the receipts only in memory. They aren't written to state until line 729, which comes after assertEnrolledInEvery, a possible 2FA re-approval in #authorizeWrite, and identifier authorization. If any of those throw (2FA declined, identifier_not_enrolled, the identifier provider fails), the receipts are dropped. Escrows "keep only recent receipts", so a later resume() may find the receipt gone and clear with mutation_superseded, even though this mutation was applied. That leaves the replicas out of sync. ARCHITECTURE.md says "persist the receipts, then reread the rest", which the code doesn't do. |
|
An account can get stuck in an unrepairable state (design). getIdentifiers and every mutation now fail hard on replica_lagging, and the only way out is repair. But repair can be impossible to finish:
|
|
skips the profile check that resume() has (security, low). #prepareWrite rejects a read approval for a different profile (lines 790–795). #isUnapplied (lines 599–615) doesn't. If the user switched profiles, abort() reads the other profile's versions (for example 0, which is below newVersion) and clears a mutation that may have been applied on the original profile. The fix is to add the same sub !== mutation.profileId check. |
…onciliation Co-authored-by: Cursor <cursoragent@cursor.com>
🛑 Files requiring codeowner reviewTo merge this PR, you'll need to get approvals from the following owners. @MetaMask/web3auth (23 files)
@MetaMask/core-platform (expand for more) |
Escrow |
That's harmless, though. The next resume() fetches them again, and the escrow keeps the last 64 receipts per profile, so they'll still be there. Updated the architecture doc: e1bbe6d |
|
fixed: e14884b |
The registration service rejects a JSON content type with an empty body, so every DELETE /recovery/lock/:lock_id returned 400 and the lease was never released. Co-authored-by: Cursor <cursoragent@cursor.com>
Explanation
replica_lagging.repairReplicas(identifier). It copies the highest record to escrows one version behind, as a mutation addressed only to them (register,updateIdentifiersorupdateRecoverySecret).abortwhile writing once the approval has expired, there are no receipts, and every target escrow is still atexpectedVersion.References