Skip to content

feat: add per-profile recovery locks - #10910

Merged
ieow merged 18 commits into
mainfrom
feat/mfa-recovery-locks
Nov 12, 2026
Merged

ieow merged 18 commits into
mainfrom
feat/mfa-recovery-locks

Conversation

@huggingbot

@huggingbot huggingbot commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

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

@huggingbot
huggingbot requested review from a team as code owners October 20, 2026 11:31
Base automatically changed from cw/mfa-recovery-controller to main October 21, 2026 08:24
huggingbot and others added 8 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>
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>
@huggingbot
huggingbot force-pushed the feat/mfa-recovery-locks branch from 8cd9124 to 19c3300 Compare October 29, 2026 10:27
@huggingbot
huggingbot changed the base branch from main to feat/mfa-recovery-siwe-enrollment October 29, 2026 10:27
…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
Base automatically changed from feat/mfa-recovery-siwe-enrollment to main November 11, 2026 02:53
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
@ieow

ieow commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Stale lockId after a failed acquire: confirmed. The client writes lockId to state before calling acquire. If the API returns 409 because another operation owns the lease, the stale ID stays in state. Medium severity.

@ieow

ieow commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

releaseLock() stuck on an expired lease: partly wrong. I said the API would return 404 on an expired lease. It doesn't. The API's DELETE returns 204 when the lease is absent, so an expired lease that nobody else took releases cleanly. The real remaining case is narrower: our lease expired, another operation took it, and DELETE returns 409. The client throws recovery_lock_conflict and keeps the stale lockId. It recovers only after the other operation releases. The fix is to clear lockId when release returns 409, since we no longer own the lease. Low-to-medium severity.

@ieow

ieow commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Expired lease is a dead end on the approval path: confirmed. The API's PUT never recreates an expired lease and returns 409. The approval path (#authorizeMutation) renews with no fallback to acquire. Expired and owned-by-another both return 409, and the client maps both to recovery_lock_conflict, so it can't tell them apart. Medium severity.

@ieow

ieow commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Stub doesn't match the real lock (tests/stubs.ts). StubRecoveryLockProvider.release silently succeeds for a non-owner (the real API returns 409), and the stub has no expiry, so the expired-renew path is never tested.

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

Copy link
Copy Markdown
Member Author

Stale lockId after a failed acquire: confirmed. The client writes lockId to state before calling acquire. If the API returns 409 because another operation owns the lease, the stale ID stays in state. Medium severity.

fixed here

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

Copy link
Copy Markdown
Member Author

releaseLock() stuck on an expired lease: partly wrong. I said the API would return 404 on an expired lease. It doesn't. The API's DELETE returns 204 when the lease is absent, so an expired lease that nobody else took releases cleanly. The real remaining case is narrower: our lease expired, another operation took it, and DELETE returns 409. The client throws recovery_lock_conflict and keeps the stale lockId. It recovers only after the other operation releases. The fix is to clear lockId when release returns 409, since we no longer own the lease. Low-to-medium severity.

fixed here

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

Copy link
Copy Markdown
Member Author

Expired lease is a dead end on the approval path: confirmed. The API's PUT never recreates an expired lease and returns 409. The approval path (#authorizeMutation) renews with no fallback to acquire. Expired and owned-by-another both return 409, and the client maps both to recovery_lock_conflict, so it can't tell them apart. Medium severity.

fixed here by removing renew API. The acquire API will simply renew

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

Copy link
Copy Markdown
Member Author

Stub doesn't match the real lock (tests/stubs.ts). StubRecoveryLockProvider.release silently succeeds for a non-owner (the real API returns 409), and the stub has no expiry, so the expired-renew path is never tested.

fixed here

@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

@ieow
ieow added this pull request to the merge queue Nov 12, 2026
Merged via the queue into main with commit 616e29d Nov 12, 2026
44 checks passed
@ieow
ieow deleted the feat/mfa-recovery-locks branch November 12, 2026 06:47
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