encrypt passphrase full#711
Closed
aaspinwall wants to merge 1 commit into
Closed
Conversation
b5fd981 to
0d1f6ef
Compare
aaspinwall
added a commit
that referenced
this pull request
Jul 8, 2026
The passphrase (which unlocks the user's keys) was persisted as plaintext in localStorage['lb/passphrase'] — including the value shared into the add-on via the token bridge. Encrypt it at rest with a non-extractable AES-GCM-256 key held in IndexedDB (per-origin; shared across the add-on's moz-extension pages): - passphraseEncryption.ts: getOrCreatePassphraseKey (single-flight, IndexedDB), encryptPassphrase/decryptPassphrase (fresh 12-byte IV per call, auth-tagged). - Storage.storePassPhrase encrypts (plaintext fallback only when crypto/IndexedDB are unavailable, e.g. tests) and sets an in-memory plaintext cache synchronously; getPassPhrase reads that cache; initializePassphrase decrypts on load and migrates a legacy plaintext value in place; clear() drops the cache. - keychain.load() and restoreKeysUsingLocalStorage() hydrate the cache, and the router guard hydrates once per navigation so fresh windows (e.g. the /passphrase print tab) and cold reloads read the passphrase correctly. - makeBackup/restoreFromBackup now await storePassPhrase so the encrypted write is guaranteed to persist. Tests cover encrypt/decrypt round-trip, IV uniqueness, tamper + wrong-key rejection, no-plaintext-at-rest, legacy migration, and cache/clear behavior; the at-rest path, IndexedDB key persistence, and non-extractable key were also verified in a real browser. Note: the token-bridge transit value (browser.storage.local) stays plaintext — it is transient (consumed + removed) and the web/extension origins can't share the IndexedDB key; out of scope here. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
aaspinwall
added a commit
that referenced
this pull request
Jul 9, 2026
The passphrase (which unlocks the user's keys) was persisted as plaintext in localStorage['lb/passphrase'] — including the value shared into the add-on via the token bridge. Encrypt it at rest with a non-extractable AES-GCM-256 key held in IndexedDB (per-origin; shared across the add-on's moz-extension pages): - passphraseEncryption.ts: getOrCreatePassphraseKey (single-flight, IndexedDB), encryptPassphrase/decryptPassphrase (fresh 12-byte IV per call, auth-tagged). - Storage.storePassPhrase encrypts (plaintext fallback only when crypto/IndexedDB are unavailable, e.g. tests) and sets an in-memory plaintext cache synchronously; getPassPhrase reads that cache; initializePassphrase decrypts on load and migrates a legacy plaintext value in place; clear() drops the cache. - keychain.load() and restoreKeysUsingLocalStorage() hydrate the cache, and the router guard hydrates once per navigation so fresh windows (e.g. the /passphrase print tab) and cold reloads read the passphrase correctly. - makeBackup/restoreFromBackup now await storePassPhrase so the encrypted write is guaranteed to persist. Tests cover encrypt/decrypt round-trip, IV uniqueness, tamper + wrong-key rejection, no-plaintext-at-rest, legacy migration, and cache/clear behavior; the at-rest path, IndexedDB key persistence, and non-extractable key were also verified in a real browser. Note: the token-bridge transit value (browser.storage.local) stays plaintext — it is transient (consumed + removed) and the web/extension origins can't share the IndexedDB key; out of scope here. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Recreated it here #982 |
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.
No description provided.