安全漏洞 / 高 / 工具系统
electron/harness/tools/built-in/git.ts (GitDiffTool)
electron/harness/tools/built-in/git.ts
GitDiffTool 接受 pathspec 参数,直接传给 git diff <pathspec>。 未校验 pathspec 是否在工作空间内:
git diff <pathspec>
-- /etc/passwd
-- ../../../other-repo/
-- C:\\Windows\\System32\\
async execute(input: { pathspec?: string[] }): Promise<ToolResult> { const safePathspecs: string[] = []; if (input.pathspec) { for (const p of input.pathspec) { // 跳过 git 选项(-- 开头) if (p.startsWith('--')) continue; // realpath 校验 const resolved = resolve(this.workspacePath, p); const real = realpathSync(resolved); if (!real.startsWith(this.workspacePath + sep) && real !== this.workspacePath) { return { error: `Path outside workspace: ${p}` }; } safePathspecs.push(p); } } // ... }
参考 file-guard.ts 的 validatePath 实现。
No dependencies set.
The note is not visible to the blocked user.
问题类型
安全漏洞 / 高 / 工具系统
文件位置
electron/harness/tools/built-in/git.ts(GitDiffTool)问题描述
GitDiffTool 接受 pathspec 参数,直接传给
git diff <pathspec>。未校验 pathspec 是否在工作空间内:
-- /etc/passwd可尝试读取系统文件差异(如果 git 仓库覆盖该路径)-- ../../../other-repo/可读取其他仓库-- C:\\Windows\\System32\\可越权影响
建议修复
参考 file-guard.ts 的 validatePath 实现。