AI Agent Security Testing Framework โ multi-phase scan campaigns with knowledge graph tracking
Project description
ZIRAN ๐ง
AI Agent Security Testing
Find vulnerabilities in AI agents โ not just LLMs, but agents with tools, memory, and multi-step reasoning.
Install ยท Quick Start ยท Examples ยท Docs
Why ZIRAN?
Most security tools test the LLM (prompt injection, jailbreaks) or the web app (XSS, SQLi). ZIRAN tests the AI agent โ the system that wields tools, retains memory, and chains reasoning. That's a fundamentally different attack surface.
| Capability | ZIRAN | Garak | Promptfoo | PyRIT | Shannon |
|---|---|---|---|---|---|
| Agent-aware (tools + memory) | Yes | โ | Partial | โ | โ |
| Tool chain analysis | Yes | โ | โ | โ | โ |
| Multi-phase campaigns | Yes | โ | โ | Partial | Yes |
| Multi-agent coordination | Yes | โ | โ | โ | โ |
| Adaptive campaigns | Yes | โ | โ | โ | โ |
| Autonomous pentesting agent | Yes | โ | โ | โ | โ |
| Streaming (SSE/WebSocket) | Yes | โ | โ | โ | โ |
| Knowledge graph tracking | Yes | โ | โ | โ | โ |
| Remote agent scanning (HTTPS) | Yes | REST only | HTTP provider | Partial | โ |
| Multi-protocol (REST/OpenAI/MCP/A2A) | Yes | โ | โ | โ | โ |
| A2A protocol support | Yes | โ | โ | โ | โ |
| Protocol auto-detection | Yes | โ | โ | โ | โ |
| CI/CD quality gate | Yes | โ | Yes | โ | Pro |
| Open source | Apache-2.0 | Apache-2.0 | MIT | MIT | AGPL-3.0 |
Key differentiators:
- Tool Chain Analysis โ Detects dangerous tool combinations (
read_fileโhttp_request= data exfiltration). No other tool does this. - Multi-Phase Trust Exploitation โ Progressive campaigns that build trust before testing boundaries, like a real attacker.
- Multi-Agent Coordination โ Discover topologies (supervisor, router, peer-to-peer) and test cross-agent trust boundaries and delegation patterns.
- Adaptive Campaigns โ Three execution strategies โ fixed, rule-based adaptive, and LLM-driven โ that adjust attack plans in real-time based on knowledge graph state.
- Streaming Support โ Real-time attack monitoring via SSE and WebSocket protocols for long-running agent responses.
- Knowledge Graph โ Every discovered capability, relationship, and attack path is tracked in a live graph.
- Remote Agent Scanning โ Test any published agent over HTTPS with YAML-driven target configuration. Supports REST, OpenAI-compatible, MCP, and A2A protocols with automatic detection.
- A2A Protocol Support โ First security tool to test Agent-to-Agent agents, including Agent Card discovery, task lifecycle attacks, and multi-turn manipulation.
- Autonomous Pentesting Agent โ An LLM-driven agent that plans, executes, and adapts attack campaigns autonomously, with finding deduplication and interactive red-team mode.
- Framework Agnostic โ LangChain, CrewAI, MCP, remote HTTPS agents, or write your own adapter.
Install
pip install ziran
# with framework adapters
pip install ziran[langchain] # LangChain support
pip install ziran[crewai] # CrewAI support
pip install ziran[a2a] # A2A protocol support
pip install ziran[streaming] # SSE/WebSocket streaming
pip install ziran[pentest] # autonomous pentesting agent
pip install ziran[all] # everything
Quick Start
CLI
# scan a LangChain agent (in-process)
ziran scan --framework langchain --agent-path my_agent.py
# scan a remote agent over HTTPS
ziran scan --target target.yaml
# adaptive campaign with LLM-driven strategy
ziran scan --target target.yaml --strategy llm-adaptive
# stream responses in real-time
ziran scan --target target.yaml --streaming
# scan a multi-agent system
ziran multi-agent-scan --target target.yaml
# discover capabilities of a remote agent
ziran discover --target target.yaml
# autonomous pentesting agent
ziran pentest --target target.yaml
# interactive red-team mode
ziran pentest --target target.yaml --interactive
# view the interactive HTML report
open reports/campaign_*_report.html
Python API
import asyncio
from ziran.application.agent_scanner.scanner import AgentScanner
from ziran.application.attacks.library import AttackLibrary
from ziran.infrastructure.adapters.langchain_adapter import LangChainAdapter
adapter = LangChainAdapter(agent=your_agent)
scanner = AgentScanner(adapter=adapter, attack_library=AttackLibrary())
result = asyncio.run(scanner.run_campaign())
print(f"Vulnerabilities found: {result.total_vulnerabilities}")
print(f"Dangerous tool chains: {len(result.dangerous_tool_chains)}")
See examples/ for 19 runnable demos โ from static analysis to autonomous pentesting.
Remote Agent Scanning
ZIRAN can test any published agent over HTTPS โ no source code or in-process access required. Define your target in a YAML file and ZIRAN handles the rest:
# target.yaml
name: my-agent
url: https://agent.example.com
protocol: auto # auto | rest | openai | mcp | a2a
auth:
type: bearer
token_env: AGENT_API_KEY
tls:
verify: true
Supported protocols:
| Protocol | Use Case | Auto-detected via |
|---|---|---|
| REST | Generic HTTP endpoints | Fallback default |
| OpenAI-compatible | Chat completions API (/v1/chat/completions) |
Path probing |
| MCP | Model Context Protocol agents (JSON-RPC 2.0) | JSON-RPC response |
| A2A | Google Agent-to-Agent protocol | /.well-known/agent.json |
# auto-detect protocol and scan
ziran scan --target target.yaml
# force a specific protocol
ziran scan --target target.yaml --protocol openai
# A2A agent with Agent Card discovery
ziran scan --target a2a_target.yaml --protocol a2a
See examples/15-remote-agent-scan/ for ready-to-use target configurations.
What ZIRAN Finds
Prompt-level โ injection, system prompt extraction, memory poisoning, chain-of-thought manipulation.
Tool-level โ tool manipulation, privilege escalation, data exfiltration chains.
Tool chains (unique to ZIRAN) โ automatic graph analysis of dangerous tool compositions:
โโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Risk โ Type โ Tools โ Description โ
โโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ critical โ data_exfiltration โ read_file โ http_request โ File contents sent to external serverโ
โ critical โ sql_to_rce โ sql_query โ execute_code โ SQL results executed as code โ
โ high โ pii_leakage โ get_user_info โ external_apiโ User PII sent to third-party API โ
โโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
How It Works
flowchart LR
subgraph agent["๐ค Your Agent"]
direction TB
T["๐ง Tools"]
M["๐ง Memory"]
P["๐ Permissions"]
end
agent -->|"adapter layer"| D
subgraph ziran["โฉ๏ธ ZIRAN Pipeline"]
direction TB
D["1 ยท DISCOVER\nProbe tools, permissions,\ndata access"]
MAP["2 ยท MAP\nBuild knowledge graph\n(NetworkX MultiDiGraph)"]
A["3 ยท ANALYZE\nWalk graph for dangerous\nchains (30+ patterns)"]
ATK["4 ยท ATTACK\nMulti-phase exploits\ninformed by the graph"]
R["5 ยท REPORT\nScored findings with\nremediation guidance"]
D --> MAP --> A --> ATK --> R
end
R --> HTML["๐ HTML\nInteractive graph"]
R --> MD["๐ Markdown\nCI/CD tables"]
R --> JSON["๐ฆ JSON\nMachine-parseable"]
style agent fill:#1a1a2e,stroke:#e94560,color:#fff,stroke-width:2px
style ziran fill:#0f3460,stroke:#e94560,color:#fff,stroke-width:2px
style D fill:#16213e,stroke:#0ea5e9,color:#fff
style MAP fill:#16213e,stroke:#0ea5e9,color:#fff
style A fill:#16213e,stroke:#0ea5e9,color:#fff
style ATK fill:#16213e,stroke:#e94560,color:#fff
style R fill:#16213e,stroke:#10b981,color:#fff
style HTML fill:#1e293b,stroke:#10b981,color:#fff
style MD fill:#1e293b,stroke:#10b981,color:#fff
style JSON fill:#1e293b,stroke:#10b981,color:#fff
style T fill:#2d2d44,stroke:#e94560,color:#fff
style M fill:#2d2d44,stroke:#e94560,color:#fff
style P fill:#2d2d44,stroke:#e94560,color:#fff
Multi-Phase Trust Exploitation
| Phase | Goal |
|---|---|
| Reconnaissance | Discover capabilities and data sources |
| Trust Building | Establish rapport with the agent |
| Capability Mapping | Map tools, permissions, data access |
| Vulnerability Discovery | Identify attack paths |
| Exploitation Setup | Position without triggering defences |
| Execution | Execute the exploit chain |
| Persistence | Maintain access across sessions (opt-in) |
| Exfiltration | Extract sensitive data (opt-in) |
Each phase builds on the knowledge graph from previous phases.
Campaign Strategies
| Strategy | Description |
|---|---|
fixed |
Sequential phases in order (default) |
adaptive |
Rule-based adaptation โ skips, repeats, or re-orders phases based on knowledge graph state |
llm-adaptive |
LLM-driven strategy โ uses an LLM to analyze findings and plan the next phase dynamically |
ziran scan --target target.yaml --strategy adaptive
ziran scan --target target.yaml --strategy llm-adaptive
Autonomous Pentesting Agent
An LLM-powered agent that autonomously plans, executes, and adapts penetration testing campaigns:
# fully autonomous mode
ziran pentest --target target.yaml --max-iterations 5
# interactive red-team mode โ collaborate with the agent
ziran pentest --target target.yaml --interactive
The pentesting agent:
- Plans attack strategies using LLM reasoning and knowledge graph state
- Executes multi-step exploit chains with real-time adaptation
- Deduplicates findings using LLM embeddings to cluster related vulnerabilities
- Reports with detailed HTML reports including OWASP LLM Top 10 mapping
See examples/19-pentesting-agent/ for a complete walkthrough.
Multi-Agent Scanning
Test coordinated multi-agent systems โ supervisors, routers, peer-to-peer networks:
ziran multi-agent-scan --target target.yaml
ZIRAN discovers the agent topology, scans each agent individually, then runs cross-agent attacks targeting trust boundaries and delegation patterns.
Streaming
Monitor attack responses in real-time via SSE or WebSocket:
ziran scan --target target.yaml --streaming
Reports
Three output formats, generated automatically:
- HTML โ Interactive knowledge graph with attack path highlighting
- Markdown โ CI/CD-friendly summary tables
- JSON โ Machine-parseable for programmatic consumption
CI/CD Integration
Use ZIRAN as a quality gate in your pipeline:
Live scan (runs the full attack suite against your agent)
# .github/workflows/security.yml
- uses: taoq-ai/ziran@v0
with:
command: scan
framework: langchain # langchain | crewai | bedrock
agent-path: my_agent.py # OR use target: target.yaml for remote agents
coverage: standard # essential | standard | comprehensive
gate-config: gate_config.yaml
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} # or ANTHROPIC_API_KEY, etc.
Offline CI gate (evaluate a previous scan result)
- uses: taoq-ai/ziran@v0
with:
command: ci
result-file: scan_results/campaign_report.json
gate-config: gate_config.yaml
Outputs: status (passed/failed), trust-score, total-findings, critical-findings, sarif-file.
See the full example workflow or use the Python API.
Development
git clone https://github.com/taoq-ai/ziran.git && cd ziran
uv sync --group dev
uv run ruff check . # lint
uv run mypy ziran/ # type-check
uv run pytest --cov=ziran # test
Contributing
See CONTRIBUTING.md. Ways to help:
- Report bugs
- Request features
- Submit Skill CVEs for tool vulnerabilities
- Add attack vectors (YAML) or adapters
License
Apache License 2.0 โ See NOTICE for third-party attributions.
Built by TaoQ AI
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ziran-0.6.1.tar.gz.
File metadata
- Download URL: ziran-0.6.1.tar.gz
- Upload date:
- Size: 2.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b94c5a3c3084524bdf67389acaf6c2347047a3868359f9c780b39784d24d340
|
|
| MD5 |
8e5286cd4033024cb40ea72e160ce763
|
|
| BLAKE2b-256 |
a8db84245a398f33385ef0cc4b46b6c156f29ae486e42fcebc629c6a1dcdf94d
|
Provenance
The following attestation bundles were made for ziran-0.6.1.tar.gz:
Publisher:
release.yml on taoq-ai/ziran
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ziran-0.6.1.tar.gz -
Subject digest:
6b94c5a3c3084524bdf67389acaf6c2347047a3868359f9c780b39784d24d340 - Sigstore transparency entry: 1056950531
- Sigstore integration time:
-
Permalink:
taoq-ai/ziran@4d98a0cefdb0b1b77ead3c52318d9e9d0f8a6988 -
Branch / Tag:
refs/tags/v0.6.1 - Owner: https://github.com/taoq-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4d98a0cefdb0b1b77ead3c52318d9e9d0f8a6988 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ziran-0.6.1-py3-none-any.whl.
File metadata
- Download URL: ziran-0.6.1-py3-none-any.whl
- Upload date:
- Size: 295.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
490ea51b1041144f1eb3e5f9c44809cf9cfe5230dca3972f17ebf77ade2539a1
|
|
| MD5 |
60e3a8d4617c2a9b42a6c1378d6d3a1f
|
|
| BLAKE2b-256 |
06f5c940c7ee3e1debe43af9031cb68881d8a014965bbb84aa5be9ad57ff7bcf
|
Provenance
The following attestation bundles were made for ziran-0.6.1-py3-none-any.whl:
Publisher:
release.yml on taoq-ai/ziran
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ziran-0.6.1-py3-none-any.whl -
Subject digest:
490ea51b1041144f1eb3e5f9c44809cf9cfe5230dca3972f17ebf77ade2539a1 - Sigstore transparency entry: 1056950532
- Sigstore integration time:
-
Permalink:
taoq-ai/ziran@4d98a0cefdb0b1b77ead3c52318d9e9d0f8a6988 -
Branch / Tag:
refs/tags/v0.6.1 - Owner: https://github.com/taoq-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4d98a0cefdb0b1b77ead3c52318d9e9d0f8a6988 -
Trigger Event:
push
-
Statement type: