karpie28/red-teaming-the-robot

GitHub: karpie28/red-teaming-the-robot

一套完整的 LLM 安全测试演示仓库,整合 Garak、PyRIT 等开源工具,涵盖提示注入、多轮攻击和防御护栏的实战案例。

Stars: 0 | Forks: 0

# 红队演练机器人:LLM 的实用开源安全实践 **SCALE 23x** | Ballroom DE | 2026年3月7日星期六 | 下午 2:30-3:30 SCALE 23x 关于使用开源工具进行 AI 安全测试的演讲配套仓库。 ## 目录 ``` ├── presentation/ │ ├── index.html # reveal.js slide deck (open in Chrome for best rendering) │ └── SPEAKER_NOTES.md # Full speaker notes with timing ├── demos/ │ ├── 01_confused_deputy.py # Confused deputy attack (indirect prompt injection) │ ├── 02_garak_live_scan.sh # Live Garak vulnerability scan │ ├── 03_pyrit_demo.py # PyRIT multi-turn attacks (Crescendo, converters) │ ├── 04_guardrails_demo.py # Defensive guardrails (unguarded vs guarded) │ ├── 05_supply_chain_check.py # Supply chain security (pickle, hash verification) │ └── 06_deepseek_attacks.py # DeepSeek R1 reasoning attacks ├── vulnerable_app/ │ ├── chatbot.py # Intentionally vulnerable chatbot │ └── api_server.py # REST API endpoint for Garak scanning ├── garak_rest.yaml # Garak config for REST API scanning ├── scripts/ │ ├── setup.sh # One-command setup (venv + deps + preflight) │ └── preflight.sh # Pre-talk checklist (demos, network, terminal) └── runs/ # Real Garak scan results against GPT-2 ``` ## 演讲当天设置 在演讲开始 **30 分钟前** 运行此命令,一次性完成所有设置: ``` source scripts/setup.sh ``` 这将: 1. `cd` 到项目目录 2. 创建并激活 Python virtual environment 3. 安装依赖项(`anthropic`,`boto3`) 4. 运行所有预检(demo、网络、终端大小) 设置完成后,在 **Chrome** 中打开演示文稿(字体渲染最佳): ``` open -a "Google Chrome" presentation/index.html ``` 在浏览器中按 `S` 打开演讲者备注窗口。 ### 仅预检 如果 venv 已设置好,只想验证一切正常: ``` bash scripts/preflight.sh ``` ### 镜像终端 (tmux) 在投影仪上显示终端并从笔记本电脑输入 —— 两者看到的是同一个会话: ``` # Projector 终端 tmux new-session -s demo # 笔记本电脑终端 tmux attach -t demo ``` ## 快速开始 所有 demo 都针对本地模拟聊天机器人运行 —— **不需要 API key 或云服务**。 ``` # 激活 venv source .venv/bin/activate # 运行演示(mock 模式) python3 demos/01_confused_deputy.py python3 demos/03_pyrit_demo.py python3 demos/04_guardrails_demo.py python3 demos/05_supply_chain_check.py python3 demos/06_deepseek_attacks.py # 运行 Garak 实时扫描(需要 garak + GPT-2 模型) bash demos/02_garak_live_scan.sh quick ``` ### 实时模式(可选,需要凭证) 部分 demo 支持 `--live` 或 `--backend bedrock` 标志,用于针对真实模型运行: ``` # 需要有效的 AWS 凭证以用于 Bedrock python3 demos/06_deepseek_attacks.py --backend bedrock # 需要安装 Ollama 并拉取 DeepSeek 模型 python3 demos/06_deepseek_attacks.py --backend ollama ``` ## 涵盖的工具 | 工具 | 功能 | 许可证 | |------|-------------|---------| | [Garak](https://github.com/NVIDIA/garak) | LLM 漏洞扫描器("LLM 版 nmap") | Apache 2.0 | | [PyRIT](https://github.com/Azure/PyRIT) | 多轮红队框架("LLM 版 Burp Suite") | MIT | ## 关键主题 - Prompt injection(直接和间接) - Confused Deputy 攻击 - 编码绕过(Base64, ROT13, Leetspeak) - 多轮攻击:Crescendo, PAIR, Tree of Attacks - 真实事件:EchoLeak (CVE-2025-32711), Skeleton Key - 防御性防护栏(输入/输出过滤) - 供应链安全(pickle 漏洞利用、哈希验证) - 用于 LLM 安全测试的 CI/CD 集成 ## 需求 核心 demo(01, 03, 04, 05, 06)仅使用 Python 标准库以及 `anthropic` 和 `boto3`(由 `setup.sh` 安装)。 查看完整依赖列表(包括 Garak, transformers, torch): ``` pip install -r requirements.txt ``` ## 资源 - [OWASP LLM Top 10](https://owasp.org/www-project-top-10-for-large-language-model-applications/) - [Garak 文档](https://docs.garak.ai) - [PyRIT 文档](https://azure.github.io/PyRIT/) - [Crescendo 攻击论文 (USENIX Security 2025)](https://arxiv.org/abs/2404.01833) - [Skeleton Key 越狱 (Microsoft)](https://www.microsoft.com/en-us/security/blog/2024/06/26/mitigating-skeleton-key-a-new-type-of-generative-ai-jailbreak-technique/) ## 许可证 MIT
标签:AI伦理, AI漏洞扫描, AI红队测试, AI风险缓解, Crescendo攻击, DeepSeek安全, DNS 解析, Garak, Guardrails, NeMo Guardrails, Pickle安全, Prompt注入, PyRIT, Python, REST API安全, SCALE 23x, 后端开发, 后端开发, 基线管理, 多智能体系统, 多轮对话攻击, 大模型防御, 大语言模型安全, 开源安全工具, 技术演讲, 文档安全, 无后门, 机密管理, 模型反序列化, 深度学习安全, 混淆代理人攻击, 演示代码, 逆向工具, 逆向工程平台, 配置审计, 间接提示注入