安全漏洞 / 高 / 工具系统
electron/harness/sandbox/sandbox.ts
scanCode 用于检测代码字符串中的危险操作,但当前模式集遗漏:
require('fs')
require('child_process')
import('fs')
process.binding('fs')
Reflect.get(globalThis, 'req' + 'uire')
new Function('return process')()
project_memory.md 要求:
sandbox scanCode must include 28 patterns with 'i' flag and base64/$() detection to prevent encoding bypass
但实际模式数可能不足或未覆盖上述场景。
const DANGEROUS_PATTERNS = [ /\brequire\s*\(\s*['"]fs['"]\s*\)/i, /\brequire\s*\(\s*['"]child_process['"]\s*\)/i, /\bimport\s*\(\s*['"]fs['"]\s*\)/i, /\bprocess\.binding\s*\(/i, /\bnew\s+Function\s*\(/i, /\bReflect\.get\s*\(/i, /\beval\s*\(/i, /\bFunction\s*\(\s*['"]return process['"]\s*\)/i, // ... 28+ patterns ];
文件: electron/harness/sandbox/sandbox.ts
修复: 新增 6 个危险模式检测:require('fs')、动态 import('fs'|'child_process'|...)、process.binding(、new Function(、Reflect.get(、Function('return process')。模式总数从 28 增至 34。
import('fs'|'child_process'|...)
process.binding(
new Function(
Reflect.get(
Function('return process')
验证: tsc --noEmit 类型检查通过。
tsc --noEmit
No dependencies set.
The note is not visible to the blocked user.
问题类型
安全漏洞 / 高 / 工具系统
文件位置
electron/harness/sandbox/sandbox.ts问题描述
scanCode 用于检测代码字符串中的危险操作,但当前模式集遗漏:
require('fs')/require('child_process')等同步 require 形式import('fs')动态 importprocess.binding('fs')底层绑定Reflect.get(globalThis, 'req' + 'uire')字符串拼接绕过new Function('return process')()函数构造project_memory.md 要求:
但实际模式数可能不足或未覆盖上述场景。
影响
建议修复
修复说明
文件:
electron/harness/sandbox/sandbox.ts修复: 新增 6 个危险模式检测:
require('fs')、动态import('fs'|'child_process'|...)、process.binding(、new Function(、Reflect.get(、Function('return process')。模式总数从 28 增至 34。验证:
tsc --noEmit类型检查通过。