fix(auth): clear MFA enrollment flow state on every entry - #2473
Merged
russellwheatley merged 1 commit intoSep 2, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to reset the Multi-Factor Authentication (MFA) enrollment flow state upon entry. It adds a reset() function to MfaEnrollmentFlowState to clear all fields, and helper extensions (entersMfaEnrollment and enterMfaEnrollment) to ensure the state is cleared whenever the flow is entered. Additionally, a comprehensive test suite MfaEnrollmentEntryResetTest has been added to verify this behavior across different entry points. I have no feedback to provide.
russellwheatley
approved these changes
Sep 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MfaEnrollmentFlowStateis remembered once above the back stack and handed to every enrollment step, and six of its nine fields arerememberSaveable. Nothing ever cleared it, so re-entering the flow landed the user on a form pre-filled from the previous attempt — phone number, verification code, and a consumedsmsSessionstill live. Across a sign-out that is the previous user's data, which is the leak flagged as security-high on #2467.MfaEnrollmentFlowState.reset()returns all nine fields to the valuesrememberMfaEnrollmentFlowState()starts them at, and both host entry points now go through aNavBackStack<NavKey>.enterMfaEnrollmentthat resets before pushing — so there is no spelling of "enter the flow" that skips the clear. The clear happens on entry rather than on completion because completion is not the only exit: skip, back off the lowest step, the signed-out redirect and process death mid-flow all leave state behind, and entry is the point where a stale value is actually harmful.Entry by named step is included, and lands on the step the host asked for rather than being redirected through the resolved start step — a host deliberately showing the picker under a single-factor configuration keeps that behaviour. The funnel is a single predicate,
toKey() is AuthRoute.MfaEnrollment.Step, which theFlowEntry/Destinationsplit from #2469 makes exact: aFlowEntryresolves to its ownstartKey()and aDestinationto itself, soMfaEnrollmentand its four steps match and nothing else does — includingAuthRoute.Reauth(step = ...), whose key is theReauthwrapper.Adds 5 tests driving the real
FirebaseAuthScreenthrough sign-in, both factor branches, a successful enrollment and re-entry. Both entry sites are pinned independently rather than cross-covered, and all 12 mutation controls were verified to fail the test that names the behaviour they break — including each ofreset()'s nine fields individually.resendTimerandsmsSessionare pinned by the unit-levelreset()test only: driving a real SMS send from a host test would require naming a Firebase-internal class whose obfuscated name changes between releases (zzamin 24.0.1,zzaoin 24.2.0), which would break on the next dependency bump. That limitation is documented at the assertion.This re-lands the fix from #2463, which merged into
feat/mfa-enrollment-per-step-navan hour after that branch had already reachedversion-10.0.0-beta05, so it never arrived. It is a reimplementation rather than a cherry-pick: #2469 replaced Navigation 2 in the meantime, and the original was written againstNavHostControllerandroutestrings that no longer exist.Maintainer note: Fixes internal CPRN-384