Skip to content

fix: harden credential persistence - #5

Merged
helsome merged 1 commit into
helsome:mainfrom
xjsns346:fix/secure-credential-persistence
Sep 2, 2026
Merged

helsome merged 1 commit into
helsome:mainfrom
xjsns346:fix/secure-credential-persistence

Conversation

@xjsns346

Copy link
Copy Markdown
Contributor

Summary

  • fail closed instead of writing Base64-obfuscated credentials when Electron safeStorage is unavailable
  • make credential writes truly atomic and surface persistence failures instead of silently falling back to a direct overwrite
  • serialize credential mutations so concurrent updates cannot overwrite each other
  • persist updatedAt metadata for provider credentials while remaining compatible with existing v1 stores and legacy plain: entries

Why

The current fallback prefixes Base64 data with plain: even though the product and architecture documentation promise encryption at rest. The persistence path also writes the destination file directly before renaming the temporary file, which defeats the atomic-write guarantee and can expose a truncated credential store after interruption. Concurrent mutations share the same temporary path and can lose updates.

Legacy plain: values remain readable so existing users are not locked out, but new credentials are never persisted unless secure OS-backed encryption is available.

Verification

  • bun test apps/electron/src/main/credentialStore.test.ts — 8 passed
  • bun run typecheck — passed for all workspaces
  • bun run build — passed
  • full suite: 1137 passed, 14 existing environment-dependent failures (missing gitignored LongBridge account fixtures/CLI plus unrelated Windows and locale-sensitive tests); no failure points to CredentialStore

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.

2 participants