Skip to content

Key storage: legacy plaintext key is never migrated; vault readable from content scripts #36

Done

Description

@jjohare

From a re-audit of main at bd39ce8. Nothing here exposes the key to a web page, and the cryptography checks out: all 92 published NIP-44 v2 vectors pass against src/nip44.js, invalid cases included, and the documented passkey vector reproduces. These are storage and lifecycle gaps.

  • Silent identity loss for pre-0.0.8 installs. Builds before Security overhaul: consolidated hardening of the key-holding signer (consent UI, session-only key, NIP-44, NIP-98 replay fix, CI) #22 stored podkey_private_key unencrypted in chrome.storage.local. Nothing migrates it into the vault. After an upgrade, the status check reports no key and sends the user to setup; the next generate or import runs storeKeypair, which deletes the old key (src/storage.js:51) with no warning and no export offered. If the user never sets up again, the plaintext key stays on disk. "Forget key" does not remove it (popup/popup.js:571), and export still falls back to reading it (popup/popup.js:713). Fix: on update, if the legacy key exists, require the user to seal it under a passphrase or export it before it is removed; add it to the Forget wipe; drop the export fallback.
  • Vault and passkey records are readable from the content-script world on every site. src/injected.js:113-121 uses chrome.storage.local and onChanged, and that area is exposed to content scripts by default, so podkey_vault, the passkey wrapped blob and any legacy key are reachable from a compromised renderer on any site. The unlocked key in storage.session is not. Fix: stop the content script touching chrome.storage (the service worker can push it the one sidestr flag it needs) and move key-bearing records to IndexedDB on the extension origin. The sidestr signer pins and chain cache (src/sidestr/settings.js:339-343) are writable the same way and share the fix.
  • Offline guessing cost (src/vault.js:24, :46). scrypt at N=2^16, and the 8-character minimum counts UTF-16 units, so four emoji pass. Matters more given the point above.
  • No idle auto-lock. The unlocked key lives for the whole browser session.
  • A signed event can carry an id that does not match its contents (src/crypto.js:156 with src/background.js:389), through type coercion of the fields the page supplies. Integrity only; fix by validating field types before hashing.
  • NIP-44 decrypt has no upper length bound (src/nip44.js:184-206), and the repo's tests carry two hard-coded vectors and none of the invalid ones. Vendor the published vector file into test/fixtures.
  • Passkey setup rolls back on one failure path only (popup/popup.js:399-406).
  • Hand-written encoders. bech32, base64 and a constant-time compare are local code. They test correct; @scure/base covers the first two.

For discussion, not a defect: the vault blob and the passkey wrap are project-specific envelopes, and site/passkey-identity.html specifies the derivation in normative language for other implementations. NIP-49 would fit the passphrase vault, and age or JWE the wrap. Worth deciding before more implementations depend on it.

Activity

  1. added
    bug
    on Nov 28, 2026
  2. jjohare commented on Nov 28, 2026

    @jjohare
    CollaboratorAuthor

    Addressed in 0.0.13 (a2265b7): the legacy unencrypted key is reported, sealed under a passphrase and removed only once the vault reads back; storage is set to trusted contexts; new vaults use scrypt N=2^17 with stored parameters bounded; passphrase length counts code points; Podkey locks on screen lock and after 30 minutes unused; events with malformed fields are refused; NIP-44 decrypt is bounded and tested against the published vectors; passkey setup rolls back on any failure; the encoders come from @scure/base; export needs the passphrase or passkey. The envelope question is #45, and IndexedDB and the remaining items are in #47.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions