fix(cosh-ng): [core] confine file writes - #2211
Conversation
There was a problem hiding this comment.
[P1] 新增目录权限默认 0777 依赖 umask,建议收紧或继承 workspace root 权限,避免在敏感 workspace 中意外放宽访问控制。
[P2] 通过 /proc/self/fd/<fd> 重新打开目录获取锁在 Linux 受限环境下可能失败,建议在文档或错误信息中明确该前提依赖,便于调用方理解。
[P2] WorkspaceFs 错误统一透传为工具错误字符串,LLM 难以区分安全拒绝与普通路径错误,建议为安全拒绝类错误提供稳定前缀或代码。
🤖 Generated by Qoder • View workflow run
2566aeb to
4ab6981
Compare
|
PR number: #2211 Findings
除上述外,未发现 blocking package/module/public API 组织问题:变更全部位于 前序已报仍未解决(供跟踪)
Open Questions
Validation
|
- Resolve writes beneath pinned workspace directory descriptors. - Preserve atomic replacement while rejecting traversal and symlink races. - Move blocking path preparation off Tokio worker threads. Fixes: 81af2d9 ("feat(tui): add tool execution framework") Signed-off-by: kongche-jbw <kongche.jbw@alibaba-inc.com>
4ab6981 to
0617211
Compare
|
已基于最新
验证:
本机为 Linux,因此 macOS 完成了 cross-check/cross-clippy;现有并发与内部 symlink 回归测试均为 Unix 测试,可由 macOS runner 直接执行。 |
Why
write_fileandeditresolved paths without the pinned workspace filesystem,so auto-approved tool calls could traverse or follow symlinks outside the
workspace. The write path also remained vulnerable to path replacement races
after validation.
What changed
Related issue
closes #2183
User / Agent impact
write_fileandeditnow reject paths outside the session workspace withoutmodifying external files. Internal symlinks, nested directory creation, atomic
replacement, permission preservation, and edit conflict detection remain
supported.
Risk and compatibility
Writes that previously targeted paths outside the workspace now fail closed.
The descriptor-relative atomic replacement is covered by traversal, symlink,
root-replacement, durability, permission, and concurrency regression tests.
Validation
cargo test --package cosh-core tool::— 205 passedcargo fmt --all -- --checkcargo clippy --package cosh-core --all-targets -- -D warningsgit diff --checkDocumentation and rollback
No documentation changes are required. Reverting commit
2566aebarestoresthe previous behavior, but also restores the workspace escape vulnerability.