Repository navigation
fix(account): require a recent MFA challenge to disable MFA - #15057
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Turning MFA off while it is in force now needs the same recent challenge as deleting an authenticator. The recency check moves onto the User document so the mfaProtected hook and the action share it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. No blocking issues — approved ✅; 2 nitpicks below. 🧹 Nitpicks (2) — 🟢 2 low
The change gates
All MFA-enforcement paths were traced: the guard is consistent with the existing Reviewed commit: 7135f67 |
🟢 Tier S · Ready to merge
The MFA disable action now requires a recent challenge when MFA is enforced, while allowing disablement when no verified second factor exists. The shared user document method centralizes the recency check used by the
📂 Walkthrough · 5
Reviewed |
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
What does this PR do?
PATCH /v1/account/mfacould turn MFA off with any fully-factored session, without a fresh challenge. Deleting an authenticator already needs a recent challenge (mfaProtected), so the disable toggle was the weaker path to the same outcome.getMinimumFactors() > 1) now needs an MFA challenge completed in the lastMFA_RECENT_DURATION, and returns401 user_challenge_requiredotherwise, the same as deleting an authenticator.User::sessionChallengeRecent(), used by both themfaProtectedhook and this action, so there is one check instead of two copies. The hook behaves the same: thesessionresource is the entry from the user'ssessions.mfaProtectedis a static route group, so it cannot apply to only one direction of the toggle. That is why the check runs in the action.Test Plan
AccountCustomClientTest::testUpdateMFADisableRequiresRecentChallenge: enabling works without a challenge; disabling without one returns 401user_challenge_requiredand MFA stays on; disabling works after a recovery-code challenge. Fails onmain(200 instead of 401) and passes with this change.AccountCustomClientTest::testUpdateMFADisableWithoutSecondFactor: MFA flagged on with no verified factor can still be turned off.UserTest::testSessionChallengeRecent: recent, stale, never-challenged and unknown sessions.Related PRs and Issues
Tracking: appwrite-labs/cloud#7053
🤖 Generated with Claude Code