修复 AGC Windows ACL 提权与文件访问边界 #211

Merged
kdletters merged 7 commits from fix/windows-acl into master 2026-08-31 14:37:35 +08:00
Member

背景

Windows 下 AGC 读取配置目录、项目文件和本地资源时,可能先于 ACL 校验阶段就因继承权限、错误 owner 或拒绝访问而失败,表现为 拒绝访问。 (os error 5)

此前自定义 --config-dir 场景还存在 scope 无法传递到提权子进程的问题;native picker 路径也缺少进程内来源证明,递归索引可能跟随 junction/reparse point,新建文件在权限加固失败时可能留下残留文件。

本次变更

  1. 修复自定义 --config-dirmanaged / user-selected scope 传递与提权票据校验。
  2. 增加 native picker 文件/目录路径的短期 provenance 授权;未经过 picker 授权的任意 IPC 绝对路径不能触发 user-selected 自动提权。
  3. 项目文件列表和索引递归改用 symlink_metadata(),拒绝 symlink、junction 和 Windows reparse point。
  4. 统一在 metadata/read/open 前完成 ACL 准备,对 ACL 导致的 metadata 失败执行一次受控修复和重试。
  5. 新建 conversation、导出包、Agent DB、资源、字体等文件在 harden 失败时关闭句柄并清理刚创建的文件。
  6. 修复 UAC 提权授权票据以 share_mode(0) 独占打开后与 GetNamedSecurityInfoW/SetNamedSecurityInfoW 产生共享冲突的问题。
  7. 同步 AGC Windows ACL 技术方案与安全回归测试。

安全行为

  • UAC 取消返回 1223,不会被当作成功。
  • 提权子进程重新校验目标路径、scope、当前用户 SID、nonce、有效期和票据一次性消费。
  • symlink、junction、reparse point 和非普通文件对象保持失败关闭。
  • 自定义配置目录可以位于用户 profile 外部,但仍受 owner、DACL 和路径类型校验。

验证结果

已执行并通过:

cargo check --locked --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml
cargo test --locked --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml private_path_elevation_policy_tests -- --nocapture
# 10 passed

cargo test --locked --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml local_project -- --nocapture
# 20 passed

cargo test --locked --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml checkpoint::security_tests -- --nocapture
# 10 passed

cargo test --locked --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml private_file_write_tests -- --nocapture
# 2 passed

npm run check:encoding
# 5554 files passed

git diff --check
# passed

另外确认:

  • origin/master 是当前分支祖先。
  • 交接文档已删除,且原本不在 Git 跟踪列表中。
  • 全量 cargo test 未作为通过依据;此前存在与 ACL 无关的失败项。
  • cargo fmt --check 仍受仓库已有格式漂移影响,本次未执行全仓库格式化。
  • 真实 Windows UAC 点击“Yes”的手工回归仍需在目标机器上确认。

手工验收

使用:

& "C:\Users\dongy\workspace\Genarrative\.worktrees\agc-windows-acl-fix\apps\ai-game-creator-shell\src-tauri\target\debug\genarrative-ai-game-creator-shell.exe" `
  --config-dir "C:\Users\dongy\AppData\Local\Temp\agc-acl-live-20260830\deny-config-2"

验收标准:

  1. 选择“否”:进程返回 exit code 1223
  2. 重新启动并选择“Yes”:不再返回 exit code 1,ACL 修复完成后继续启动。
  3. 再次启动同一配置目录:不应重复弹出修复。
  4. 检查目录 owner 和 DACL,确认归当前用户所有且为私有权限。
### 背景 Windows 下 AGC 读取配置目录、项目文件和本地资源时,可能先于 ACL 校验阶段就因继承权限、错误 owner 或拒绝访问而失败,表现为 `拒绝访问。 (os error 5)`。 此前自定义 `--config-dir` 场景还存在 scope 无法传递到提权子进程的问题;native picker 路径也缺少进程内来源证明,递归索引可能跟随 junction/reparse point,新建文件在权限加固失败时可能留下残留文件。 ### 本次变更 1. 修复自定义 `--config-dir` 的 `managed / user-selected` scope 传递与提权票据校验。 2. 增加 native picker 文件/目录路径的短期 provenance 授权;未经过 picker 授权的任意 IPC 绝对路径不能触发 `user-selected` 自动提权。 3. 项目文件列表和索引递归改用 `symlink_metadata()`,拒绝 symlink、junction 和 Windows reparse point。 4. 统一在 metadata/read/open 前完成 ACL 准备,对 ACL 导致的 metadata 失败执行一次受控修复和重试。 5. 新建 conversation、导出包、Agent DB、资源、字体等文件在 harden 失败时关闭句柄并清理刚创建的文件。 6. 修复 UAC 提权授权票据以 `share_mode(0)` 独占打开后与 `GetNamedSecurityInfoW/SetNamedSecurityInfoW` 产生共享冲突的问题。 7. 同步 AGC Windows ACL 技术方案与安全回归测试。 ### 安全行为 - UAC 取消返回 `1223`,不会被当作成功。 - 提权子进程重新校验目标路径、scope、当前用户 SID、nonce、有效期和票据一次性消费。 - symlink、junction、reparse point 和非普通文件对象保持失败关闭。 - 自定义配置目录可以位于用户 profile 外部,但仍受 owner、DACL 和路径类型校验。 ### 验证结果 已执行并通过: ``` cargo check --locked --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml cargo test --locked --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml private_path_elevation_policy_tests -- --nocapture # 10 passed cargo test --locked --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml local_project -- --nocapture # 20 passed cargo test --locked --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml checkpoint::security_tests -- --nocapture # 10 passed cargo test --locked --manifest-path apps/ai-game-creator-shell/src-tauri/Cargo.toml private_file_write_tests -- --nocapture # 2 passed npm run check:encoding # 5554 files passed git diff --check # passed ``` 另外确认: - `origin/master` 是当前分支祖先。 - 交接文档已删除,且原本不在 Git 跟踪列表中。 - 全量 `cargo test` 未作为通过依据;此前存在与 ACL 无关的失败项。 - `cargo fmt --check` 仍受仓库已有格式漂移影响,本次未执行全仓库格式化。 - 真实 Windows UAC 点击“Yes”的手工回归仍需在目标机器上确认。 ### 手工验收 使用: ```powershell & "C:\Users\dongy\workspace\Genarrative\.worktrees\agc-windows-acl-fix\apps\ai-game-creator-shell\src-tauri\target\debug\genarrative-ai-game-creator-shell.exe" ` --config-dir "C:\Users\dongy\AppData\Local\Temp\agc-acl-live-20260830\deny-config-2" ``` 验收标准: 1. 选择“否”:进程返回 `exit code 1223`。 2. 重新启动并选择“Yes”:不再返回 `exit code 1`,ACL 修复完成后继续启动。 3. 再次启动同一配置目录:不应重复弹出修复。 4. 检查目录 owner 和 DACL,确认归当前用户所有且为私有权限。
suzmii added 1 commit 2026-08-30 18:03:59 +08:00
修复 AGC Windows ACL 提权与文件访问边界
Project CI / Frontend tests (pull_request) Successful in 3m55s
Project CI / Backend tests (pull_request) Failing after 4m29s
Project CI / Native shell tests (pull_request) Failing after 5m56s
Project CI / Repository checks (pull_request) Successful in 3m21s
78e4fbdfe4
修复自定义 --config-dir 的 ACL 提权 scope 传递

