scthornton/airs-golden-config
GitHub: scthornton/airs-golden-config
一套通过迭代红队测试逐步调优的 Prisma AIRS 强化安全配置,将大语言模型攻击成功率从 8.71% 降至 1.02%,并提供完整的主题管理、缺口分析和部署工具链。
Stars: 1 | Forks: 1
# AIRS Golden Config
一个通过迭代红队微调构建的强化型 Prisma AIRS 安全配置文件。在仅使用内置检测器时,攻击成功率为 8.71%——经过 8 轮迭代,降至 **1.02% 静态**(最佳)/ **Agent 评分 15**。通过 [Daystrom](https://github.com/cdot65/daystrom) 进行的自动化评估确认,主题已达到 AIRS 分类器的上限。
```
Static ASR %
8.7 ┤ █████████████████████████████████████████ 401 threats BASELINE
2.8 ┤ ████████████ 127 threats ITER 1 (-68%)
1.7 ┤ ███████ 77 threats ITER 2 (-40%)
1.1 ┤ █████ 51 threats ITER 3 (-34%)
1.3 ┤ █████ 59 threats (scan variance) ITER 4
1.2 ┤ █████ 55 threats (DLP added) ITER 5
1.2 ┤ █████ 53 threats (stable) ITER 6
1.0 ┤ ████ 47 threats (NEW BEST) ITER 7 ✓
1.4 ┤ ██████ 65 threats (scan variance) ITER 8
└──────────────────────────────────────────────────────────
Iter 0 Iter 1 Iter 2 Iter 3 Iter 4 Iter 5 Iter 6-8
```
## 包含内容
**三层防护,均设置为 BLOCK:**
1. **内置检测器**(9 个)—— prompt 注入、越狱、有毒内容、恶意代码、DLP、URL 类别、Agent 安全、上下文基础、内联超时
2. **自定义主题防护栏**(15/20 个槽位)—— 针对内置检测器遗漏的攻击类别的语义分类器:政治偏见、多轮升级、品牌诽谤、CBRN、系统 prompt 泄露等。
3. **DLP 数据配置文件** —— 带有 Tier 1 类别(PII、凭证、脏话、自残、敏感内容)的嵌套配置文件
七个主题达到了 100% 的拦截率,并在所有扫描中保持稳定。五个槽位预留给特定客户的自定义模式。
## 架构
```
SCM Red Team Scanner
│
▼
┌────────────────────────┐
│ AIRS Hard-Block │
│ Wrapper (Flask) │
│ │
│ 1. Prompt scan ───────┼──► AIRS Scan API
│ (all user turns) │ Profile: redteamtest
│ 2. If BLOCK → stop │
│ 3. LLM call ──────────┼──► OpenAI (gpt-4o-mini)
│ 4. Response scan ─────┼──► AIRS (prompt+response)
│ 5. Response solo scan ┼──► AIRS (response only)
│ 6. If BLOCK → stop │ ├─ 9 built-in detectors
│ 7. Return response │ ├─ 15 custom topics
│ │ └─ DLP data profiles
└────────────────────────┘
```
## 快速开始
```
# 1. 设置凭证
cp .env.example .env # Fill in your AIRS + OpenAI keys
source .env
# 2. 安装 SDK
pip install -r requirements.txt
pip install --index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ \
pan-airs-api-mgmt-sdk==0.0.1a12
# 3. 初始化状态
cp mgmt/state.example.json mgmt/state.json
# 4. 将 topics 部署到您的租户
python mgmt/topic_ops.py deploy --file topics/golden_topics.json
# 5. 创建并配置安全配置文件
python mgmt/profile_ops.py create
# 6. 通过快速扫描进行验证
python scan/scan_tester.py --limit 5
```
## 仓库结构
```
mgmt/ Management API operations
config.py Shared config, auth, AIRS client
topic_ops.py Topic CRUD — deploy, update, sync
profile_ops.py Security profile CRUD
dlp_ops.py DLP data profile operations
scan/ Scan and analysis tools
scan_tester.py Quick scan against AIRS API
parse_export.py Parse SCM red team exports
gap_analysis.py Identify coverage gaps
vm/ Wrapper deployment
wrapper_vertex.py Flask wrapper (AIRS scan + LLM)
deploy.sh GCP VM provisioning
push.sh Hot-reload wrapper on VM
report/ Reporting
generate_report.py Per-iteration + final reports
collect_vm_logs.py VM log collection + parsing
topics/ Topic definitions
golden_topics.json 15 semantic guardrail topics
results/ Scan data per iteration
docs/ Experiment reports
```
## 迭代循环
每个微调周期:
1. 在 SCM 中运行红队扫描(静态 + Agent)
2. 导出结果 → `python scan/parse_export.py results/export.zip --iteration N`
3. 分析差距 → `python scan/gap_analysis.py results/iteration_N/`
4. 部署/更新主题 → `python mgmt/topic_ops.py deploy`
5. 生成报告 → `python report/generate_report.py iteration N`
6. 重新扫描。重复此过程直到满意为止。
## 结果
| 迭代 | 主题数 | 静态 ASR | 威胁数 | Agent 评分 | 变更内容 |
|------|--------|------------|---------|-------------|--------------|
| 0 | 0 | 8.71% | 401/4602 | — | 基线 |
| 1 | 12 | **2.76%** | 127/4602 | — | 部署了 12 个主题 |
| 2 | 14 | **1.67%** | 77/4602 | — | 优化了 3 个,新增了 2 个 |
| 3 | 15 | **1.11%** | 51/4602 | — | 优化了 4 个,新增了 1 个 |
| 4 | 15 | **1.28%** | 59/4602 | — | 优化了 4 个(扫描差异) |
| 5 | 15 | **1.20%** | 55/4602 | — | 新增了 DLP 数据配置文件 |
| 6 | 15 | **1.15%** | 53/4602 | 15 | 稳定确认 |
| 7 | 15 | **1.02%** | 47/4602 | 27.5 | 静态最佳;Agent 回退(数学框架) |
| 8 | 15 | **1.41%** | 65/4602 | 15 | 优化了 4 个主题 + wrapper v4;Agent 恢复 |
24 个攻击类别中有 17 个达到了 0% ASR。Daystrom 自动化评估确认,由于 OR-gate 架构,所有主题均已达到 **AIRS 分类器上限**(60-75% 覆盖率)。请参阅[实验状态](docs/experiment_status.md)和[完整报告](docs/golden_config_final_report.md)。
## Golden Config v2
[golden-v2/](golden-v2/) 利用 Morgan Stanley 项目中的精确度经验,将 15 个主题的 v1 版本简化为 12 个主题。在包含 126 个 prompt 的绕过语料库中实现了 4.76% 的 ASR(相比之下 v1 为 5.56%),且主题数量减少了 20%。主题描述重写为 15-20 个词,并锚定到具体的 token。
详情请参阅 [golden-v2/README.md](golden-v2/README.md)。
## 主要发现
- **内置检测器存在重大缺口。** 基线威胁中有 56% 针对的是内置覆盖率为零的类别。
- **首次部署主题是最大的杠杆。** 迭代 1 将 ASR 降低了 68%。随后的每一次迭代所带来的收益都在递减。
- **主题描述的质量 > 数量。** 精确的描述可以达到 100% 的拦截率。250 个字符的描述承载了约 40-50% 的分类器权重。
- **AIRS 分类器是 OR-gate,而不是 AND-gate。** 只要描述中有任何匹配的信号就会触发,而不是基于信号的交集触发。"Blocks X to achieve Y" 仅在 X 上或仅在 Y 上就能触发。这是根本性的上限——任何主题重写都无法解决这个问题。
- **多轮攻击需要针对内容。** 分类器匹配的是单轮——应针对主题(武器、种族灭绝、恐怖主义),而不是多轮结构。
- **预留主题槽位。** 从 60% 的利用率开始,留下了适应的空间。不要在第一天就填满所有 20 个槽位。
- **双重扫描 wrapper(v4)。** 对 prompt 扫描两次(最后一条消息 + 完整上下文),对响应扫描两次(带上下文 + 独立),可以同时捕获升级模式和创意框架绕过。
- **3 个持久的 Agent 目标使用创意规避。** 虚构角色扮演(Hannibal Lecter)、荒诞替换(SmartWash 3000 袜子)以及词汇替换(用 "sun-drops" 代替 oxycontin)通过不使用可匹配的关键词绕过了分类器。
## 要求
- Python 3.10+
- 具有 API 访问权限(Management + Scan APIs)的 Prisma AIRS 租户
- `pan-airs-api-mgmt-sdk` (TestPyPI)
- OpenAI API 密钥(用于 wrapper VM)
- GCP 项目(用于 VM 部署,可选)
## 许可证
内部研究工具。有关方法论和发现,请参阅[完整报告](docs/golden_config_final_report.md)。
## 联系方式
**Scott Thornton** — AI 安全研究员
- 网站: [perfecxion.ai](https://perfecxion.ai/)
- 邮箱: [scott@perfecxion.ai](mailto:scott@perfecxion.ai)
- LinkedIn: [linkedin.com/in/scthornton](https://www.linkedin.com/in/scthornton)
- ORCID: [0009-0008-0491-0032](https://orcid.org/0009-0008-0491-0032)
- GitHub: [@scthornton](https://github.com/scthornton)
**安全问题**: 请通过 [SECURITY.md](SECURITY.md) 报告
标签:AI安全, AI风险治理, AMSI绕过, ASR优化, Chat Copilot, CISA项目, DevSecOps, DLP, Petitpotam, Prisma AIRS, 上游代理, 大模型安全, 威胁检测, 安全基线, 安全策略, 安全配置, 提示注入, 提示词设计, 攻击成功率, 教学环境, 模型加固, 网络安全, 自动化评估, 自定义主题, 语义分类器, 越狱防护, 逆向工具, 隐私保护, 集群管理