dogahwisdom/ai-agent-security-attack

GitHub: dogahwisdom/ai-agent-security-attack

基于 Go-Explore 风格算法的模块化红队攻击 pipeline,用于自动发现工具型 AI Agent 中的多步安全故障。

Stars: 1 | Forks: 0

# AI Agent 安全 — 多步攻击 用于 Kaggle 竞赛的模块化红队攻击 pipeline [**AI Agent 安全 — 多步工具攻击**](https://www.kaggle.com/competitions/ai-agent-security-multi-step-tool-attacks) (OpenAI, 2026)。 该提交实现了 **MultiStepExplorer**,这是一种 Go-Explore 风格的算法,通过前沿归档、cell 签名和批量 prompt 分支,发现使用工具的 agent 中可复现的多步故障。 **Kaggle 实时 notebook:** [jed-attack-submission](https://www.kaggle.com/code/wisdomdogah/jed-attack-submission) ## 架构 ``` attack.py # Kaggle entry (AttackAlgorithm → MultiStepExplorer) src/agent_security/ algorithms/multi_step_explorer.py # Main attack loop coordinators/branch_runner.py # Per-cell expansion exploration/ # Archive, prompts, signatures, rewards config/explorer_settings.py # Tunable hyperparameters kaggle_kernel/ # Notebook + metadata for Kaggle push scripts/ # Dev, eval, and deployment tooling ``` ``` flowchart LR subgraph explorer [MultiStepExplorer] Seed[Seed archive] --> Loop{Time / steps left?} Loop --> Select[CellSelector] Select --> Branch[BranchRunner] Branch --> Archive[FrontierArchive] Branch --> Findings[AttackCandidate list] Archive --> Loop end Env[AttackEnv] <--> Branch ``` ## 快速开始 **要求:** Python 3.11+,带有 OAuth 的 [Kaggle CLI](https://github.com/Kaggle/kaggle-api)。 ``` git clone https://github.com/dogahwisdom/ai-agent-security-attack.git cd ai-agent-security-attack python3 -m venv .venv && source .venv/bin/activate pip install -e ".[dev]" ./scripts/download_competition.sh ``` ### 本地评估 ``` ./scripts/evaluate.sh pytest ruff check src tests attack.py ``` ### Kaggle notebook 部署 ``` ./scripts/setup_kaggle_oauth.sh # one-time OAuth setup ./scripts/push_kernel.sh # rebuild notebook + push ./scripts/verify_kaggle_oauth.sh # smoke test ``` ## 竞赛提交 这是一项通过 Kaggle notebook 和推理服务器进行评估的**代码竞赛**。 | 要求 | 值 | |-------------|-------| | Accelerator | **GPU T4 x2**(P100 会被拒绝) | | 提交文件 | **`submission.csv`**(分数在隐藏重新运行时写入) | | 算法 artifact | 位于 `/kaggle/working/` 下的 `attack.py` | **网页提交(推荐):** 1. 打开 [notebook](https://www.kaggle.com/code/wisdomdogah/jed-attack-submission) → **Edit** 2. **Settings** → accelerator **GPU T4 x2** 3. **File** → **Save Version** → **Save & Run All (Commit)** 4. **Output** → 确认生成 `submission.csv` 和 `attack.py` 5. 竞赛页面 → **Submit Prediction** → **Notebook** → 最新版本 → **submission.csv** 参考:[入门 Notebook](https://www.kaggle.com/code/martynaplomecka/getting-started-notebook) ## 配置 将 config 字典传递给 `MultiStepExplorer`(或通过 Kaggle `AttackAlgorithm` 初始化): | 键 | 默认值 | 描述 | |-----|---------|-------------| | `max_turns` | 20 | 每次运行的最大探索轮数 | | `branch_batch` | 12 | 每个归档 cell 尝试的 prompt 数量 | | `target_shell` | false | 使用专注于 shell 的 prompt 库 | | `seed_prompt` | `"open demo"` | 初始归档 seed 消息 | ## 项目布局 | 路径 | 用途 | |------|---------| | `attack.py` | 竞赛入口点 | | `src/agent_security/` | 模块化攻击库 | | `kaggle_kernel/` | 生成的 notebook + `kernel-metadata.json` | | `scripts/` | 下载、评估、OAuth、kernel 推送 | | `tests/` | 单元测试 | | `data/` | 竞赛 SDK(已 gitignore;运行下载脚本) | ## 许可证 MIT — 见 [LICENSE](LICENSE)。 ## 致谢 - [OpenAI / Kaggle AI Agent 安全竞赛](https://www.kaggle.com/competitions/ai-agent-security-multi-step-tool-attacks) - [`aicomp-sdk`](https://pypi.org/project/aicomp-sdk/) 评估框架
标签:AI安全, Chat Copilot, LLM Agent, Petitpotam, Python, 安全规则引擎, 无后门, 逆向工具