安全漏洞 / 高 / 工具系统
electron/harness/tools/built-in/code-search.ts
CodeSearchTool 接受用户输入的 pattern 与 glob 参数,传给 ripgrep 子进程。 若未正确转义,以 - 开头的 pattern 会被 ripgrep 解释为选项:
pattern
glob
-
--help
--ignore-file /etc/passwd
--crlf
--files
--
const args = [ '--json', '--', // 终止选项解析 pattern, rootPath, ]; execFile('rg', args, ...);
No dependencies set.
The note is not visible to the blocked user.
问题类型
安全漏洞 / 高 / 工具系统
文件位置
electron/harness/tools/built-in/code-search.ts问题描述
CodeSearchTool 接受用户输入的
pattern与glob参数,传给 ripgrep 子进程。若未正确转义,以
-开头的 pattern 会被 ripgrep 解释为选项:--help会输出帮助而非搜索--ignore-file /etc/passwd可读取任意文件--crlf等改变行为--files列出所有文件影响
建议修复
--终止选项解析:-开头,或强制转义