修复 Game Agent 项目外读取的父目录链接绕过
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
Project CI / AI game creator shell Rust smoke (pull_request) Has been cancelled
Project CI / AI game creator shell Rust crates (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Has been cancelled

文件读取和目录列表逐段拒绝符号链接及 Windows 重解析点
新增受保护目录别名与文件链接回归测试,保留普通外部读取
同步技术方案与排障记录,明确真实路径要求
This commit is contained in:
2026-09-29 13:34:59 +01:00
parent 5454062423
commit 0dacfec429
4 changed files with 80 additions and 7 deletions
@@ -2,6 +2,7 @@
## 2026-09-29 Game Agent 读工具被项目相对路径规则拦住
- 项目外读取不能只依赖末段 `O_NOFOLLOW`:父目录符号链接可隐藏 `.ssh` 等受保护名字。文件读取和目录列表在访问前逐段检查原始路径,拒绝符号链接与 Windows 重解析点;目录扫描对子目录再次检查。系统临时目录若含平台别名(例如 macOS `/var`),普通读取测试使用临时目录的 canonical 路径,不能通过 canonicalize 待读路径来抹掉待检测链接。
- 现象:`agc_read_project_context` 或 `agc_list_project_files` 对绝对路径返回「项目文件路径不能是绝对路径」,对 `..` 返回「项目文件路径非法」。
- 原因:这两条读取入口以前直接调用共享 `normalize_relative_path`。该函数同时服务项目浏览、快照和写入,不能放宽。
- 处理:读取入口改走 `resolve_game_agent_read_path`。绝对路径和离开项目的 `..` 可以读;项目内的 `.agent`、凭据文件名、符号链接和硬链接仍然拒绝。写入、补丁、素材导入和 `read-only` 沙箱不变。