feat(db): delete passkey wraps when a password reset rotates kB - #21128
Open
vpomerleau wants to merge 2 commits into
Open
feat(db): delete passkey wraps when a password reset rotates kB#21128vpomerleau wants to merge 2 commits into
vpomerleau wants to merge 2 commits into
Conversation
Because: * A wrap seals kB to the generation in `keysChangedAt`, so a reset that rotates kB leaves rows that can never open again. * Asking for the password up front beats asking after a failed unwrap. This commit: * Adds `resetAccount_20`, deleting `passkeyWraps` alongside `recoveryKeys` in the existing `keysHaveChangedArg` block. The passkeys survive, so the credentials stay usable for re-enrolment. * Covers both branches of that guard in `test/remote/db.in.spec.ts`. * Adds `passkeys` and `passkeyWraps` fixtures to fxa-shared and moves the fixture proc to `resetAccount_20`. Closes FXA-14421
Because: * `nx run db-migrations:migrate` does not exist; the package defines only lint, test-unit and test-integration. * The old text also omitted bumping `target-patch.json`, without which the patcher is a no-op. This commit: * Points at the patcher, notes `yarn start` already runs it, and refers to the databases README rather than restating it.
vpomerleau
requested review from
nshirley
and
a balanced review from Copilot
September 1, 2026 18:16
Contributor
There was a problem hiding this comment.
Pull request overview
Deletes obsolete passkey wraps whenever password reset rotates kB, while preserving passkey credentials for re-enrolment.
Changes:
- Adds and adopts
resetAccount_20. - Adds fixtures and integration coverage for both key-change branches.
- Updates migration instructions.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
packages/fxa-shared/test/db/models/auth/sp_resetAccount.sql |
Updates the fixture procedure and wrap deletion. |
packages/fxa-shared/test/db/models/auth/passkeys.sql |
Adds the passkeys test table. |
packages/fxa-shared/test/db/models/auth/passkey-wraps.sql |
Adds the wraps test table. |
packages/fxa-shared/test/db/models/auth/helpers.ts |
Loads the new fixtures. |
packages/fxa-shared/db/models/auth/base-auth.ts |
Selects resetAccount_20. |
packages/fxa-auth-server/test/remote/db.in.spec.ts |
Tests wrap deletion and preservation. |
packages/db-migrations/databases/fxa/target-patch.json |
Advances schema level to 198. |
packages/db-migrations/databases/fxa/patches/patch-198-197.sql |
Adds the commented rollback. |
packages/db-migrations/databases/fxa/patches/patch-197-198.sql |
Creates the updated reset procedure. |
CLAUDE.md |
Corrects migration instructions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
vpomerleau
marked this pull request as ready for review
September 1, 2026 18:20
nshirley
approved these changes
Sep 1, 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.
Because
keysChangedAt. A password reset without a recovery key advances it, so every wrap on the account is permanently undecryptable.This pull request
resetAccount_20(patch-197-198), deletingpasskeyWrapsinside the existingIF keysHaveChangedArg = 1block alongsiderecoveryKeys.passkeysrows in place, so the credential stays usable for re-enrolment.Proc.ResetAccountat the new procedure.packages/fxa-auth-server/test/remote/db.in.spec.ts.passkeysandpasskeyWrapsfixtures to the fxa-shared auth test schema and moves the fixture procedure toresetAccount_20.CLAUDE.md. Unrelated to the ticket — the documentednxtarget does not exist.Issue that this pull request solves
Closes: FXA-14421
Checklist
Put an
xin the boxes that applyHow to review (Optional)
patch-197-198.sql— the procedure isresetAccount_19verbatim plus oneDELETE, so the diff againstpatch-159-160.sqlis the useful comparison.base-auth.ts, then the tests.Proc.ResetAccountmoves everydb.resetAccountcaller to the new procedure at once.Screenshots (Optional)
Please attach the screenshots of the changes made in case of change in user interface.
Other information (Optional)
account.passkey.wrap_invalidatedstays registered but unused:account.resetis the parent event, and other rows a reset drops don't raise their own.scripts/recorded-future/check-and-reset.ts) was checked per the ticket comment and deliberately left unchanged. It randomizeswrapWrapKbbut leaveskeysChangedAtuntouched, so it does not rotate kB — rotation happens at the user's follow-up reset, which this procedure covers.