Skip to content

fix(windows): DPAPI vault fallback when Credential Manager fails (#1061) - #1141

Open
Ohualtex wants to merge 1 commit into
Louis-CFM:mainfrom
Ohualtex:fix/windows-dpapi-secrets-fallback
Open

Ohualtex wants to merge 1 commit into
Louis-CFM:mainfrom
Ohualtex:fix/windows-dpapi-secrets-fallback

Conversation

@Ohualtex

Copy link
Copy Markdown
Contributor

Adds an encrypted per-user Windows DPAPI fallback store for secrets when Windows Credential Manager rejects writes or lookups (such as Windows error code 8 / ERROR_NOT_ENOUGH_MEMORY blocking Phone Link setup).

Changes (#1061)

  • Cargo feature (windows 0.61): Enables Win32_Security_Cryptography in windows/src-tauri/Cargo.toml.
  • Encrypted per-user DPAPI vault (windows/src-tauri/src/secrets.rs):
    • Uses CryptProtectData / CryptUnprotectData (CRYPTPROTECT_UI_FORBIDDEN) with explicit app entropy and atomic writes under %LOCALAPPDATA%\Coucou\vault hardened via platform::ensure_private_dir.
    • When keyring (set / set_internal) fails on Windows (e.g. Windows error code 8), persists the secret via DPAPI fallback without logging secret values.
    • Falls back to reading from the DPAPI vault in get / get_internal if Credential Manager has no entry or returns an error, and cleans both stores on clear / empty set_internal.
    • Enforces the exact same KNOWN_KEYS vs INTERNAL_KEYS boundary before touching either store.

Testing

  • Added secrets::tests::dpapi_vault_round_trips_large_secret_and_deletes_cleanly verifying 4 KB secret encryption on disk (no plaintext leak), decryption, path validation, and deletion.
  • Ran cargo test --lib secrets::tests and cargo test --lib phone_link::.

Closes #1061

This branch has not been deployed

No deployments
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.

Phone link can't be enabled: "no secure storage for the pairing code: Platform secure storage failure: Windows error code 8"

1 participant