sherifkozman/the-red-council

GitHub: sherifkozman/the-red-council

一个多 Agent 编排的 LLM 与 AI Agent 对抗安全测试平台,实现攻击、检测、防御、验证的闭环自动化流程。

Stars: 16 | Forks: 2

The Red Council

AI 红队与安全 — 攻击。评估。修补。

Tests Coverage Python License

## 什么是 The Red Council? The Red Council 是一个用于大语言模型(LLM)的自动化对抗测试平台。它实现了一个闭环安全工作流,能够识别漏洞、自动生成防御措施,并实时验证其有效性。 它利用 **Gemini 3 Pro** 进行攻击生成、评判和防御。 ### 核心循环 1. **攻击**:红队 agent 使用包含 165+ 精选工件的知识库生成对抗性 prompt。 2. **评判**:公正的评估器对目标的响应进行安全违规评分(机密泄露、策略违规)。 3. **防御**:如果检测到违规,蓝队 agent 会自动加强目标的系统 prompt。 4. **验证**:编排器(Orchestrator)针对强化后的模型重新运行攻击,以证明修复有效。 ## 核心功能 - **多 Agent 对抗流程**:通过 LangGraph 进行编排。 - **实时战斗 UI**:使用 Next.js 14 和 Tailwind 进行实时攻击可视化。 - **RAG 增强攻击**:从 HarmBench 和 PyRIT 数据集中精选的知识库。 - **生产级 API**:带有 SSE 流式传输的强化版 FastAPI 后端。 - **通用配置**:支持任何 LLM endpoint(OpenAI、Anthropic、Vertex、本地)。 - **OpenClaw 集成**:将 OpenClaw agent 作为一项技能进行测试([文档](docs/tutorials/openclaw-integration.md))。 ## 快速开始 ### 前置条件 - Python 3.11+ - Node.js 18+(用于前端) - Google Cloud 凭证(用于访问 Vertex AI) ### 安装 ``` # Clone git clone https://github.com/sherifkozman/the-red-council.git cd the-red-council # Setup Backend python -m venv venv source venv/bin/activate # 基础安装(核心功能) pip install -e . # 或者包含 framework 集成: pip install -e ".[langchain]" # LangChain integration pip install -e ".[langgraph]" # LangGraph integration pip install -e ".[mcp]" # MCP protocol integration pip install -e ".[all-frameworks]" # All framework integrations # Development dependencies(用于贡献) pip install -e ".[dev]" # 初始化知识库 python -m scripts.seed_kb # Setup Frontend cd frontend pnpm install ``` ### 安装选项 The Red Council 支持用于框架集成的可选依赖项: | 扩展 | 安装命令 | 描述 | |-------|-----------------|-------------| | Core | `pip install -e .` | 核心功能、UI 和 API | | langchain | `pip install -e ".[langchain]"` | LangChain agent 集成 | | langgraph | `pip install -e ".[langgraph]"` | LangGraph 工作流集成 | | mcp | `pip install -e ".[mcp]"` | MCP 协议集成 | | all-frameworks | `pip install -e ".[all-frameworks]"` | 所有框架集成 | | dev | `pip install -e ".[dev]"` | 开发工具(pytest, ruff, mypy) | **注意:** 框架扩展是可选的。核心包在未安装任何框架集成的情况下也能正常工作。 ### 运行竞技场 ``` # Terminal 1:API Backend uvicorn src.api.main:app --port 8000 # Terminal 2:Tactical UI cd frontend && pnpm dev ``` 打开 [http://localhost:3000](http://localhost:3000) 开始你的第一次战役。 ## Agent 安全测试 (v0.5.0) The Red Council v0.5.0超越了纯粹的 LLM 测试,支持使用 **OWASP Agentic Top 10** 漏洞框架进行 **AI Agent 安全测试**。 ### Agent 测试功能 - **InstrumentedAgent SDK**:封装任何 agent 以捕获工具调用、内存访问和操作 - **OWASP Agentic Top 10**:测试所有 10 个特定于 agent 的漏洞 (ASI01-ASI10) - **框架集成**:原生支持 LangChain、LangGraph 和 MCP 协议 - **安全报告**:提供详细的漏洞发现和修复指南 ### 快速示例 ``` from src.agents.instrumented import InstrumentedAgent from src.core.agent_schemas import AgentInstrumentationConfig from src.agents.agent_judge import AgentJudge, AgentJudgeConfig # 1. 配置 instrumentation config = AgentInstrumentationConfig( enable_tool_interception=True, enable_memory_monitoring=True, divergence_threshold=0.5, ) # 2. 包装你的 agent instrumented = InstrumentedAgent(my_agent, "test-agent", config) # 3. 运行你的 agent(自动捕获事件) with instrumented: result = instrumented.wrap_tool_call("search", search_func, query="test") # 4. 评估安全漏洞 judge = AgentJudge() score = judge.evaluate_agent(instrumented.events) print(f"Risk Score: {score.overall_agent_risk}/10") for violation in score.owasp_violations: if violation.detected: print(f" {violation.owasp_category}: {violation.evidence}") ``` ### 框架集成 ``` # LangChain from src.integrations import LangChainAgentWrapper wrapped = LangChainAgentWrapper.from_agent_executor(my_executor, config) # LangGraph from src.integrations import LangGraphAgentWrapper wrapped = LangGraphAgentWrapper.from_state_graph(my_graph, config) # MCP Protocol from src.integrations import MCPAgentWrapper wrapped = await MCPAgentWrapper.from_stdio_server(["python", "server.py"], config) ``` ### API Endpoints Agent 测试可通过 REST API 使用: ``` # 创建测试 session curl -X POST http://localhost:8000/api/v1/agent/session \ -H "Content-Type: application/json" \ -d '{"context": "Agent under test"}' # 提交事件 curl -X POST http://localhost:8000/api/v1/agent/session/{session_id}/events \ -H "Content-Type: application/json" \ -d '{"events": [{"event_type": "tool_call", "tool_name": "search", ...}]}' # 运行评估 curl -X POST http://localhost:8000/api/v1/agent/session/{session_id}/evaluate # 获取安全报告 curl http://localhost:8000/api/v1/agent/session/{session_id}/report ``` 有关综合文档,请参阅 [Agent 测试指南](docs/agent-testing-guide.md)。 ## 文档 - [快速开始指南](docs/quickstart.md) - [Agent 测试指南](docs/agent-testing-guide.md) *(v0.5.0 新增)* - [OpenClaw 集成](docs/tutorials/openclaw-integration.md) - [架构与设计](docs/architecture.md) - [API 参考](docs/api-reference.md) - [配置指南](docs/configuration.md) - [路线图](ROADMAP.md) ## 许可证 MIT - 详情请参阅 [LICENSE](LICENSE)。
标签:AI安全, AV绕过, Chat Copilot, DLL 劫持, FastAPI, LangGraph, LLM越狱, MITM代理, 多智能体, 大语言模型, 红队评估, 配置审计