Electron 应用开发者需要 macOS Data Protection Keychain 而不是 legacy keychain
Electron 应用在 macOS 上保存密钥时,官方 safeStorage 走 legacy file-based keychain,同机其他应用或后台 agent 可用 security 命令查询;作者因此为 Electron 自建了使用 Data Protection Keychain 的 keychain-store,用代码签名访问组和 Touch ID/密码规则限制取用。
目标用户
在 macOS 上开发 Electron 应用、需要保护本地密钥或敏感数据不被同机其他进程读取的开发者
潜在需求
需要一种能对接 macOS Data Protection Keychain 的存储方式,通过代码签名 access groups 和访问规则(如 Touch ID 或密码)限制哪些应用可以取回密钥,而不是让所有本机进程都能读取。
发生场景
开发者在 Electron 应用里保存加密数据的密钥时,官方 safeStorage 默认使用 legacy file-based keychain;当机器上同时运行多个后台 agent 或其他应用时,它们可以用 security CLI 查询同一 keychain,密钥缺少进程级隔离。
来源证据
Electron 的 safeStorage 使用 legacy file-based keychain,同机其他应用或 agent 可以用 security CLI 查询;Data Protection Keychain 可通过代码签名访问组和访问规则限制取用。
Hey HN, I've been working on Hansel [1] (an encrypted personal data store you can query with agents), and there wasn't a good way to use the modern macOS Data Protection Keychain. Electron's safeStorage [2] uses the legacy file-based keychain, which allows other apps/agents to query it with the `security` CLI. Not great when you have a dozen agents running in the background! The Data Protection Keychain is nice because it limits access via code-signing access groups and lets you set access ruleshttps://news.ycombinator.com/item?id=49349159
为什么值得留意
信号来自正在构建加密个人数据存储的作者,是实际项目中的具体阻碍:local 安全边界在机器上运行多个 agent 的场景下变得更关键,而 Electron 官方方案没有覆盖这一层;若更多开发者遇到同样限制,就存在可被一个专用库或封装填补的缺口。
已有方案
- Electron safeStorage(legacy file-based keychain)
未满足部分
- 官方 safeStorage 不支持使用 macOS Data Protection Keychain
- Electron 生态中缺少现成好用的 Data Protection Keychain 封装,作者只能自己实现
目前未知
- 帖子由项目作者发布,当前无评论,缺少独立用户反馈
- safeStorage 的 legacy keychain 行为细节未在本帖中展开验证
- 其他 Electron 开发者是否同样遇到这一阻碍尚不清楚
继续核实
- 除作者外,还有多少 Electron 应用开发者意识到 safeStorage 的 keychain 可被其他本机进程查询?
- macOS Data Protection Keychain 的代码签名 access group 在 Electron 分发与自动更新场景下是否稳定可用?
- keychain-store 是否被其他项目采用并解决同类需求?