Skip to content

fix(sandbox): 扣密钥时密封双平台 lark-cli 密钥库 - #3672

Merged
deepcoldy merged 1 commit into
masterfrom
wt/botmux-claude-fix-pr-3649-cd-keystore
Nov 20, 2026
Merged

deepcoldy merged 1 commit into
masterfrom
wt/botmux-claude-fix-pr-3649-cd-keystore

Conversation

@deepcoldy

Copy link
Copy Markdown
Owner

改了什么

修复 #3649 合入后发现的 macOS 密钥扣留绕过:sandboxWithholdBotSecret=true 时,macOS 整库 deny 只有 baseline,能被同路径 workingDir、sandboxPaths 或更深层精确 key 授权覆盖;Linux 的深层精确 key 授权也有同类问题。

  • macOS 整库与当前 bot 的 master.key.file、appsecret_<appId>.enc 统一使用 mandatory ceiling。
  • Linux 默认及 LARKSUITE_CLI_DATA_DIR 自定义 keystore 同步覆盖。
  • withheld store 内所有非 deny 规则在 merge 后过滤,避免 sibling/token/future-file 通过 longest-prefix 重开父目录。
  • Seatbelt 在 finalReadOnlyPaths 之后重新发射 withheld-store deny,HOME 或 / 的祖先授权也不能覆盖密钥。
  • larkTransportEnabled=false 的会话也纳入同一密封集合;非 withhold 的 own-key 只读 carve-out 保持不变。

影响面

仅影响 sandboxWithholdBotSecret=true 的 oncall 会话,覆盖 macOS/Linux、transport/no-transport、默认及自定义 keystore。其它会话配置与现有 own-key 认证路径不变。relay-session-tool.ts 的 P2-2 修复不在本 PR 内。

实际验证

  • bun run build:通过。
  • fs-policy、沙盒与测试卫生:293 项通过、6 项跳过;Bun 相关 65 项通过。
  • 覆盖 workingDir、userPaths readWrite/readOnly、精确 key、custom/default store、HOME// 祖先、sibling/token/future-file、no-transport。
  • 变异复验:分别移除整库 mandatory、精确 key mandatory、keystore 内非 deny 过滤、最终 Seatbelt deny,均确定性咬红后恢复。
  • 独立对抗复核:transport 与 no-transport 下均未再发现密钥库重开路径,非 withhold 行为未变化。

macOS 限制:本机为 Linux,仅验证真实 compileToSeatbelt 生成的 profile 与 last-match 发射顺序;未执行 macOS 内核级真机验证,需 darwin 真机复核。

🤖 Generated with Claude Code

- macOS 整库与当前 bot key 改为 mandatory ceiling;Linux 默认/自定义 keystore 同步覆盖
- withheld store 内所有非 deny 规则在 merge 后过滤,阻断 sibling/token/future-file 的深层授权;Seatbelt 在 finalReadOnlyPaths 之后重发最终 deny,HOME 或 / 的祖先授权也不能重开密钥
- larkTransportEnabled=false 的会话同样纳入密封集合;非 withhold 的 own-key 只读 carve-out 保持不变

验证:bun run build;fs-policy/沙盒/测试卫生 293 项通过、6 项跳过;Bun 相关 65 项通过。workingDir、userPaths、精确 key、祖先、sibling、custom store、no-transport 变异均咬红后恢复。独立复核未发现重开路径。macOS 仅验证编译 profile 与发射顺序,未做真机运行验证。

Co-Authored-By: Claude Code <[email protected]>
@deepcoldy

Copy link
Copy Markdown
Owner Author

独立复核(首审 Claude,针对 Kimi 实现的合后 P2-1 修复)结论:可合(同仓 PR 无法用 GitHub APPROVE 自批,双审结论以评审群记录为准)。

【密封有效性 — 真实 buildFsPolicy/accessForPath/compileToSeatbelt 探针】
darwin withhold 下 7 个攻击向量全部 deny/mandatory、Seatbelt backstop 均在最后:对照(无关 workingDir)、workingDir=整库(internal)、userPaths rw 整库、userPaths 直指 ownKey、userPaths ro 整库、深层 sibling/token/future-file、HOME 祖先授权。no-transport 会话三向量同样密封。

【无正常 auth 回归】
非 withhold 时 darwin/linux 的 own-key readOnly carve-out 保持、sibling 仍 deny;linux withhold + workingDir=store 仍 deny。

【独立变异(均咬红后还原)】

  1. darwin 三层 mandatory→baseline:5 测试红(workingDir/user rw store/精确 key/ro/Seatbelt)
  2. 去掉 merge 后深层授权过滤:精确只让 sibling/future 用例红
  3. 去掉 Seatbelt finalDenyPaths 兜底:4 个祖先授权/Seatbelt 用例红

【验证】tsc 0 错、build 过;fs-policy/sandbox-relay/hygiene 214 项 + cli-relay/send-cred/freeze/background-guards/ipc 115 项 vitest 全绿;bun 腿 60 项全绿;merge-tree 对最新 master 无冲突;与 #3671 文件零重叠可并行。

【G9 边界】Seatbelt 编译 profile 与 last-match 发射顺序已由单测验证,但 darwin 内核级 sandbox-exec 强制效果未在 macOS 真机执行(Kimi 已注明),建议登记一次 macOS 真机回归窗口,与 #3649 同类 follow-up 一并安排。

最终以维护者审阅为准。

@deepcoldy
deepcoldy merged commit a4970c9 into master Nov 20, 2026
20 checks passed
@deepcoldy

Copy link
Copy Markdown
Owner Author

已合入。macOS 内核级 sandbox-exec 真机验证(本 PR 的 finalDenyPaths last-match 兜底 + #3649 的 process-info/file-write-unlink 规则)单测覆盖不到,已开跟踪 issue #3676 安排 darwin 真机回归窗口。

@github-actions

Copy link
Copy Markdown

@deepcoldy 合入 master 后的 Midscene E2E 失败:Feishu live Midscene 失败。

这次运行覆盖 885b8fb…a0b04a957(4 个提交),同批合入的还有 #3671 #3665 #3675,失败不一定由本 PR 引起。

用例 跑道 状态 失败信息
OhMyPi basic bot flow feishu-core-clis failed Failed to continue: The page remains completely blank/white after waiting and reloading. Cannot find the "Topics" filter tab because no UI elements are rendered on the page. The Feishu messenger page…

@github-actions

Copy link
Copy Markdown

🚀 Released in v3.59.25

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