Make backup keygen cancellable and clear retained plaintext passwords - #564
Merged
Merged
Conversation
Cancel was disabled exactly while the up-to-3-minute key derivation ran, with interactive dismissal also blocked, so the keygenCancelled state was unreachable. A dismissed view could still complete the key change because onDisappear never cancelled the task and the sync KDF cannot observe cancellation — check it explicitly before storing the derived key. Clear the entered plaintext passwords on every exit path except mid-correction confirm-mismatch. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
The backup key-change screen advertised "up to 3 minutes" of key derivation but was uncancellable in practice:
.disabled(isLoading)— disabled exactly while the keygen ran, withinteractiveDismissDisabledalso active, so the.keygenCancelledstate was unreachable from the UI.onDisappeardid not cancelkeyGenerationTask, so a dismissed view could still completestore(backupPassword:)in the background and silently replace the user's backup password.Fix
.creating(comment documents why); swipe-dismiss remains blocked.onDisappearcancels the in-flight keygen task before resetting state.try Task.checkCancellation()after the KDF returns and before the derived key replaces the stored password — cancellation is now authoritative; worst case the CPU work completes in the detached task and is discarded, leaving the old backup password intact.didDisappear()and on the keygen-error/cancelled paths. Deliberately retained on confirm-mismatch (user is mid-correction, view still frontmost — documented inline).Tests
saveEnteredPassword_cancelledBeforeStore_setsKeygenCancelledAndDoesNotStore(store mocksetnever called)saveEnteredPassword_cancelled_clearsEnteredPasswords,_keygenError_clearsEnteredPasswords,_passwordConfirmError_retainsEnteredPasswords,didDisappear_clearsEnteredPasswordslayoutCreatingState(light/dark): view pinned in.creatingvia a blocking test deriver, wrapped in aNavigationStackso the toolbar renders — the enabled Cancel button is the point of the image.Local verification: VaultFeedTests + VaultiOSTests schemes passed on iPhone 18 Pro Max / iOS 27.0 (snapshot recorded, then clean pass).
🤖 Generated with Claude Code