Skip to main content

RedAgent

Autonomous AI Agent Red Teaming & Security Auditing Platform

Stateful Multi-Agent Vulnerability Assessment Engine for Enterprise LLM Systems

License: Apache-2.0 Python: 3.11+ Framework: LangGraph Tests: Passing Security: OWASP LLM Top 10

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.
  • 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, staging bots, or live enterprise agents over REST API endpoints (RestTargetConnector).
  • Actionable Remediation Roadmap: Automatically generates concrete developer fixes, including regex guardrail patterns, system prompt hardening snippets, and RBAC constraints.
  • Dual Mode (CLI + SDK): Run as a standalone terminal security scanner or embed into Python CI/CD pipelines.

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 Markdown report:

redagent scan --target target.json --output audit_report.md

Or export as structured JSON:

redagent scan --target target.json --output report.json

3. 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)"
    )

if __name__ == "__main__":
    asyncio.run(test_ai_agent_security())

Running Regression Tests

Ensure platform integrity across all modules:

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.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for redagent 0.1.0
File Size Uploaded Provenance Actions
redagent-0.1.0.tar.gz 45.7 kB Without provenance Details for redagent-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for redagent 0.1.0
File Interpreter ABI Platform Actions
redagent-0.1.0-py3-none-any.whl Python 3 none any Details for redagent-0.1.0-py3-none-any.whl

Total release size: 98.2 kB

Release files / redagent-0.1.0.tar.gz

Download URL redagent-0.1.0.tar.gz
Size 45.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2070d665f5df54ee518539d17f19c4a9a6ab3cd2230d6703b0d92718dcc6721d
BLAKE2b-256 checksum
How to use checksums
03dd12fefca46a8c9f29854e85e45748b7692b299c5aee956ef310dbb7b367c6
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.1.0-py3-none-any.whl

Download URL redagent-0.1.0-py3-none-any.whl
Size 52.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
05272f66b71022b5fb47b817435830f9fe7eafc8ff1dd48619c9c738fb002572
BLAKE2b-256 checksum
How to use checksums
bb67d95fcb26ed48c9951376b046282c0f45a72f25fe7ea43c5e7c22fb578d7c
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.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page