screem500/prompt-injection-auditor
GitHub: screem500/prompt-injection-auditor
一个将 AI agent 转变为提示词注入安全审计员的开放 Agent Skill,提供静态扫描、攻击目录和防御清单,帮助开发者在发布系统提示词前发现并修复安全隐患。
Stars: 2 | Forks: 0
# prompt-injection-auditor
[](https://opensource.org/licenses/Apache-2.0)
[](https://agentskills.io)
[](https://skills.sh)
**一个开放的 Agent Skill,可将任何 AI agent 转变为提示词注入安全审计员。**
静态扫描器 + 攻击目录 + 防御清单 + 授权的 red-team payloads — 针对诸如 EchoLeak (CVE-2025-32711) 等真实世界安全事件而构建。
兼容 Claude Code、Cursor、Kimi 以及 20 多个支持开放式 [Agent Skills](https://agentskills.io) 标准的 agent。
## 为什么需要它?
2025 年的研究评估发现,**超过 90% 的生产级 LLM agent 容易受到提示词注入攻击**,且真实的突发事件不断证明这一点:
- **EchoLeak (CVE-2025-32711, CVSS 9.3)** — 生产级 AI 系统中首个 zero-click 提示词注入漏洞:电子邮件中隐藏的指令使 Microsoft 365 Copilot 通过 markdown 图像泄露 OneDrive/SharePoint 数据,无需任何点击。
- **LangGrinch (CVE-2025-68664)** — LangChain 序列化注入漏洞,通过模型响应泄露环境机密。
- **Langflow (CVE-2025-3248 / CVE-2026-33017)** — agent 构建框架中的未授权 RCE 漏洞,在披露后数小时内即被利用。
大多数系统提示词在发布时没有指令层级、没有保密规则,也没有不可信内容处理机制。此 skill 可在攻击者之前发现这些弱点。
## 安装说明
```
npx skills add /prompt-injection-auditor
```
## 用法
安装该 skill 后,只需向你的 agent 提问:
```
Audit this system prompt against prompt injection: [paste prompt]
```
```
Review my SKILL.md for security weaknesses before I publish it.
```
该 agent 遵循 5 步方法论:收集目标 -> 运行静态扫描器 -> 根据攻击目录进行人工审查 -> 授权的实战测试(可选) -> 带有严重性评级和修复建议的报告。
### 独立扫描器(无需 agent)
```
python scripts/pi_scan.py system_prompt.txt # terminal report
python scripts/pi_scan.py system_prompt.txt --md report.md # markdown report
python scripts/pi_scan.py system_prompt.txt --json out.json # CI/automation
```
当存在 Critical/High 级别的发现时,退出代码为 `1` — 可直接将其接入你的 CI pipeline。
## 演示
扫描一个易受攻击的提示词(硬编码的 API key + 电子邮件/代码执行工具 + 读取收件箱):
```
=== Prompt Injection Audit: vulnerable_prompt.txt ===
Risk score: 100/100 [####################] SEVERELY EXPOSED — do not deploy before remediation
[Critical] PI-SECRET: Secret-like value present: Hardcoded credential-like value (lines 2)
[Critical] PI-TOOLS: Powerful capabilities declared: Code/command execution capability;
Network/egress capability; Outbound messaging capability (lines 4, 5)
Why: The agent has action capabilities AND ingests untrusted content
(web/email/RAG) — the EchoLeak-class combination.
[ High] PI-NO-HIERARCHY: No explicit instruction hierarchy
[ High] PI-NO-NONDISCLOSE: No non-disclosure rule for the prompt itself
...
Summary: Critical=2, High=4, Medium=2, Low=1
```
一个经过强化的提示词(包含层级 + 保密 + delimiters)得分为 **0/100 — HARDENED**。
## 包含内容
```
prompt-injection-auditor/
├── SKILL.md # 5-step audit methodology + ethics guardrails
├── scripts/
│ └── pi_scan.py # Zero-dependency static analyzer (~20 weakness classes)
└── references/
├── attack-patterns.md # Direct / indirect / encoding / exfiltration / multi-agent
├── defense-checklist.md # 22 numbered hardening measures
└── test-payloads.md # Escalation-ordered payloads for authorized live tests
```
### 严重性模型
| 严重性 | 示例 |
|----------|----------|
| Critical | 提示词中包含机密信息 · 操作工具 **+** 不可信的数据摄入(EchoLeak 级别) |
| High | 可提取的系统提示词 · 注入的指令可触发工具 |
| Medium | Persona 覆盖 · 缺少输出约束 · 无身份欺骗防护 |
| Low | 没有明确利用路径的健壮性/风格问题 |
## 道德规范
此 skill 仅供**防御性审计和授权测试使用**。实时注入测试仅限于您拥有或获得明确书面测试许可的系统 — 此防护机制已内置于 skill 本身。
## 路线图
- [ ] 针对最新 agent 框架 CVE(LangChain / Langflow / LangGraph)的检测规则
- [ ] Skill 文件 linter 模式(在发布到 skills.sh 之前审计 `SKILL.md` 文件)
- [ ] HTML 报告输出
- [ ] 用于 GitHub Code Scanning 的 SARIF 导出
## 许可证
[Apache License 2.0](LICENSE) — 版权所有 2026。可免费使用,需注明出处。
*如果此 skill 对您有帮助,在仓库点个 star 可以帮助其他人发现它。*
标签:AI安全, Chat Copilot, DLL 劫持, StruQ, 大语言模型, 红队评估, 逆向工具