Skip to content

fix(security): keep file paths inside the working directory - #732

Draft
Solaris-star wants to merge 1 commit into
lsdefine:mainfrom
Solaris-star:fix/730-jail-file-write-paths
Draft

fix(security): keep file paths inside the working directory#732
Solaris-star wants to merge 1 commit into
lsdefine:mainfrom
Solaris-star:fix/730-jail-file-write-paths

Conversation

@Solaris-star

Copy link
Copy Markdown
Contributor

关联问题

关联 #730

修复范围

GenericAgentHandler._get_abs_path 现在对路径做 realpath 解析,并要求解析结果位于工作目录内:

  • 拒绝 ../ 越界路径;
  • 拒绝解析后指向工作目录外的 symlink;
  • 接受工作目录内的相对路径和绝对路径;
  • file_writefile_patchfile_read 和 JS 结果保存路径在拒绝时返回明确错误。

本 PR 没有改动 code_run_header.py 的 hash/integrity 机制,也没有重构执行链,避免扩大 #730 的修复范围。header 完整性可以另开 issue 讨论。

验证

python -m unittest -v tests.test_path_jail

4 个测试通过,覆盖正常路径、../、symlink escape,以及 file_write 的拒绝结果;python -m compileall -q ga.py tests/test_path_jail.py 通过。

这是 draft PR,先请维护者确认路径 containment 的边界和错误处理方式。

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