增加 native picker 路径 provenance 与短期授权

拒绝 symlink、junction 和 Windows reparse point 递归

统一 metadata/read 前 ACL 准备并补强新建文件失败清理

修复 UAC 授权票据独占句柄导致的共享冲突

同步 AGC Windows ACL 技术方案与安全回归测试
kdletters requested changes 2026-08-31 10:46:43 +08:00
kdletters left a comment
Member

当前 head 的 Backend tests 与 Native shell tests 均失败,需先修复并重新跑完整 CI 后再合并。失败状态见该提交的 Project CI;本次先请求修改。

当前 head 的 Backend tests 与 Native shell tests 均失败,需先修复并重新跑完整 CI 后再合并。失败状态见该提交的 Project CI;本次先请求修改。
Member

请在修复 Backend/Native shell CI 失败并取得最新全绿结果后再合并;当前远端门禁仍为失败。

请在修复 Backend/Native shell CI 失败并取得最新全绿结果后再合并;当前远端门禁仍为失败。
suzmii added 1 commit 2026-08-31 10:52:16 +08:00
Merge branch 'master' into fix/windows-acl
Project CI / Frontend tests (pull_request) Successful in 3m26s
Project CI / Repository checks (pull_request) Successful in 3m5s
Project CI / Backend tests (pull_request) Failing after 3m14s
Project CI / Native shell tests (pull_request) Failing after 7m36s
4651197458
suzmii added 1 commit 2026-08-31 11:18:46 +08:00
Merge branch 'master' into fix/windows-acl
Project CI / Frontend tests (pull_request) Successful in 3m51s
Project CI / Backend tests (pull_request) Successful in 7m8s
Project CI / Native shell tests (pull_request) Failing after 12m2s
Project CI / Repository checks (pull_request) Successful in 3m13s
01ec370808
Author
Member

Close #216

Close #216
suzmii added 2 commits 2026-08-31 11:58:42 +08:00
更新项目字体符号链接错误文案断言

同步自动工作区链接拒绝断言
Merge remote-tracking branch 'origin/fix/windows-acl' into fix/windows-acl
Project CI / Repository checks (pull_request) Successful in 3m48s
Project CI / Frontend tests (pull_request) Successful in 4m25s
Project CI / Backend tests (pull_request) Successful in 7m19s
Project CI / Native shell tests (pull_request) Successful in 15m34s
12c4447cd1
suzmii requested review from kdletters 2026-08-31 12:50:27 +08:00
suzmii added 1 commit 2026-08-31 14:31:45 +08:00
Merge branch 'master' into fix/windows-acl
Project CI / Repository checks (pull_request) Successful in 5m13s
Project CI / Backend tests (pull_request) Successful in 9m50s
Project CI / Frontend tests (pull_request) Successful in 12m3s
Project CI / Native shell tests (pull_request) Successful in 29m10s
d330cb78bc
kdletters added 1 commit 2026-08-31 14:37:24 +08:00
Merge branch 'master' into fix/windows-acl
Project CI / Repository checks (pull_request) Successful in 2m42s
Project CI / Frontend tests (pull_request) Successful in 4m21s
Project CI / Backend tests (pull_request) Successful in 6m38s
Project CI / Native shell tests (pull_request) Successful in 18m47s
0aa82b79fd
kdletters merged commit 80b8238d0a into master 2026-08-31 14:37:35 +08:00
kdletters deleted branch fix/windows-acl 2026-08-31 14:37:35 +08:00
Sign in to join this conversation.