安全漏洞 / 高 / 工具系统
electron/harness/sandbox/permissions.ts
PolicyEngine 在校验工具输入时,先 JSON.stringify(input) 再用正则匹配危险模式。 这种方式可被多种方式绕过:
JSON.stringify(input)
\u0029
{a: {b: 'dangerous'}}
'rm ' + '-rf /'
function deepScan(obj: unknown): string[] { const findings: string[] = []; if (typeof obj === 'string') { DANGEROUS_PATTERNS.forEach(p => { if (p.test(obj)) findings.push(p.source); }); } else if (Array.isArray(obj)) { obj.forEach(item => findings.push(...deepScan(item))); } else if (obj && typeof obj === 'object') { Object.values(obj).forEach(v => findings.push(...deepScan(v))); } return findings; }
No dependencies set.
The note is not visible to the blocked user.
问题类型
安全漏洞 / 高 / 工具系统
文件位置
electron/harness/sandbox/permissions.ts问题描述
PolicyEngine 在校验工具输入时,先
JSON.stringify(input)再用正则匹配危险模式。这种方式可被多种方式绕过:
\u0029等编码绕过字符匹配{a: {b: 'dangerous'}}在 stringify 后可能与顶层字符串相似'rm ' + '-rf /'在 stringify 后是合法字符串影响
建议修复