Skip to content

fix(desktop): fall back to old keychain when DPK unavailable (unsigned builds) - #1266

Merged
wpfleger96 merged 1 commit into
mainfrom
duncan/keychain-dpk-fallback
Jun 25, 2026
Merged

wpfleger96 merged 1 commit into
mainfrom
duncan/keychain-dpk-fallback

Conversation

@wpfleger96

Copy link
Copy Markdown
Member

Problem

Unsigned and dev builds (tauri dev, hermit/cargo run) lack the hardened-runtime entitlement required by kSecUseDataProtectionKeychain. macOS returns errSecMissingEntitlement (-34018), which propagated up through store()load_or_create_identity → setup hook → panic.

This was introduced in #1264, which switched the macOS keychain backend to Data Protection Keychain. Release builds (properly signed with hardened runtime) work correctly. Dev builds do not.

Fix

Add is_dpk_unavailable(e: &SFError) -> bool that checks e.code() == -34018. All four macOS SecretStore methods (probe, load, store, delete) now have a fallback arm: when DPK returns -34018, they transparently retry via the legacy keyring crate path — the same path used on Windows and Linux.

Behavior after this fix

Build type Behavior
Signed release build DPK path — zero prompts after first device unlock
Unsigned dev build (tauri dev / hermit) Legacy keyring path — prompts once per key per session, no panic
Windows / Linux Unchanged

Files changed

  • desktop/src-tauri/src/secret_store.rs only

…d builds)

Unsigned/dev builds (tauri dev, hermit/cargo run) lack the hardened-runtime
entitlement required by kSecUseDataProtectionKeychain. macOS returns
errSecMissingEntitlement (-34018) and the app panics in the setup hook.

Treat -34018 as "DPK unavailable" across all four SecretStore methods
(probe/load/store/delete): when DPK returns that error, transparently retry
via the legacy keyring crate path. Release builds (properly signed) continue
using DPK with zero prompts. Dev builds fall back to old-keychain behavior
(prompts once per key per session) without panicking. Windows/Linux paths
are unchanged.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
@wpfleger96
wpfleger96 merged commit 958ac7a into main Jun 25, 2026
26 checks passed
@wpfleger96
wpfleger96 deleted the duncan/keychain-dpk-fallback branch June 25, 2026 02:53
wpfleger96 added a commit that referenced this pull request Jun 25, 2026
Buzz stored each secret as a separate keychain item — the identity key
plus one entry per managed agent (6 agents = 7 items total). On dev
builds (old keychain, null ACL) every read and write triggers a prompt:
15-20+ on first launch. On release builds (DPK) the first launch prompts
once per key (7 total). Goose solved this identically: one entry, all
secrets as a JSON map, one prompt total.

Switch SecretStore to the same pattern. A single blob entry (service
= the store's service name, username = "secrets") holds all keys as a
JSON map. The map is cached in-memory after the first read, so subsequent
probe/load/store/delete calls within the same process never touch the
keychain again. One prompt on first launch, zero after.

Migration: on first launch after upgrade the blob doesn't exist yet.
load() falls back to reading the old per-key DPK entry (macOS) or
legacy keyring entry (all platforms), writes it into the new blob, and
deletes the old item — one-time per key, transparent to callers.

The is_dpk_unavailable (-34018) fallback from #1266 is incorporated
here: unsigned dev builds fall back to the legacy keyring crate for the
single blob entry. The probe/load/store/delete semantics seen by callers
(IdentityKeyStore, KeyStore) are unchanged.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
wpfleger96 added a commit that referenced this pull request Jun 25, 2026
Buzz stored each secret as a separate keychain item — the identity key
plus one entry per managed agent (6 agents = 7 items total). On dev
builds (old keychain, null ACL) every read and write triggers a prompt:
15-20+ on first launch. On release builds (DPK) the first launch prompts
once per key (7 total). Goose solved this identically: one entry, all
secrets as a JSON map, one prompt total.

Switch SecretStore to the same pattern. A single blob entry (service
= the store's service name, username = "secrets") holds all keys as a
JSON map. The map is cached in-memory after the first read, so subsequent
probe/load/store/delete calls within the same process never touch the
keychain again. One prompt on first launch, zero after.

Migration: on first launch after upgrade the blob doesn't exist yet.
load() falls back to reading the old per-key DPK entry (macOS) or
legacy keyring entry (all platforms), writes it into the new blob, and
deletes the old item — one-time per key, transparent to callers.

The is_dpk_unavailable (-34018) fallback from #1266 is incorporated
here: unsigned dev builds fall back to the legacy keyring crate for the
single blob entry. The probe/load/store/delete semantics seen by callers
(IdentityKeyStore, KeyStore) are unchanged.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
BradGroux pushed a commit to BradGroux/buzz that referenced this pull request Aug 23, 2026
…d builds) (block#1266)

Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
Co-authored-by: npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7 <dcfd242e557282d7a1e2cf2e6877522682f1e5c6156dc92ca7d90eaedd3b0f95@sprout-oss.stage.blox.sqprod.co>
asiazhang added a commit to asiazhang/ledger that referenced this pull request Sep 5, 2026
* feat(encryption): 开发态回退——dev/未签名构建降级无门钥匙串缓存,自动解锁立即可用(#662)

- 运行形态判别收口纯函数 uses_biometry_gate(发布带门 / 开发无门),
  RememberMode(biometry | dev-fallback)经 RememberPassphraseSupport.mode
  暴露前端,序列化形态(kebab-case)有单测钉死
- 开发态 store 不设 access control,条目落传统钥匙串无门(与发布同
  service/account,先删后建、不留混合条目);发布构建生物门路径零变化
- 实证偏离 ticket 步骤 1/2 字面手段:macOS 26.6.2 (Tahoe, arm64) 探针证实
  无门条目写数据保护钥匙串同样 -34018(先例 block/buzz#1266),故不启用
  OSX_10_15/use_protected_keychain,偏差记录于模块注释/Cargo 注释/冒烟清单
- -34018 提为专属码化错误 encryption.remember-entitlement-restricted
  (store/load 双路径),双语模板同步,不再误报「生物认证未启用」
- 设置页开发回退形态显示本地化提示(经 i18n),Vitest 正反用例覆盖
- 冒烟清单新增第 9 节(发布构建受限)与第 10 节(无门回退);词汇表
  「自动解锁」运行形态边界更新;CHANGELOG Unreleased 记录

* docs(verification): 冒烟清单第 10 节按跨 cdhash 实测细化批准交互语义(#662
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