安全漏洞 / 高 / Agent 引擎
electron/harness/security/prompt-injection-defense.ts
检测 "ignore previous instructions" 等注入模式时,正则未使用 \b 单词边界:
\b
/ignore previous instructions/i // 错误
可通过添加字符绕过:
ignoree previous instructions
ignore previous instructionss
Xignore previous instructionsX
反向地,可能误伤:
please don't ignore previous instructions
// 使用单词边界 /\bignore\s+previous\s+instructions?\b/i // 或更严格的边界 /(?<![a-z])ignore\s+previous\s+instructions?(?![a-z])/gi
同时建议结合多种检测手段(启发式 + 模型分类)。
文件: electron/harness/security/prompt-injection-defense.ts
修复: 为所有英文关键词注入模式添加 \b 单词边界(如 \bignore\s+...\binstructions?\b),防止 Xignore previous instructions、ignore previous instructionss 等前后缀绕过。
\bignore\s+...\binstructions?\b
Xignore previous instructions
验证: tsc --noEmit 类型检查通过。
tsc --noEmit
No dependencies set.
The note is not visible to the blocked user.
问题类型
安全漏洞 / 高 / Agent 引擎
文件位置
electron/harness/security/prompt-injection-defense.ts问题描述
检测 "ignore previous instructions" 等注入模式时,正则未使用
\b单词边界:可通过添加字符绕过:
ignoree previous instructionsignore previous instructionssXignore previous instructionsX反向地,可能误伤:
please don't ignore previous instructions(会误报)影响
建议修复
同时建议结合多种检测手段(启发式 + 模型分类)。
修复说明
文件:
electron/harness/security/prompt-injection-defense.ts修复: 为所有英文关键词注入模式添加
\b单词边界(如\bignore\s+...\binstructions?\b),防止Xignore previous instructions、ignore previous instructionss等前后缀绕过。验证:
tsc --noEmit类型检查通过。