Harden Windows package paths (T-605)
This commit is contained in:
+12
-5
@@ -3,12 +3,12 @@ id: T-605
|
||||
title: 统一 Windows 安全路径校验并封堵 ZIP 逃逸
|
||||
phase: 1
|
||||
deps: [T-102, T-201, T-202, T-604]
|
||||
status: TODO
|
||||
status: DONE
|
||||
created: 2026-07-16
|
||||
issue: null
|
||||
context_ref: null
|
||||
context_ref: f7a803d944d3ef1c782aa974d5114f51d3e00b17
|
||||
claim_branch: null
|
||||
work_branch: null
|
||||
work_branch: agent/codex/T-605
|
||||
write_paths:
|
||||
- docs/tasks/T-605.md
|
||||
- core/internal/safepath/
|
||||
@@ -26,6 +26,7 @@ write_paths:
|
||||
- docs/api.md
|
||||
- docs/04-architecture.md
|
||||
- docs/05-coding-rules.md
|
||||
- docs/00-ai-start-here.md
|
||||
- docs/current-state.md
|
||||
---
|
||||
|
||||
@@ -42,7 +43,7 @@ Extractor 的正式调用约束是 Catalog 签名与 ZIP SHA-256 已验证后才
|
||||
1. 在 `core/internal/safepath` 建立 Go 1.20 兼容、无 Windows API 依赖的共享 Windows 安全相对路径策略:
|
||||
- 输入统一使用 UTF-8 与 `/` 分隔。
|
||||
- 拒绝空路径、绝对/UNC/盘符/ADS、反斜杠、NUL、控制字符和 Windows 禁止字符。
|
||||
- 逐段拒绝空段、`.`、`..`、尾随 ASCII 空格/句点。
|
||||
- 逐段拒绝空段、`.`、`..`、首尾 ASCII 空格和尾随句点。
|
||||
- 大小写不敏感地拒绝 DOS 设备名及其在 Win7~Win11 需要兼容的扩展/变体。
|
||||
- 分别支持“必须指向文件”和“工作目录可为 `.`”两类调用语义,避免各模块自行放宽。
|
||||
- 提供统一的 Windows 大小写折叠冲突键,替换 catalog/installer/storage 中分散的路径规则。
|
||||
@@ -67,7 +68,7 @@ Extractor 的正式调用约束是 Catalog 签名与 ZIP SHA-256 已验证后才
|
||||
- destination 包含性兜底对文件、目录和最终 entrypoint 都生效,且不能通过混合分隔符或路径清理结果绕过。
|
||||
- 合法 UTF-8/中文文件名、嵌套路径和 Catalog/installed-app 既有合法样例继续通过。
|
||||
- Windows 专属测试在当前可用 Windows 环境实际执行;测试代码须可在 Win7、Win10、Win11 复用。若本任务环境不能覆盖三套系统,执行记录必须写明已测系统和待 T-601 补齐的 VM/真机矩阵。
|
||||
- `cd core && GOTOOLCHAIN=go1.20.14 go vet ./... && GOTOOLCHAIN=go1.20.14 go test -count=1 ./...` 通过。
|
||||
- `cd core && GOWORK=off GOTOOLCHAIN=go1.20.14 go vet ./... && GOWORK=off GOTOOLCHAIN=go1.20.14 go test -count=1 ./...` 通过。
|
||||
- `./scripts/verify_phase0.ps1` 与 `bash scripts/verify_phase0.sh` 全绿,modern/Win7 双目标继续构建。
|
||||
- `python scripts/validate_agent_context.py`、`python scripts/validate_harness_governance.py` 通过。
|
||||
|
||||
@@ -91,3 +92,9 @@ Extractor 的正式调用约束是 Catalog 签名与 ZIP SHA-256 已验证后才
|
||||
|
||||
- 2026-07-16:根据 `docs/review/phase1-security-review.md` 交叉复核定稿的最高优先级整改落成任务;现有全局最大任务为 T-604,因此取 T-605。
|
||||
- 2026-07-16:任务风险按定稿校准为“签名内容管线的纵深防御缺口”,同时保留阻断 T-302 的结论;本任务只收口 Windows 路径规则与 destination 纵深检查,中央目录、断电耐久和签名向量继续串行拆分。
|
||||
- 2026-07-16:在 `agent/codex/T-605` 分支领取任务,基线为 `f7a803d944d3ef1c782aa974d5114f51d3e00b17`;保持单 Agent 串行执行。
|
||||
- 2026-07-16:新增 `core/internal/safepath`,统一拒绝非规范/绝对路径、反斜杠/ADS、控制字符、Windows 禁止字符、首尾 ASCII 空格、尾随句点及 DOS 设备名(含扩展、上标数字和兼容变体);Unicode simple-fold 冲突键同时替换 installer/storage 中分散的 `strings.ToLower`。
|
||||
- 2026-07-16:Catalog `entry_exe`、ZIP entry/entrypoint、installed-app `files[].path` 全部接入共享规则;Extractor 在创建 staging 前规划所有绝对输出路径,用 destination 相对包含性检查覆盖文件、目录与最终 entrypoint。攻击矩阵新增 `payload/.. /escape.exe`、dot-space、设备名、禁止字符和 Unicode 折叠冲突,并断言 staging 外无文件。
|
||||
- 2026-07-16:三个相关 Schema 加强可表达的路径形状约束并声明运行时校验器为 Windows 设备名/控制字符的权威;`api.md`、架构、编码规则和 ZIP testdata 说明同步。Schema JSON/正则 smoke 对合法中文与 `../`、嵌套 `..`、尾随点、首部空格、双斜杠、`?` 拒绝均通过。
|
||||
- 2026-07-16:Windows 原生测试 `TestExtractorRejectsWindowsNormalizedEscapeOnNativeFilesystem` 在 Windows 10 专业版 10.0.19045 amd64 通过;测试代码带 `windows` build tag,可直接用于 Win7/Win11。当前环境没有 Win7/Win11 VM,两者实际矩阵按验收边界留 T-601 补齐。
|
||||
- 2026-07-16:验证通过:Go 1.20.14 + `GOWORK=off` 执行 `go vet ./...`、`go test -count=1 ./...` 与 Windows 定向测试;`./scripts/verify_phase0.ps1`;`bash scripts/verify_phase0.sh`;modern Go 1.25.0 与 Win7 Go 1.20.14 双目标测试/构建;`python scripts/validate_agent_context.py`;`python scripts/validate_harness_governance.py`。
|
||||
|
||||
Reference in New Issue
Block a user