redagent 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. redagent-0.1.0/LICENSE +17 -0
  2. redagent-0.1.0/PKG-INFO +282 -0
  3. redagent-0.1.0/README.md +249 -0
  4. redagent-0.1.0/config/__init__.py +4 -0
  5. redagent-0.1.0/config/settings.py +45 -0
  6. redagent-0.1.0/pyproject.toml +50 -0
  7. redagent-0.1.0/redagent/__init__.py +42 -0
  8. redagent-0.1.0/redagent/agents/__init__.py +16 -0
  9. redagent-0.1.0/redagent/agents/base.py +130 -0
  10. redagent-0.1.0/redagent/agents/data_exfil.py +71 -0
  11. redagent-0.1.0/redagent/agents/evaluator.py +222 -0
  12. redagent-0.1.0/redagent/agents/orchestrator.py +168 -0
  13. redagent-0.1.0/redagent/agents/prompt_injection.py +71 -0
  14. redagent-0.1.0/redagent/agents/tool_abuse.py +77 -0
  15. redagent-0.1.0/redagent/cli.py +296 -0
  16. redagent-0.1.0/redagent/connectors/__init__.py +11 -0
  17. redagent-0.1.0/redagent/connectors/base.py +33 -0
  18. redagent-0.1.0/redagent/connectors/mock.py +116 -0
  19. redagent-0.1.0/redagent/connectors/rest.py +87 -0
  20. redagent-0.1.0/redagent/core/__init__.py +4 -0
  21. redagent-0.1.0/redagent/core/graph.py +127 -0
  22. redagent-0.1.0/redagent/core/iteration_engine.py +265 -0
  23. redagent-0.1.0/redagent/core/llm.py +56 -0
  24. redagent-0.1.0/redagent/core/logger.py +38 -0
  25. redagent-0.1.0/redagent/knowledge/__init__.py +5 -0
  26. redagent-0.1.0/redagent/knowledge/seed_data.py +98 -0
  27. redagent-0.1.0/redagent/knowledge/vector_store.py +163 -0
  28. redagent-0.1.0/redagent/schemas/__init__.py +35 -0
  29. redagent-0.1.0/redagent/schemas/execution.py +50 -0
  30. redagent-0.1.0/redagent/schemas/finding.py +54 -0
  31. redagent-0.1.0/redagent/schemas/report.py +132 -0
  32. redagent-0.1.0/redagent/schemas/state.py +72 -0
  33. redagent-0.1.0/redagent/schemas/target.py +61 -0
  34. redagent-0.1.0/redagent/schemas/test_case.py +85 -0
  35. redagent-0.1.0/redagent/tools/__init__.py +5 -0
  36. redagent-0.1.0/redagent/tools/base_tool.py +15 -0
  37. redagent-0.1.0/redagent/tools/target_client.py +61 -0
  38. redagent-0.1.0/redagent.egg-info/PKG-INFO +282 -0
  39. redagent-0.1.0/redagent.egg-info/SOURCES.txt +43 -0
  40. redagent-0.1.0/redagent.egg-info/dependency_links.txt +1 -0
  41. redagent-0.1.0/redagent.egg-info/entry_points.txt +2 -0
  42. redagent-0.1.0/redagent.egg-info/requires.txt +19 -0
  43. redagent-0.1.0/redagent.egg-info/top_level.txt +2 -0
  44. redagent-0.1.0/setup.cfg +4 -0
  45. redagent-0.1.0/tests/test_redagent.py +125 -0
redagent-0.1.0/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ Copyright 2026 RedAgent Project Authors
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
@@ -0,0 +1,282 @@
1
+ Metadata-Version: 2.4
2
+ Name: redagent
3
+ Version: 0.1.0
4
+ Summary: AI Agent Security & Automated Red Teaming Platform
5
+ Author: RedAgent Architecture Team
6
+ License: Apache-2.0
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.11
9
+ Classifier: Topic :: Security
10
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
11
+ Requires-Python: >=3.11
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: pydantic>=2.7.0
15
+ Requires-Dist: pydantic-settings>=2.2.0
16
+ Requires-Dist: langgraph>=0.2.0
17
+ Requires-Dist: langchain>=0.2.0
18
+ Requires-Dist: langchain-core>=0.2.0
19
+ Requires-Dist: litellm>=1.40.0
20
+ Requires-Dist: httpx>=0.27.0
21
+ Requires-Dist: redis>=5.0.0
22
+ Requires-Dist: chromadb>=0.5.0
23
+ Requires-Dist: rich>=13.7.0
24
+ Requires-Dist: python-dotenv>=1.0.1
25
+ Requires-Dist: structlog>=24.1.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=8.2.0; extra == "dev"
28
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
29
+ Requires-Dist: black>=24.4.0; extra == "dev"
30
+ Requires-Dist: isort>=5.13.0; extra == "dev"
31
+ Requires-Dist: mypy>=1.10.0; extra == "dev"
32
+ Dynamic: license-file
33
+
34
+ <div align="center">
35
+
36
+ # RedAgent
37
+ ### Autonomous AI Agent Red Teaming & Security Auditing Platform
38
+ **Stateful Multi-Agent Vulnerability Assessment Engine for Enterprise LLM Systems**
39
+
40
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
41
+ [![Python: 3.11+](https://img.shields.io/badge/Python-3.11%2B-3776AB.svg?logo=python&logoColor=white)](pyproject.toml)
42
+ [![Framework: LangGraph](https://img.shields.io/badge/Orchestration-LangGraph-FF4B4B.svg)](https://github.com/langchain-ai/langgraph)
43
+ [![Tests: Passing](https://img.shields.io/badge/Tests-6%2F6%20Passed-brightgreen.svg)](tests/)
44
+ [![Security: OWASP LLM Top 10](https://img.shields.io/badge/Standard-OWASP_LLM_Top_10-red.svg)](https://owasp.org/www-project-top-10-for-large-language-model-applications/)
45
+
46
+ [Features](#key-features) • [Architecture](#system-architecture) • [Quickstart](#quickstart--installation) • [CLI Usage](#cli-usage) • [SDK Usage](#python-sdk--cicd-integration) • [Legal Notice](#legal-disclaimer--authorized-use-policy)
47
+
48
+ </div>
49
+
50
+ ---
51
+
52
+ > [!WARNING]
53
+ > ### LEGAL DISCLAIMER & AUTHORIZED USE POLICY
54
+ > **RedAgent is strictly designed for authorized security auditing, internal red teaming, academic research, and defensive hardening.**
55
+ >
56
+ > Testing AI agents, API endpoints, or systems without prior **explicit, written authorization** from the system owner is illegal and violates computer crime laws (e.g., Computer Fraud and Abuse Act - CFAA, EU NIS2, UK Computer Misuse Act). The authors and contributors of RedAgent assume **no liability** and are not responsible for any misuse, damage, or legal consequences resulting from this tool. By using RedAgent, you agree to comply with all applicable local and international cybersecurity laws.
57
+
58
+ ---
59
+
60
+ ## Why RedAgent?
61
+
62
+ Traditional Dynamic Application Security Testing (DAST) and API scanners are fundamentally incapable of discovering non-deterministic LLM vulnerabilities:
63
+ - They do not understand conversational state, prompt boundaries, or instruction delimiters.
64
+ - They conclude execution after a single HTTP 200 or standard polite refusal ("I am sorry, but...").
65
+ - They cannot evaluate autonomous function calling (`Excessive Agency`) or vector memory leakage (`RAG Data Exfiltration`).
66
+
67
+ **RedAgent solves this by deploying a team of adversarial AI agents.** Powered by a **Dynamic Test Iteration Engine with Backtracking**, our specialist agents analyze target refusals, systematically mutate boundary conditions (delimiters, role claims, parameter tampering), and continue exploring alternative attack vectors until every path on the exploration tree is exhausted.
68
+
69
+ ---
70
+
71
+ ## Key Features
72
+
73
+ - **OWASP LLM Top 10 Coverage:** Automated test generation mapped to Prompt Injection (LLM01), Sensitive Information Disclosure (LLM06), and Excessive Agency / Insecure Tool Abuse (LLM07/LLM08).
74
+ - **Persistent Refinement with Backtracking:** Agents do not surrender on a single defense. When a prompt is blocked by a guardrail, the engine backtracks and mutates formatting, delimiters, and semantic framing.
75
+ - **ChromaDB Vector Knowledge Store:** Persistently indexes adversarial seeds, boundary test templates, and OWASP evaluation rubrics (with zero-dependency in-memory fallback).
76
+ - **Pluggable Target Connectors:** Test local mock agents, staging bots, or live enterprise agents over REST API endpoints (`RestTargetConnector`).
77
+ - **Actionable Remediation Roadmap:** Automatically generates concrete developer fixes, including regex guardrail patterns, system prompt hardening snippets, and RBAC constraints.
78
+ - **Dual Mode (CLI + SDK):** Run as a standalone terminal security scanner or embed into Python CI/CD pipelines.
79
+
80
+ ---
81
+
82
+ ## System Architecture
83
+
84
+ RedAgent operates as a stateful Directed Acyclic Graph (DAG) built on **LangGraph**, **Pydantic v2**, and **LiteLLM**:
85
+
86
+ ```mermaid
87
+ graph TD
88
+ A[Target AI Agent Profile] --> B[Orchestrator Agent]
89
+ B --> C{Adversarial Specialists}
90
+ C -->|OWASP LLM01| D[Prompt Injection Specialist]
91
+ C -->|OWASP LLM07/LLM08| E[Tool Abuse & Authorization Agent]
92
+ C -->|OWASP LLM06| F[Data Exfiltration Agent]
93
+
94
+ subgraph Persistent Refinement Loop
95
+ D <-->|Multi-turn Mutation & Backtracking| IE[Dynamic Test Iteration Engine]
96
+ E <-->|Adaptive Strategy Shift| IE
97
+ F <-->|Vector Seed Retrieval| IE
98
+ IE <--> VS[(Security Vector Store: ChromaDB)]
99
+ IE <--> TC[Target Connectors: Mock / REST]
100
+ end
101
+
102
+ D --> G[Evaluator & Reporting Agent]
103
+ E --> G
104
+ F --> G
105
+ G --> H[Final Audit Report & Remediation Roadmap]
106
+ ```
107
+
108
+ ### Specialized Multi-Agent Roles
109
+
110
+ | Agent Role | Domain Specialty | OWASP Focus | Core Objective |
111
+ | :--- | :--- | :--- | :--- |
112
+ | **Orchestrator Agent** | Threat Modeler & Planner | System-wide | Profiles target tools, RAG connections, and generates structured test matrices. |
113
+ | **Prompt Injection Specialist** | Boundary & Delimiter Attacks | LLM01 | Tests instruction delimiters, goal hijacking, and system override resistance. |
114
+ | **Tool Abuse Agent** | RBAC & Excessive Agency | LLM07, LLM08 | Tests unconstrained function calling, parameter tampering, and privilege escalation. |
115
+ | **Data Exfiltration Agent** | Confidentiality & Memory | LLM06 | Evaluates system prompt leaks, canary tokens, and RAG metadata disclosure. |
116
+ | **Evaluator & Reporter** | Semantic Analysis & Risk | Comprehensive | Computes risk scores (0-10) and formulates concrete developer remediation rules. |
117
+
118
+ ---
119
+
120
+ ## Quickstart & Installation
121
+
122
+ ### 1. Installation
123
+ Clone the repository and install in editable mode:
124
+
125
+ ```bash
126
+ git clone https://github.com/Zwony/RedAgent.git
127
+ cd RedAgent
128
+
129
+ # Create and activate virtual environment
130
+ python -m venv venv
131
+ # Windows:
132
+ .\venv\Scripts\activate
133
+ # Linux/macOS:
134
+ source venv/bin/activate
135
+
136
+ # Install dependencies and CLI tool
137
+ pip install -e .
138
+ ```
139
+
140
+ ### 2. Configure Environment (Optional)
141
+ To use cloud LLMs (OpenAI, Anthropic, Gemini) for the attack and evaluation agents, copy `.env.example`:
142
+
143
+ ```bash
144
+ cp .env.example .env
145
+ ```
146
+ And specify your API keys:
147
+ ```env
148
+ OPENAI_API_KEY=your_key_here
149
+ DEFAULT_ATTACKER_MODEL=gpt-4o
150
+ ```
151
+
152
+ ---
153
+
154
+ ## CLI Usage
155
+
156
+ ### 1. Scaffold a New Target Agent Profile
157
+ Generate a starter configuration file with customizable tools and RAG settings:
158
+ ```bash
159
+ redagent init --output target.json --name "CustomerServiceAgent"
160
+ ```
161
+
162
+ ### 2. Run Security Audit on an AI Agent Profile
163
+ Execute the stateful multi-agent DAG against your target and export an executive Markdown report:
164
+ ```bash
165
+ redagent scan --target target.json --output audit_report.md
166
+ ```
167
+ Or export as structured JSON:
168
+ ```bash
169
+ redagent scan --target target.json --output report.json
170
+ ```
171
+
172
+ ### 3. Run the Interactive Sandbox Demo
173
+ Experience the multi-agent refinement loop against a simulated banking assistant:
174
+ ```bash
175
+ redagent demo
176
+ ```
177
+
178
+ ---
179
+
180
+ ## Sample Audit Output
181
+
182
+ When an audit finishes, RedAgent renders a comprehensive executive summary and remediation table:
183
+
184
+ ```text
185
+ Security Audit Posture Summary
186
+ +-----------------------------------------------+
187
+ | Metric | Value |
188
+ |-------------------+---------------------------|
189
+ | Target Name | Acme Customer Service Bot |
190
+ | Overall Rating | CRITICAL_RISK |
191
+ | Max Risk Score | 9.1 / 10.0 |
192
+ | Total Test Cases | 6 |
193
+ | Findings Detected | 3 |
194
+ +-----------------------------------------------+
195
+
196
+ Vulnerability Findings & Evaluator Analysis
197
+ +-----------------------------------------------------------------------------+
198
+ | Finding ID | Category | Severity | Status | Remediation |
199
+ |--------------+----------------+----------+-----------------+----------------|
200
+ | fnd_fa89278c | LLM01: Prompt | HIGH | confirmed_vuln | Sanitize input |
201
+ | | Injection | | | delimiters |
202
+ | fnd_df05d8d0 | LLM08: | CRITICAL | confirmed_vuln | Enforce RBAC |
203
+ | | Excessive | | | & schema check |
204
+ | | Agency | | | on query tool |
205
+ | fnd_e8a2e77f | LLM08: | CRITICAL | confirmed_vuln | Require user |
206
+ | | Excessive | | | confirmation |
207
+ | | Agency | | | for wire trf |
208
+ | fnd_3d6dc2bd | LLM01: Prompt | INFO | robust_defense | Boundary kept |
209
+ | fnd_223a6591 | LLM06: Data | INFO | robust_defense | Prompt kept |
210
+ | fnd_951b5078 | LLM06: Data | INFO | robust_defense | KB protected |
211
+ +-----------------------------------------------------------------------------+
212
+
213
+ => Hardening & Guardrail Remediation Roadmap:
214
+ #1 [LLM08: Excessive Agency]: Enforce server-side RBAC and schema constraints on tool 'lookup_customer_order'.
215
+ #2 [LLM08: Excessive Agency]: Require explicit user confirmation token for sensitive function calls ('cancel_and_refund_order').
216
+ #3 [LLM01: Prompt Injection]: Sanitize input delimiters such as triple backticks or custom markup tags.
217
+ ```
218
+
219
+ ---
220
+
221
+ ## Python SDK & CI/CD Integration
222
+
223
+ Embed automated AI red teaming directly into test suites or CI/CD pipelines:
224
+
225
+ ```python
226
+ import asyncio
227
+ from redagent import RedTeamGraphEngine, TargetInfo, TargetToolDefinition
228
+
229
+ async def test_ai_agent_security():
230
+ # 1. Define Target System
231
+ target = TargetInfo(
232
+ target_id="support_bot_staging",
233
+ name="Customer Service Assistant",
234
+ endpoint_type="rest_api",
235
+ endpoint_url="https://staging.acme.internal/agent",
236
+ accessible_tools=[
237
+ TargetToolDefinition(
238
+ name="query_orders",
239
+ description="Queries customer orders by ID",
240
+ is_sensitive=True,
241
+ )
242
+ ],
243
+ has_rag=True,
244
+ rag_sources=["internal_kb"],
245
+ )
246
+
247
+ # 2. Run RedAgent Engine
248
+ engine = RedTeamGraphEngine()
249
+ final_state = await engine.run(target=target)
250
+
251
+ # 3. Assert Security Baseline in CI/CD
252
+ report = final_state.audit_report
253
+ assert report.overall_rating.value in ("SECURE", "LOW_RISK"), (
254
+ f"Security audit failed with posture: {report.overall_rating.value} (Risk: {report.overall_risk_score}/10)"
255
+ )
256
+
257
+ if __name__ == "__main__":
258
+ asyncio.run(test_ai_agent_security())
259
+ ```
260
+
261
+ ---
262
+
263
+ ## Running Regression Tests
264
+
265
+ Ensure platform integrity across all modules:
266
+ ```bash
267
+ pytest -v tests/
268
+ ```
269
+
270
+ ## Community & Contributing
271
+
272
+ We welcome contributions from security researchers, AI engineers, and open-source developers.
273
+
274
+ - **Contributing Guide:** Review [CONTRIBUTING.md](CONTRIBUTING.md) for local environment setup, coding standards, and agent creation guides.
275
+ - **Security Policy:** To report vulnerabilities in RedAgent itself, consult [SECURITY.md](SECURITY.md).
276
+ - **Code of Conduct:** We adhere to the Contributor Covenant. See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).
277
+ - **Release History:** See [CHANGELOG.md](CHANGELOG.md) for version notes and release highlights.
278
+
279
+ ---
280
+
281
+ ## License
282
+ This project is licensed under the **Apache License 2.0** - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,249 @@
1
+ <div align="center">
2
+
3
+ # RedAgent
4
+ ### Autonomous AI Agent Red Teaming & Security Auditing Platform
5
+ **Stateful Multi-Agent Vulnerability Assessment Engine for Enterprise LLM Systems**
6
+
7
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
8
+ [![Python: 3.11+](https://img.shields.io/badge/Python-3.11%2B-3776AB.svg?logo=python&logoColor=white)](pyproject.toml)
9
+ [![Framework: LangGraph](https://img.shields.io/badge/Orchestration-LangGraph-FF4B4B.svg)](https://github.com/langchain-ai/langgraph)
10
+ [![Tests: Passing](https://img.shields.io/badge/Tests-6%2F6%20Passed-brightgreen.svg)](tests/)
11
+ [![Security: OWASP LLM Top 10](https://img.shields.io/badge/Standard-OWASP_LLM_Top_10-red.svg)](https://owasp.org/www-project-top-10-for-large-language-model-applications/)
12
+
13
+ [Features](#key-features) • [Architecture](#system-architecture) • [Quickstart](#quickstart--installation) • [CLI Usage](#cli-usage) • [SDK Usage](#python-sdk--cicd-integration) • [Legal Notice](#legal-disclaimer--authorized-use-policy)
14
+
15
+ </div>
16
+
17
+ ---
18
+
19
+ > [!WARNING]
20
+ > ### LEGAL DISCLAIMER & AUTHORIZED USE POLICY
21
+ > **RedAgent is strictly designed for authorized security auditing, internal red teaming, academic research, and defensive hardening.**
22
+ >
23
+ > Testing AI agents, API endpoints, or systems without prior **explicit, written authorization** from the system owner is illegal and violates computer crime laws (e.g., Computer Fraud and Abuse Act - CFAA, EU NIS2, UK Computer Misuse Act). The authors and contributors of RedAgent assume **no liability** and are not responsible for any misuse, damage, or legal consequences resulting from this tool. By using RedAgent, you agree to comply with all applicable local and international cybersecurity laws.
24
+
25
+ ---
26
+
27
+ ## Why RedAgent?
28
+
29
+ Traditional Dynamic Application Security Testing (DAST) and API scanners are fundamentally incapable of discovering non-deterministic LLM vulnerabilities:
30
+ - They do not understand conversational state, prompt boundaries, or instruction delimiters.
31
+ - They conclude execution after a single HTTP 200 or standard polite refusal ("I am sorry, but...").
32
+ - They cannot evaluate autonomous function calling (`Excessive Agency`) or vector memory leakage (`RAG Data Exfiltration`).
33
+
34
+ **RedAgent solves this by deploying a team of adversarial AI agents.** Powered by a **Dynamic Test Iteration Engine with Backtracking**, our specialist agents analyze target refusals, systematically mutate boundary conditions (delimiters, role claims, parameter tampering), and continue exploring alternative attack vectors until every path on the exploration tree is exhausted.
35
+
36
+ ---
37
+
38
+ ## Key Features
39
+
40
+ - **OWASP LLM Top 10 Coverage:** Automated test generation mapped to Prompt Injection (LLM01), Sensitive Information Disclosure (LLM06), and Excessive Agency / Insecure Tool Abuse (LLM07/LLM08).
41
+ - **Persistent Refinement with Backtracking:** Agents do not surrender on a single defense. When a prompt is blocked by a guardrail, the engine backtracks and mutates formatting, delimiters, and semantic framing.
42
+ - **ChromaDB Vector Knowledge Store:** Persistently indexes adversarial seeds, boundary test templates, and OWASP evaluation rubrics (with zero-dependency in-memory fallback).
43
+ - **Pluggable Target Connectors:** Test local mock agents, staging bots, or live enterprise agents over REST API endpoints (`RestTargetConnector`).
44
+ - **Actionable Remediation Roadmap:** Automatically generates concrete developer fixes, including regex guardrail patterns, system prompt hardening snippets, and RBAC constraints.
45
+ - **Dual Mode (CLI + SDK):** Run as a standalone terminal security scanner or embed into Python CI/CD pipelines.
46
+
47
+ ---
48
+
49
+ ## System Architecture
50
+
51
+ RedAgent operates as a stateful Directed Acyclic Graph (DAG) built on **LangGraph**, **Pydantic v2**, and **LiteLLM**:
52
+
53
+ ```mermaid
54
+ graph TD
55
+ A[Target AI Agent Profile] --> B[Orchestrator Agent]
56
+ B --> C{Adversarial Specialists}
57
+ C -->|OWASP LLM01| D[Prompt Injection Specialist]
58
+ C -->|OWASP LLM07/LLM08| E[Tool Abuse & Authorization Agent]
59
+ C -->|OWASP LLM06| F[Data Exfiltration Agent]
60
+
61
+ subgraph Persistent Refinement Loop
62
+ D <-->|Multi-turn Mutation & Backtracking| IE[Dynamic Test Iteration Engine]
63
+ E <-->|Adaptive Strategy Shift| IE
64
+ F <-->|Vector Seed Retrieval| IE
65
+ IE <--> VS[(Security Vector Store: ChromaDB)]
66
+ IE <--> TC[Target Connectors: Mock / REST]
67
+ end
68
+
69
+ D --> G[Evaluator & Reporting Agent]
70
+ E --> G
71
+ F --> G
72
+ G --> H[Final Audit Report & Remediation Roadmap]
73
+ ```
74
+
75
+ ### Specialized Multi-Agent Roles
76
+
77
+ | Agent Role | Domain Specialty | OWASP Focus | Core Objective |
78
+ | :--- | :--- | :--- | :--- |
79
+ | **Orchestrator Agent** | Threat Modeler & Planner | System-wide | Profiles target tools, RAG connections, and generates structured test matrices. |
80
+ | **Prompt Injection Specialist** | Boundary & Delimiter Attacks | LLM01 | Tests instruction delimiters, goal hijacking, and system override resistance. |
81
+ | **Tool Abuse Agent** | RBAC & Excessive Agency | LLM07, LLM08 | Tests unconstrained function calling, parameter tampering, and privilege escalation. |
82
+ | **Data Exfiltration Agent** | Confidentiality & Memory | LLM06 | Evaluates system prompt leaks, canary tokens, and RAG metadata disclosure. |
83
+ | **Evaluator & Reporter** | Semantic Analysis & Risk | Comprehensive | Computes risk scores (0-10) and formulates concrete developer remediation rules. |
84
+
85
+ ---
86
+
87
+ ## Quickstart & Installation
88
+
89
+ ### 1. Installation
90
+ Clone the repository and install in editable mode:
91
+
92
+ ```bash
93
+ git clone https://github.com/Zwony/RedAgent.git
94
+ cd RedAgent
95
+
96
+ # Create and activate virtual environment
97
+ python -m venv venv
98
+ # Windows:
99
+ .\venv\Scripts\activate
100
+ # Linux/macOS:
101
+ source venv/bin/activate
102
+
103
+ # Install dependencies and CLI tool
104
+ pip install -e .
105
+ ```
106
+
107
+ ### 2. Configure Environment (Optional)
108
+ To use cloud LLMs (OpenAI, Anthropic, Gemini) for the attack and evaluation agents, copy `.env.example`:
109
+
110
+ ```bash
111
+ cp .env.example .env
112
+ ```
113
+ And specify your API keys:
114
+ ```env
115
+ OPENAI_API_KEY=your_key_here
116
+ DEFAULT_ATTACKER_MODEL=gpt-4o
117
+ ```
118
+
119
+ ---
120
+
121
+ ## CLI Usage
122
+
123
+ ### 1. Scaffold a New Target Agent Profile
124
+ Generate a starter configuration file with customizable tools and RAG settings:
125
+ ```bash
126
+ redagent init --output target.json --name "CustomerServiceAgent"
127
+ ```
128
+
129
+ ### 2. Run Security Audit on an AI Agent Profile
130
+ Execute the stateful multi-agent DAG against your target and export an executive Markdown report:
131
+ ```bash
132
+ redagent scan --target target.json --output audit_report.md
133
+ ```
134
+ Or export as structured JSON:
135
+ ```bash
136
+ redagent scan --target target.json --output report.json
137
+ ```
138
+
139
+ ### 3. Run the Interactive Sandbox Demo
140
+ Experience the multi-agent refinement loop against a simulated banking assistant:
141
+ ```bash
142
+ redagent demo
143
+ ```
144
+
145
+ ---
146
+
147
+ ## Sample Audit Output
148
+
149
+ When an audit finishes, RedAgent renders a comprehensive executive summary and remediation table:
150
+
151
+ ```text
152
+ Security Audit Posture Summary
153
+ +-----------------------------------------------+
154
+ | Metric | Value |
155
+ |-------------------+---------------------------|
156
+ | Target Name | Acme Customer Service Bot |
157
+ | Overall Rating | CRITICAL_RISK |
158
+ | Max Risk Score | 9.1 / 10.0 |
159
+ | Total Test Cases | 6 |
160
+ | Findings Detected | 3 |
161
+ +-----------------------------------------------+
162
+
163
+ Vulnerability Findings & Evaluator Analysis
164
+ +-----------------------------------------------------------------------------+
165
+ | Finding ID | Category | Severity | Status | Remediation |
166
+ |--------------+----------------+----------+-----------------+----------------|
167
+ | fnd_fa89278c | LLM01: Prompt | HIGH | confirmed_vuln | Sanitize input |
168
+ | | Injection | | | delimiters |
169
+ | fnd_df05d8d0 | LLM08: | CRITICAL | confirmed_vuln | Enforce RBAC |
170
+ | | Excessive | | | & schema check |
171
+ | | Agency | | | on query tool |
172
+ | fnd_e8a2e77f | LLM08: | CRITICAL | confirmed_vuln | Require user |
173
+ | | Excessive | | | confirmation |
174
+ | | Agency | | | for wire trf |
175
+ | fnd_3d6dc2bd | LLM01: Prompt | INFO | robust_defense | Boundary kept |
176
+ | fnd_223a6591 | LLM06: Data | INFO | robust_defense | Prompt kept |
177
+ | fnd_951b5078 | LLM06: Data | INFO | robust_defense | KB protected |
178
+ +-----------------------------------------------------------------------------+
179
+
180
+ => Hardening & Guardrail Remediation Roadmap:
181
+ #1 [LLM08: Excessive Agency]: Enforce server-side RBAC and schema constraints on tool 'lookup_customer_order'.
182
+ #2 [LLM08: Excessive Agency]: Require explicit user confirmation token for sensitive function calls ('cancel_and_refund_order').
183
+ #3 [LLM01: Prompt Injection]: Sanitize input delimiters such as triple backticks or custom markup tags.
184
+ ```
185
+
186
+ ---
187
+
188
+ ## Python SDK & CI/CD Integration
189
+
190
+ Embed automated AI red teaming directly into test suites or CI/CD pipelines:
191
+
192
+ ```python
193
+ import asyncio
194
+ from redagent import RedTeamGraphEngine, TargetInfo, TargetToolDefinition
195
+
196
+ async def test_ai_agent_security():
197
+ # 1. Define Target System
198
+ target = TargetInfo(
199
+ target_id="support_bot_staging",
200
+ name="Customer Service Assistant",
201
+ endpoint_type="rest_api",
202
+ endpoint_url="https://staging.acme.internal/agent",
203
+ accessible_tools=[
204
+ TargetToolDefinition(
205
+ name="query_orders",
206
+ description="Queries customer orders by ID",
207
+ is_sensitive=True,
208
+ )
209
+ ],
210
+ has_rag=True,
211
+ rag_sources=["internal_kb"],
212
+ )
213
+
214
+ # 2. Run RedAgent Engine
215
+ engine = RedTeamGraphEngine()
216
+ final_state = await engine.run(target=target)
217
+
218
+ # 3. Assert Security Baseline in CI/CD
219
+ report = final_state.audit_report
220
+ assert report.overall_rating.value in ("SECURE", "LOW_RISK"), (
221
+ f"Security audit failed with posture: {report.overall_rating.value} (Risk: {report.overall_risk_score}/10)"
222
+ )
223
+
224
+ if __name__ == "__main__":
225
+ asyncio.run(test_ai_agent_security())
226
+ ```
227
+
228
+ ---
229
+
230
+ ## Running Regression Tests
231
+
232
+ Ensure platform integrity across all modules:
233
+ ```bash
234
+ pytest -v tests/
235
+ ```
236
+
237
+ ## Community & Contributing
238
+
239
+ We welcome contributions from security researchers, AI engineers, and open-source developers.
240
+
241
+ - **Contributing Guide:** Review [CONTRIBUTING.md](CONTRIBUTING.md) for local environment setup, coding standards, and agent creation guides.
242
+ - **Security Policy:** To report vulnerabilities in RedAgent itself, consult [SECURITY.md](SECURITY.md).
243
+ - **Code of Conduct:** We adhere to the Contributor Covenant. See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).
244
+ - **Release History:** See [CHANGELOG.md](CHANGELOG.md) for version notes and release highlights.
245
+
246
+ ---
247
+
248
+ ## License
249
+ This project is licensed under the **Apache License 2.0** - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,4 @@
1
+ """Configuration module for RedAgent."""
2
+ from config.settings import settings
3
+
4
+ __all__ = ["settings"]
@@ -0,0 +1,45 @@
1
+ """Global configuration and settings for RedAgent platform."""
2
+ from typing import Optional
3
+ from pydantic_settings import BaseSettings, SettingsConfigDict
4
+ from pydantic import Field
5
+
6
+
7
+ class Settings(BaseSettings):
8
+ """Platform environment settings."""
9
+ model_config = SettingsConfigDict(
10
+ env_file=".env",
11
+ env_file_encoding="utf-8",
12
+ extra="ignore"
13
+ )
14
+
15
+ # General App Config
16
+ APP_NAME: str = "RedAgent Security Platform"
17
+ APP_ENV: str = Field(default="development", description="Environment: development, test, production")
18
+ LOG_LEVEL: str = Field(default="INFO", description="Logging level")
19
+
20
+ # LLM Orchestrator & Attacker Model Configuration (LiteLLM format)
21
+ DEFAULT_ORCHESTRATOR_MODEL: str = Field(
22
+ default="gpt-4o",
23
+ description="Model used by Orchestrator and Evaluator agents"
24
+ )
25
+ DEFAULT_ATTACKER_MODEL: str = Field(
26
+ default="gpt-4o",
27
+ description="Model used by Red Team attack generation specialists"
28
+ )
29
+
30
+ # API Keys (Loaded from .env)
31
+ OPENAI_API_KEY: Optional[str] = None
32
+ ANTHROPIC_API_KEY: Optional[str] = None
33
+ GEMINI_API_KEY: Optional[str] = None
34
+
35
+ # Memory & Persistence
36
+ REDIS_URL: str = Field(default="redis://localhost:6379/0", description="Redis connection URL for state caching")
37
+ CHROMADB_PATH: str = Field(default="./data/chromadb", description="Persistent directory path for ChromaDB")
38
+
39
+ # Execution Safeguards
40
+ MAX_CONCURRENT_TESTS: int = Field(default=5, description="Maximum concurrent attack runs")
41
+ DEFAULT_TIMEOUT_SECONDS: float = Field(default=30.0, description="HTTP / Execution timeout per interaction")
42
+ MAX_ATTACK_ITERATIONS: int = Field(default=3, description="Maximum self-refinement iterations per test case")
43
+
44
+
45
+ settings = Settings()
@@ -0,0 +1,50 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "redagent"
7
+ version = "0.1.0"
8
+ description = "AI Agent Security & Automated Red Teaming Platform"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = { text = "Apache-2.0" }
12
+ authors = [
13
+ { name = "RedAgent Architecture Team" }
14
+ ]
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Topic :: Security",
19
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
20
+ ]
21
+ dependencies = [
22
+ "pydantic>=2.7.0",
23
+ "pydantic-settings>=2.2.0",
24
+ "langgraph>=0.2.0",
25
+ "langchain>=0.2.0",
26
+ "langchain-core>=0.2.0",
27
+ "litellm>=1.40.0",
28
+ "httpx>=0.27.0",
29
+ "redis>=5.0.0",
30
+ "chromadb>=0.5.0",
31
+ "rich>=13.7.0",
32
+ "python-dotenv>=1.0.1",
33
+ "structlog>=24.1.0"
34
+ ]
35
+
36
+ [project.optional-dependencies]
37
+ dev = [
38
+ "pytest>=8.2.0",
39
+ "pytest-asyncio>=0.23.0",
40
+ "black>=24.4.0",
41
+ "isort>=5.13.0",
42
+ "mypy>=1.10.0"
43
+ ]
44
+
45
+ [project.scripts]
46
+ redagent = "redagent.cli:main"
47
+
48
+ [tool.setuptools.packages.find]
49
+ where = ["."]
50
+ include = ["redagent*", "config*"]