Skip to content

Security hardening: encrypt wallet secrets at rest + fix exec/IPC/XSS/nav, dedupe @bsv/sdk - #53

Merged
sirdeggen merged 10 commits into
masterfrom
security/encrypt-secrets-at-rest
Jun 19, 2026
Merged

Security hardening: encrypt wallet secrets at rest + fix exec/IPC/XSS/nav, dedupe @bsv/sdk#53
sirdeggen merged 10 commits into
masterfrom
security/encrypt-secrets-at-rest

Conversation

@sirdeggen

Copy link
Copy Markdown
Contributor

Summary

Changes

Secrets at rest (#5)

  • electron/secretStore.ts — main-process store at userData/secrets.dat, per-entry Electron safeStorage ciphertext (key in OS keychain, not beside the data). Name allow-list, atomic writes, warned plaintext fallback when no OS keyring (incl. Linux basic_text).
  • secrets:get-all/set/delete IPC + preload + types.
  • src/lib/services/secrets.ts — synchronous renderer facade over a cache hydrated once at boot; one-time migration of legacy plaintext localStorage, cleared after.
  • main.tsx awaits hydration before mount; all ~30 call sites routed through the facade; logout() now clears the store (localStorage.clear() no longer reaches it).
  • Limit (documented): protects vs other apps/users/backups/disk theft, not same-user malware on Win/Linux — passphrase upgrade tracked separately.

Non-breaking hardening

Deps

  • Bump @bsv/* to latest; @bsv/sdk -> 2.1.6, toolbox(-client) -> 2.1.30. Collapses the duplicate @bsv/sdk (nested 2.1.2) that caused the LookupResolver nominal-type clash in WalletService.ts.

Docs

  • Design spec + implementation plan under docs/superpowers/; docs/SECURITY_REVIEW.md remediation status updated.

Test plan

  • npx vitest run --config vitest.config.electron.ts — 69 passed (incl. new secretStore/secrets.renderer suites)
  • npm run build:renderer — green (was red pre-dedupe); renderer tsc 0 errors
  • npm run build:electron — green, secretStore.js emitted
  • Manual: fresh install creates encrypted secrets.dat; upgrade migrates+clears legacy plaintext; logout forgets wallet; Linux-no-keyring falls back with warning

🤖 Generated with Claude Code

sirdeggen and others added 10 commits June 19, 2026 00:37
…nifest proxy

Non-breaking fixes from docs/SECURITY_REVIEW.md:
- #2 exec -> execFile (no shell interpolation) in sslCert.ts and main.ts;
  validate restored bundle identifier.
- #3 allow-list the storage:call-method IPC to the methods StorageElectronIPC
  actually calls; reject everything else.
- #4 sanitize update release notes with DOMPurify before dangerouslySetInnerHTML.
- #6/#10 only http(s) reaches shell.openExternal; add will-redirect handler;
  block javascript:/file:/data:/custom protocols.
- #9 re-validate the resolved URL (https + /manifest.json) after redirects.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Move snap/primaryKeyHex/mnemonic12 out of renderer localStorage into a
main-process file encrypted with Electron safeStorage. Toolbox snapshots
store their AES key inside the blob, so they offer no at-rest protection today.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Hydrate the secret cache at boot before the wallet tree mounts, migrate
legacy plaintext localStorage on first run, and replace every snap/
primaryKeyHex/mnemonic12 localStorage access with the secrets facade.
logout() now clears the secret store explicitly since localStorage.clear()
no longer reaches the secrets.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
wallet-toolbox / wallet-toolbox-client -> 2.1.30 (pin @bsv/sdk ^2.1.3),
@bsv/sdk -> 2.1.6. Collapses the duplicate @bsv/sdk that nested 2.1.2
under wallet-toolbox-client, which had caused the LookupResolver type
clash in WalletService.ts and broke `tsc`/build:renderer. Renderer tsc
now 0 errors; full test suite green (69 passed).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Deggen <d.kellenschwiler@bsvassociation.org>
@sirdeggen
sirdeggen merged commit cbf1bf9 into master Jun 19, 2026
5 checks passed
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