CortexPrism/cortex-plugin-prompt-injection-guard
GitHub: CortexPrism/cortex-plugin-prompt-injection-guard
CortexPrism 官方插件,通过多类别检测模式和预中间件机制为 LLM 应用提供 prompt injection 攻击的检测与拦截能力。
Stars: 0 | Forks: 0
# cortex-plugin-prompt-injection-guard
通过涵盖 5 个类别的 30 多种检测模式,扫描用户和工具输入以防范 prompt injection 攻击。
## 安装
```
cortex plugin install marketplace:cortex-plugin-prompt-injection-guard
cortex plugin install github:CortexPrism/cortex-plugin-prompt-injection-guard
cortex plugin install ./manifest.json
```
## 工具
### injection_scan
扫描文本以检测 injection 攻击尝试。
**参数:**
- `text`(字符串,必填)— 要扫描的文本
- `context`(字符串,默认值:"user_input")— 可选值之一:user_input、tool_output、system_message、all
### injection_patterns
列出处于激活状态的检测模式。
**参数:**
- `category`(字符串,可选)— 过滤条件:direct、indirect、encoding、boundary、exfiltration
### injection_whitelist
管理白名单。
**参数:**
- `action`(字符串,默认值:"list")— list、add、remove
- `pattern`(字符串,可选)— 要添加/移除的模式
- `reason`(字符串,可选)— 修改原因
### injection_stats
获取检测统计数据。
**参数:**
- `since`(字符串,可选)— ISO 日期过滤器
## 检测类别
| 类别 | 模式数量 | 示例 |
|----------|----------|----------|
| Direct | 10 | ignore previous instructions, you are now, act as, forget everything, DAN/jailbreak |
| Indirect | 3 | URL payload injection, markdown exploits, data exfiltration |
| Encoding | 4 | Base64, URL encoding, hex encoding, Unicode homoglyphs, zero-width chars |
| Boundary | 3 | ---SYSTEM--- delimiters, role switching, XML delimiter injection |
| Exfiltration | 2 | Email/webhook data exfiltration attempts |
| Direct (extended) | 8 | Confirmation bypass, output override, hidden instructions, filter bypass, token smuggling, crescendo attacks |
## Pre-Middleware
当启用 `blockOnDetect` 时,`preMiddleware` 会在执行前扫描所有工具参数,并拦截检测分数 >= 15 的请求。
## 配置
UI 设置:
- **检测阈值**(下拉选择,默认值:medium)— Low/Medium/High 灵敏度
- **检测到时拦截**(布尔值,默认值:true)— 拦截工具执行
- **记录 Injections**(布尔值,默认值:true)— 记录所有检测记录
## 功能
- `tools` — Injection 扫描工具
- `middleware:pre` — 执行前的 injection 防护
## 开发
```
deno task test
deno task validate
```
## 许可证
MIT
标签:AI安全, Chat Copilot, CortexPrism, DLL 劫持, 内容检测, 大语言模型, 插件, 自动化攻击