当前Pull Request已关闭, 关闭人@gcw_Nt0RibX4
变更摘要
该 PR 修复 cmd/conch-agent/grpc.go 中 AgentServer 的 GetFile 与 PostFiles 两个 gRPC 接口存在的路径遍历(Path Traversal)安全漏洞:此前接口直接使用用户提供的 filepath 参数读取/写入文件,攻击者可通过 ../ 或绝对路径访问工作目录之外的敏感文件。修复方式是在两个接口中统一加入路径校验,仅允许工作目录内的相对路径,禁止绝对路径及包含 .. 的路径。
主要改动
PostFiles增加路径校验:新增filepath.IsAbs(cleanedFilepath)与strings.Contains(cleanedFilepath, "..")检查,命中时记录错误日志并返回invalid filepath错误响应,阻止越界写入关键系统文件。GetFile清理并校验路径:读取前先通过filepath.Clean(req.Filepath)生成cleanedFilepath,并应用与PostFiles相同的绝对路径与..校验,不合法时返回错误而非读取文件。- 错误与日志统一改用清理后路径:
GetFile中文件不存在、读取失败及成功日志等消息均改用cleanedFilepath,避免日志暴露用户原始输入路径。 - 新增
strings标准库导入:为上述strings.Contains校验提供依赖。
变更摘要
该 PR 修复 cmd/conch-agent/grpc.go 中 AgentServer 的 GetFile 与 PostFiles 两个 gRPC 接口存在的路径遍历(Path Traversal)安全漏洞:此前接口直接使用用户提供的 filepath 参数读取/写入文件,攻击者可通过 ../ 或绝对路径访问工作目录之外的敏感文件。修复方式是在两个接口中统一加入路径校验,仅允许工作目录内的相对路径,禁止绝对路径及包含 .. 的路径。
主要改动
PostFiles增加路径校验:新增filepath.IsAbs(cleanedFilepath)与strings.Contains(cleanedFilepath, "..")检查,命中时记录错误日志并返回invalid filepath错误响应,阻止越界写入关键系统文件。GetFile清理并校验路径:读取前先通过filepath.Clean(req.Filepath)生成cleanedFilepath,并应用与PostFiles相同的绝对路径与..校验,不合法时返回错误而非读取文件。- 错误与日志统一改用清理后路径:
GetFile中文件不存在、读取失败及成功日志等消息均改用cleanedFilepath,避免日志暴露用户原始输入路径。 - 新增
strings标准库导入:为上述strings.Contains校验提供依赖。


Welcome To openEuler Community
Hey @gcw_Nt0RibX4 , thanks for your contribution to the community.
Bot Usage Manual
I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands. You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
Contact Guide
If you have any questions, please contact the SIG: sig-CloudNative ,
and any of the maintainers: @duguhaotian, @gaodaweiky, @jimmieme, @lu-wei-army, @weibaohui, @wonleing, @yangzhao_kl, @zhaoyifan28, @zmr_2020 ,
and any of the committers: @Yekelu .


Conch当前开发分支是dev分支,master分支较落后,可以审视dev分支是否存在以上问题。


当前PR是否有AI参与:
[x] 否
[ ] 是
__1. AI Agent 平台:
__2. AI 模型:
__3. Prompt上下文 :
参考:openEuler社区《生成式AI工具使用与开源贡献政策》
PR功能描述 / 为什么需要这个合入**:
该PR关联的issue
(格式为fixes #<issue号>, 或者resolves #<issue号>): fixes #
希望检视人员了解: