Skip to content

修复:安全初始化首次 scoped Session Root - #3

Merged
jubilee-hub merged 2 commits into
vendor/v2026.7.20from
codex/issue-700-session-root-init
Jul 26, 2026
Merged

jubilee-hub merged 2 commits into
vendor/v2026.7.20from
codex/issue-700-session-root-init

Conversation

@jubilee-hub

Copy link
Copy Markdown
Owner

背景

Agent SaaS 在生产完成 shared → scoped 串行代次验收后,首次 scoped 文件对话仍失败:控制面已有 fresh Workspace OK 证据,但确定性 Session Root 子目录尚不存在;file tool 因 strict resolve 正确 fail-closed。跟踪任务:jubilee-hub/agent-saas#700。

变更

  • 只接受 /workspace/profiles/<profile-uuid>/workspaces/<workspace-uuid> 的规范化路径;
  • 在已认证的 Session Root 请求入口,使用 descriptor-anchored、O_NOFOLLOW 的逐级 mkdir/open 初始化;
  • 初始化并发幂等且非破坏:已有目录、文件、权限都不覆盖、不删除、不 chmod;
  • 拒绝 root 外路径、非规范路径、非 UUID 段、..、symlink base/parent 和普通文件父节点;
  • 挂载不可用时返回 503,非法路径返回 400,错误响应不回显内部根路径;
  • 更新受控镜像 provenance label 到 Agent SaaS fix(config): atomic write for config.yaml to prevent data loss on crash NousResearch/hermes-agent#700;
  • 让详细健康测试使用固定虚拟磁盘占用,避免宿主机磁盘超过 90% 时误报,与生产健康逻辑无关。

安全边界

  • 请求必须先通过现有 Bearer 认证 decorator,未认证请求不会创建任何目录;
  • 不新增公开 API、环境变量、工具或 multiplex 行为;
  • 不降低现有 file root enforcement、readiness 或 canary;
  • 所有目录操作都锚定已打开的父目录 fd,并拒绝符号链接。

验证

本地按仓库测试包装器运行:

scripts/run_tests.sh   tests/gateway/test_api_server.py   tests/gateway/test_api_server_runs.py   tests/gateway/test_session_api.py   tests/gateway/test_async_delivery_capability.py   tests/tools/test_file_tools_session_root.py -q

341 passed, 0 failed

覆盖 Chat/Responses 的流式与非流式入口、Runs、Session Chat、24 路并发初始化、已有内容保留、未认证零副作用、挂载缺失、越界与 symlink 对抗。

@jubilee-hub
jubilee-hub merged commit e7ea178 into vendor/v2026.7.20 Jul 26, 2026
33 checks passed
@jubilee-hub
jubilee-hub deleted the codex/issue-700-session-root-init branch July 26, 2026 23:48
@jubilee-hub

Copy link
Copy Markdown
Owner Author

合并前 Codex 复核已完成,无阻断项。

验证证据:

  • 受影响核心回归:341 passed,0 failed(统一通过 scripts/run_tests.sh 执行)
  • GitHub CI:8/8 Python slices、e2e、ruff/ty、Docker/shell lint、OSV 与供应链检查全部通过
  • 鉴权先于目录初始化;未授权请求无文件系统副作用
  • 仅允许 /workspace/profiles//workspaces/,逐级 descriptor anchored + O_NOFOLLOW
  • 缺失目录可并发安全初始化;现有目录/文件不删除、不替换、不 chmod
  • 非法布局/符号链接 fail closed 为 400,挂载或权限不可用 fail closed 为 503
  • 错误响应不回显 Session Root;没有改动 workflow、公开 API、multiplex 或权限默认值

本机曾启动仓库全量测试,但本地未安装 ACP/Anthropic 等非本阶段可选 extra,相关收集/适配器测试不具备判定意义,且没有调用 Anthropic 或任何模型服务;权威全矩阵已由本 PR CI 完整通过。

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