feat(auth): require recovery PIN and strip identifying metadata from Drive backups#538
Merged
Merged
Conversation
…Drive backups Google-account-only custody meant anyone with the Google login could decrypt the nsec; the filename leaked the npub to Drive; the chooser's profile prefetch told relays which npubs were on this device. - Derive the backup key from PBKDF2-HMAC-SHA256(PIN, salt=HMAC(sub)) with 600k iterations. PIN is a 4–8 digit numeric set during sign-in with a confirm step; mismatch and wrong-PIN paths surface inline. - Pull `sub` from the signed ID token's JWT instead of GoogleIdTokenCredential.id (which is the email, not stable across Workspace renames). - Use opaque `wisp_bk_<uuid>.bin` filenames and recover the npub by decrypting. Drop the delete-then-upload race since there's no longer a replace path. - Seed the chooser's profile REQ with 10 decoy pubkeys pulled from a popular relay so observers can't pick the real backups out of the query.
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.
Summary
External review of the new "Continue with Google" / Drive backup flow surfaced several issues. This PR addresses the security and privacy ones; the unreleased feature lets us land them without a migration path.
What changed
HMAC(sub). Compromising the Google account alone no longer decrypts the nsec.subclaim, notparsed.id.GoogleIdTokenCredential.idis the user's email and can change (Workspace renames). The JWTsubis the stable Google account ID.wisp_bk_<uuid>.bin. The npub is no longer leaked to Drive and is recovered by decrypting. The delete-then-upload race in the old code is gone — each new account creates a fresh file.UX changes
SetupPinflow (enter → confirm → mismatch retry) on first sign-in, with a "if you forget this PIN your Nostr key is gone forever" warning.EnterPinForRestoreflow when backups are found; wrong PIN surfaces inline and lets the user retry.Notes
wisp_nsec_<npub>.binfilename / email-based key derivation is dropped entirely with no migration path. Any orphaned files in testers' appDataFolder will not be listed and can be cleaned up manually.Test plan
wisp_bk_<uuid>.binfiles (filenames don't contain npub)