Skip to content

fix(desktop): prevent stale backup password encryption - #7229

Draft
tellaho wants to merge 1 commit into
mainfrom
tho/fix-backup-password-race
Draft

fix(desktop): prevent stale backup password encryption#7229
tellaho wants to merge 1 commit into
mainfrom
tho/fix-backup-password-race

Conversation

@tellaho

@tellaho tellaho commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Category: fix
User Impact: Editing a backup password while encryption is running now reliably saves the backup with the final password shown in Buzz.

Problem: On slower machines, onboarding could finish encrypting with an earlier password value after the user continued editing, leaving a valid backup that rejected the password they recorded.

Solution: Password edits now invalidate the active encryption generation, so stale completions are ignored and the final value is encrypted before the backup workflow advances.

File changes

desktop/src/features/onboarding/lib/encryptedBackup.ts
Invalidate the active encryption request whenever the password changes, reusing the existing request-ID fence to reject stale results.

desktop/src/features/onboarding/lib/encryptedBackup.test.mjs
Replace the synthetic two-request scenario with the production transition: edit during request one, queue the download, reject request one's completion, and keep the final password eligible for encryption.

desktop/tests/e2e/onboarding-backup.spec.ts
Add delayed bridge coverage that widens the slow-machine race window, inspects the passwords sent across the Tauri IPC seam, and verifies onboarding advances only after encrypting the final value.

Reproduction Steps

  1. Start the desktop onboarding flow with a newly generated machine identity and choose the password-protected backup option.
  2. Enter a valid password and pause long enough for background encryption to start.
  3. Continue editing the password, then click Backup while the original request is still running.
  4. Verify the original completion is ignored, encryption runs with the final password, and onboarding advances only after that latest request succeeds.

Validation

  • pnpm check
  • pnpm test — 5,880 tests passed
  • pnpm build:e2e
  • pnpm exec playwright test tests/e2e/onboarding-backup.spec.ts tests/e2e/profile-backup-settings.spec.ts --project=smoke — 17 tests passed
  • Falsifiability mutation: removing the request invalidation makes both the reducer regression and freshly rebuilt Playwright race test fail.

The Playwright regression uses a 750 ms encryption delay to simulate the wider timing window seen on slower Windows machines. It is not native Windows execution; the repository's Windows build CI supplies platform-specific build coverage.

Invalidate in-flight onboarding backup encryption whenever the password
changes so an earlier request cannot commit under a later displayed value.
Cover the production timing sequence in reducer and delayed bridge tests.

Co-authored-by: Carl <acda9e433d19dcd0e6b6840f7f4b98f3a56f1fab98049d444c087019e6d36560@buzz.block.builderlab.xyz>
Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

🔐 Codex Security Review

Status: review required for the current range.

The current range is 1c8321cd08feb597f8bcff5195c21148fb3e98ed...ba77a1854a37a05f5d75b648b51900088f9f1724.
A new review must complete for this exact range. When manual authorization
is required, a Block organization member must comment exactly
@buzz-security-review ba77a1854a37a05f5d75b648b51900088f9f1724 to authorize a new review.
Any previous review applies only to its recorded range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant