RedAgent
Autonomous AI Agent Red Teaming & Security Auditing Platform
Stateful Multi-Agent Vulnerability Assessment Engine for Enterprise LLM Systems
Features • Architecture • Quickstart • CLI Usage • SDK Usage • Legal Notice
Why RedAgent?
Traditional Dynamic Application Security Testing (DAST) and API scanners are fundamentally incapable of discovering non-deterministic LLM vulnerabilities:
- They do not understand conversational state, prompt boundaries, or instruction delimiters.
- They conclude execution after a single HTTP 200 or standard polite refusal ("I am sorry, but...").
- They cannot evaluate autonomous function calling (
Excessive Agency) or vector memory leakage (RAG Data Exfiltration).
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.
Key Features
- 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).
- 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.
- Interactive Web Dashboard: Launch visual security audits with live agent inspection streams using
redagent ui. - Zero-Server In-Memory Testing: Test local Python functions, coroutines, and LangChain agents directly via
CallableTargetConnector. - Air-Gapped HTML Executive Reporting: Export single-file, interactive HTML audit reports with vulnerability proofs and remediation roadmaps.
- ChromaDB Vector Knowledge Store: Persistently indexes adversarial seeds, boundary test templates, and OWASP evaluation rubrics (with zero-dependency in-memory fallback).
- Pluggable Target Connectors: Test local mock agents, in-memory callables, or live enterprise agents over REST API endpoints.
- Automatic Release Updater: Built-in non-blocking update checking and interactive upgrade prompt (
redagent update).
System Architecture
RedAgent operates as a stateful Directed Acyclic Graph (DAG) built on LangGraph, Pydantic v2, and LiteLLM:
graph TD
A[Target AI Agent Profile] --> B[Orchestrator Agent]
B --> C{Adversarial Specialists}
C -->|OWASP LLM01| D[Prompt Injection Specialist]
C -->|OWASP LLM07/LLM08| E[Tool Abuse & Authorization Agent]
C -->|OWASP LLM06| F[Data Exfiltration Agent]
subgraph Persistent Refinement Loop
D <-->|Multi-turn Mutation & Backtracking| IE[Dynamic Test Iteration Engine]
E <-->|Adaptive Strategy Shift| IE
F <-->|Vector Seed Retrieval| IE
IE <--> VS[(Security Vector Store: ChromaDB)]
IE <--> TC[Target Connectors: Mock / REST]
end
D --> G[Evaluator & Reporting Agent]
E --> G
F --> G
G --> H[Final Audit Report & Remediation Roadmap]
Specialized Multi-Agent Roles
| Agent Role | Domain Specialty | OWASP Focus | Core Objective |
|---|---|---|---|
| Orchestrator Agent | Threat Modeler & Planner | System-wide | Profiles target tools, RAG connections, and generates structured test matrices. |
| Prompt Injection Specialist | Boundary & Delimiter Attacks | LLM01 | Tests instruction delimiters, goal hijacking, and system override resistance. |
| Tool Abuse Agent | RBAC & Excessive Agency | LLM07, LLM08 | Tests unconstrained function calling, parameter tampering, and privilege escalation. |
| Data Exfiltration Agent | Confidentiality & Memory | LLM06 | Evaluates system prompt leaks, canary tokens, and RAG metadata disclosure. |
| Evaluator & Reporter | Semantic Analysis & Risk | Comprehensive | Computes risk scores (0-10) and formulates concrete developer remediation rules. |
Quickstart & Installation
1. Installation
Clone the repository and install in editable mode:
git clone https://github.com/Zwony/RedAgent.git
cd RedAgent
# Create and activate virtual environment
python -m venv venv
# Windows:
.\venv\Scripts\activate
# Linux/macOS:
source venv/bin/activate
# Install dependencies and CLI tool
pip install -e .
2. Configure Environment (Optional)
To use cloud LLMs (OpenAI, Anthropic, Gemini) for the attack and evaluation agents, copy .env.example:
cp .env.example .env
And specify your API keys:
OPENAI_API_KEY=your_key_here
DEFAULT_ATTACKER_MODEL=gpt-4o
CLI Usage
1. Scaffold a New Target Agent Profile
Generate a starter configuration file with customizable tools and RAG settings:
redagent init --output target.json --name "CustomerServiceAgent"
2. Run Security Audit on an AI Agent Profile
Execute the stateful multi-agent DAG against your target and export an executive HTML or Markdown report:
# Standalone Interactive HTML Report (offline & air-gapped)
redagent scan --target target.json --output audit_report.html
# Executive Markdown Report
redagent scan --target target.json --output audit_report.md
# Structured JSON
redagent scan --target target.json --output report.json
3. Launch the Interactive Web Dashboard
Visualize real-time agent attacks, inspect target refusal analyses, and download reports:
redagent ui
4. Check for Platform Updates
Verify upstream releases on PyPI / GitHub and interactively upgrade:
redagent update
5. Run the Interactive Sandbox Demo
Experience the multi-agent refinement loop against a simulated banking assistant:
redagent demo
Sample Audit Output
When an audit finishes, RedAgent renders a comprehensive executive summary and remediation table:
Security Audit Posture Summary
+-----------------------------------------------+
| Metric | Value |
|-------------------+---------------------------|
| Target Name | Acme Customer Service Bot |
| Overall Rating | CRITICAL_RISK |
| Max Risk Score | 9.1 / 10.0 |
| Total Test Cases | 6 |
| Findings Detected | 3 |
+-----------------------------------------------+
Vulnerability Findings & Evaluator Analysis
+-----------------------------------------------------------------------------+
| Finding ID | Category | Severity | Status | Remediation |
|--------------+----------------+----------+-----------------+----------------|
| fnd_fa89278c | LLM01: Prompt | HIGH | confirmed_vuln | Sanitize input |
| | Injection | | | delimiters |
| fnd_df05d8d0 | LLM08: | CRITICAL | confirmed_vuln | Enforce RBAC |
| | Excessive | | | & schema check |
| | Agency | | | on query tool |
| fnd_e8a2e77f | LLM08: | CRITICAL | confirmed_vuln | Require user |
| | Excessive | | | confirmation |
| | Agency | | | for wire trf |
| fnd_3d6dc2bd | LLM01: Prompt | INFO | robust_defense | Boundary kept |
| fnd_223a6591 | LLM06: Data | INFO | robust_defense | Prompt kept |
| fnd_951b5078 | LLM06: Data | INFO | robust_defense | KB protected |
+-----------------------------------------------------------------------------+
=> Hardening & Guardrail Remediation Roadmap:
#1 [LLM08: Excessive Agency]: Enforce server-side RBAC and schema constraints on tool 'lookup_customer_order'.
#2 [LLM08: Excessive Agency]: Require explicit user confirmation token for sensitive function calls ('cancel_and_refund_order').
#3 [LLM01: Prompt Injection]: Sanitize input delimiters such as triple backticks or custom markup tags.
Python SDK & CI/CD Integration
Embed automated AI red teaming directly into test suites or CI/CD pipelines:
import asyncio
from redagent import RedTeamGraphEngine, TargetInfo, TargetToolDefinition
async def test_ai_agent_security():
# 1. Define Target System
target = TargetInfo(
target_id="support_bot_staging",
name="Customer Service Assistant",
endpoint_type="rest_api",
endpoint_url="https://staging.acme.internal/agent",
accessible_tools=[
TargetToolDefinition(
name="query_orders",
description="Queries customer orders by ID",
is_sensitive=True,
)
],
has_rag=True,
rag_sources=["internal_kb"],
)
# 2. Run RedAgent Engine
engine = RedTeamGraphEngine()
final_state = await engine.run(target=target)
# 3. Assert Security Baseline in CI/CD
report = final_state.audit_report
assert report.overall_rating.value in ("SECURE", "LOW_RISK"), (
f"Security audit failed with posture: {report.overall_rating.value} (Risk: {report.overall_risk_score}/10)"
)
### In-Memory Python / LangChain Bot Auditing
Audit any local Python function or LangChain Runnable with zero HTTP server configuration:
```python
import asyncio
from redagent import RedTeamGraphEngine, TargetInfo, EndpointType
from redagent.connectors import CallableTargetConnector
# In-memory target bot (or LangChain AgentExecutor)
def my_local_agent(prompt: str) -> str:
return "I am an enterprise assistant. Instruction overrides are forbidden."
async def test_in_memory():
target = TargetInfo(target_id="local_bot", name="Local Assistant", endpoint_type=EndpointType.CALLABLE)
engine = RedTeamGraphEngine(target_connector=CallableTargetConnector(my_local_agent))
state = await engine.run(target=target)
print(f"Risk Score: {state.audit_report.overall_risk_score}/10")
if __name__ == "__main__":
asyncio.run(test_in_memory())
if name == "main": asyncio.run(test_ai_agent_security())
---
## Running Regression Tests
Ensure platform integrity across all modules:
```bash
pytest -v tests/
Community & Contributing
We welcome contributions from security researchers, AI engineers, and open-source developers.
- Contributing Guide: Review CONTRIBUTING.md for local environment setup, coding standards, and agent creation guides.
- Security Policy: To report vulnerabilities in RedAgent itself, consult SECURITY.md.
- Code of Conduct: We adhere to the Contributor Covenant. See CODE_OF_CONDUCT.md.
- Release History: See CHANGELOG.md for version notes and release highlights.
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Metadata
Release files for redagent 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| redagent-0.2.0.tar.gz | 63.2 kB | Without provenance | Details for redagent-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| redagent-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for redagent-0.2.0-py3-none-any.whl |
Total release size: 133.2 kB
Release files / redagent-0.2.0.tar.gz
| Download URL | redagent-0.2.0.tar.gz |
|---|---|
| Size | 63.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
251ead075828e54f9460922af92f0b19a4e3137632f321a13747be9227fc3502
|
|
BLAKE2b-256 checksum How to use checksums |
fd850756be9aea20d33347866ec8f54e27c7c0d2a718813d2c079644f64292d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.1
|
Release files / redagent-0.2.0-py3-none-any.whl
| Download URL | redagent-0.2.0-py3-none-any.whl |
|---|---|
| Size | 70.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
034adbc973e24838140be6b874cbef79abedc869feb333a801f6d0a8e1951480
|
|
BLAKE2b-256 checksum How to use checksums |
1d746305d7691ed0e2d835c76356538431f0404c39119a1defdee931f44d0a77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.1
|
Security for redagent 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.