Closed
【安全】【计算IT应用安全编码要求】命令注入-remoteUrl未转义拼入shell命令 #44
陈明旭Add on  23 days agoClosed at  10 days ago
陈明旭
陈明旭Collaborators
23 days ago Create

问题概述

remoteUrl 未转义直接进双引号 shell 串(同源 upload-sarif-action 已用 escapeShellArg 防注入,此处遗漏)。

问题清单

序号 问题位置 证据说明
1 index.js:173 execCapture(git remote set-url origin "${authUrl}")

修复建议

remoteUrl 经 escapeShellArg 转义或改 execFile 数组形式。

likedislike
mafeifei
mafeifeiCollaborators
10 days ago Comments:

整改已完成(!13 已合入 master)

  • 删除 git remote set-url / git remote get-url 整段逻辑,token 不再写入 .git/config,也不再出现在命令行参数中。
  • 改用 GIT_ASKPASS 临时凭证脚本(index.js:176-225):脚本权限 0o700,仅在 git fetch 子进程 env 中注入 GIT_ASKPASS / PRE_COMMIT_GC_TOKEN,并设 GIT_TERMINAL_PROMPT=0。
  • 脚本在任务结束的 finally 中立即删除(index.js:197-203),异常路径也会清理。
  • 当前 master 全仓已无 remote set-url、remote get-url 调用残留,原先「remoteUrl 未转义拼入 bash 命令」的代码整体不存在。

同类 issue #13 / #22 / #35 / #36 / #39 / #42 / #44 / #47 均由此改动覆盖,一并关闭。

likedislike
mafeifeimafeifeiCollaborators
10 days ago Close issue