Wireshark for AI Agents: an embedded runtime provenance, taint-tracking, and pre-execution security gate powered by a single-file Relate graph.
Live Interactive Explorer (Zero-Install Relate WASM): https://ahmed-za55.github.io/TaintGraph/ (runs real
@relate/relate-wasm@1.4.0in-browser for live arbitrary Cypher queries, plus Time-Travel Wireshark Playback, 1-Click 60s Judge Tour, 3 Forensic Scenarios, and the Interactive Red-Team Sandbox)
Flat text logs and plain vector databases miss Indirect Prompt Injection because no single event looks malicious in isolation:
- Lethal Trifecta: An agent reads an untrusted external GitHub issue (
UntrustedSource), accesses.env(SensitiveResource), and sends data to an external collector (ExternalSink). - Cross-Agent Contagion: A triage agent ingests poisoned content and delegates via
HANDED_OFF_TOto a coder agent that touches secrets or external sinks. - Covert File-Staged Exfiltration: Agent A reads
.envand writes/tmp/staging.txt(Artifact); Agent B reads/tmp/staging.txtand exfiltrates it—never touching.envdirectly. - Cross-Session Campaigns: Multiple independent agent sessions connect to the same malicious host or untrusted URI.
TaintGraph captures every goal, handoff, tool call, secret read, intermediate artifact, sink, and human approval as a connected property graph in Relate, blocking attacks before execution.
- Mode:
single file (.rl) - Why this mode: Each agent session or incident capture is a portable single-file
.rlbundle (BundleVfs, like.pcapfor AI agents) that requires zero external database servers, commits cleanly to Git, supports atomic multi-agent transactions (autocommit = False+commit()/rollback()), runs native in-process cosineVECTOR INDEX(SEARCH ... IN (VECTOR INDEX ...), noting Relate's(1 + cos) / 2score normalization), supportsread_only=Trueforensic auditing, and exports to idempotent.cypherscripts for Neo4j Aura / Neo4j Desktop ("Build locally, connect when needed"). - What the graph models:
- 10 Node Labels:
UserGoal,Agent,UntrustedSource,SensitiveResource,ToolCall,Artifact,ExternalSink,HumanApproval,Session,ForensicSeal - 9 Relationships:
INITIATED,INFLUENCED_BY,HANDED_OFF_TO,CALLS,READS,WRITES,SENDS_TO,APPROVED,CONTAINS
- 10 Node Labels:
flowchart LR
SESS["Session"] -->|CONTAINS| A1["Agent (triage)"]
G["UserGoal"] -->|INITIATED| A1
A1 -->|INFLUENCED_BY| U["UntrustedSource"]
A1 -->|HANDED_OFF_TO| A2["Agent (coder)"]
A2 -->|CALLS| T1["ToolCall (read_file)"]
T1 -->|READS| SEC["SensitiveResource (.env)"]
A2 -->|CALLS| T2["ToolCall (write_file)"]
T2 -->|WRITES| ART["Artifact (/tmp/staging.txt)"]
A2 -->|CALLS| T3["ToolCall (http_post) [BLOCKED]"]
T3 -->|SENDS_TO| E["ExternalSink"]
H["HumanApproval"] -->|APPROVED| T4["ToolCall (git_push) [ALLOWED]"]
| Rule ID | Severity | MITRE ATLAS | OWASP LLM | Mechanism | What It Catches |
|---|---|---|---|---|---|
LETHAL_TRIFECTA |
CRITICAL |
AML.T0051 / AML.T0024 |
LLM01 / LLM02 |
Multi-hop Cypher | UntrustedSource + SensitiveResource + ExternalSink with temporal ordering |
CROSS_AGENT_CONTAGION |
CRITICAL |
AML.T0051 |
LLM01 / LLM06 |
Variable-length Cypher (*1..4) |
Taint propagating across HANDED_OFF_TO chains |
COVERT_FILE_EXFILTRATION |
CRITICAL |
AML.T0024 |
LLM02 |
Multi-hop Cypher (WRITES -> Artifact -> READS) |
Secret staged to an intermediate file and exfiltrated downstream |
CROSS_SESSION_CAMPAIGN |
CRITICAL |
AML.T0024 |
LLM02 |
Fleet Cypher (Session -> CONTAINS) |
2+ independent sessions sharing the same ExternalSink or UntrustedSource |
OBFUSCATED_PAYLOAD_SMUGGLING |
CRITICAL |
AML.T0051 |
LLM01 |
De-obfuscator + Cypher | Base64, zero-width \u200B, bidi Trojan \u202E, or homoglyph smuggling |
SEMANTIC_GOAL_DRIFT |
HIGH |
AML.T0051 |
LLM01 |
Hybrid VECTOR INDEX + Graph |
Tainted ToolCall.embedding drifting below threshold from UserGoal.embedding |
UNAPPROVED_PRIVILEGED_ACTION |
HIGH |
AML.T0054 |
LLM06 |
Graph OPTIONAL MATCH |
shell_exec / git_push / send_email / delete_file without HumanApproval |
AGENT_HANDOFF_CYCLE |
HIGH |
AML.T0029 |
LLM10 |
Graph Cycle (*1..5) |
Runaway HANDED_OFF_TO delegation loops |
| Custom YAML Cypher | Configurable | Custom | Custom | Policy-as-Code (examples/custom_policy.yaml) |
Domain-specific read-only Cypher rules + strict domain-boundary sink allowlists |
| Benchmark | Result | Details |
|---|---|---|
16-Scenario Benchmark (taintgraph bench) |
100% Precision / 100% Recall / F1 = 1.00 | TP=8, FP=0, TN=8, FN=0 · Median latency 34.02 ms, P95 154.48 ms |
500-Event Scale Stress Test (taintgraph stress --events 500 --agents 5) |
2,582.4 events/sec · 37.35 ms audit | 521 nodes, 522 edges · 1,208.00 KB .rl (2,473.98 B/event) · 2/2 needles caught, 0 FP |
Test Suite (pytest -v) |
55 / 55 Passed | Includes 15-test Adversarial Self-Hardening Suite (Cypher injection/DoS guard, domain-boundary allowlist, HTTP path-traversal & body-size guards, empty-store resilience), Merkle seal tamper detection, Blast Radius, SARIF/HTML |
git clone https://github.com/Ahmed-za55/TaintGraph.git
cd TaintGraph
python -m venv .venv
# Windows PowerShell: .\.venv\Scripts\Activate.ps1
# macOS / Linux: source .venv/bin/activate
pip install -e ".[dev]"| Command | Purpose |
|---|---|
taintgraph demo --out data/demo_incident.rl |
Generate the multi-agent indirect prompt-injection .rl capture |
taintgraph inspect data/demo_incident.rl [--policy examples/custom_policy.yaml] |
Print graph stats and all rule findings (read_only=True) |
taintgraph query data/demo_incident.rl "<cypher>" |
Run a read-only Cypher query against a .rl store |
taintgraph serve data/demo_incident.rl --port 8765 [--watch] |
Launch the live Forensic Explorer + Red-Team Sandbox UI (--watch streams live .rl updates via SSE) |
taintgraph blast-radius data/demo_incident.rl <node_id> |
Compute downstream blast radius, weighted score, and earliest containment cut |
taintgraph ingest data/sample_trace.jsonl --out data/covert_exfil.rl |
Ingest a JSONL agent trace into a persistent .rl store |
taintgraph diff <base.rl> <target.rl> [--fail-on-regression] |
Compare two .rl stores for graph & security regressions |
taintgraph merge data/demo_incident.rl data/covert_exfil.rl --out data/fleet_forensics.rl |
Merge multiple .rl sessions and detect cross-session campaigns |
taintgraph export-cypher data/demo_incident.rl --out out.cypher |
Export an idempotent Neo4j Aura / Desktop .cypher script |
taintgraph export-json data/demo_incident.rl --out web/demo_graph.json |
Export graph & findings JSON for the static web explorer |
taintgraph report data/demo_incident.rl --format sarif --out taintgraph.sarif |
Generate SARIF 2.1.0, Markdown (--format md), or Executive HTML (--format html) report |
taintgraph seal data/demo_incident.rl |
Compute and embed an RFC 6962 SHA-256 Merkle Forensic Seal inside .rl |
taintgraph verify data/demo_incident.rl [--json] |
Verify .rl integrity against its embedded RFC 6962 Merkle Seal (read_only=True) |
taintgraph bench |
Run the 16-scenario Precision / Recall / F1 benchmark |
taintgraph stress --events 500 --agents 5 |
Run the 500-event Needle-in-a-Haystack scale stress test |
- uses: Ahmed-za55/TaintGraph@main
with:
trace-or-db: data/sample_trace.jsonl
sarif-output: taintgraph.sarif
fail-on-findings: "true"{
"mcpServers": {
"taintgraph": {
"command": "taintgraph-mcp",
"args": ["--db", "data/session.rl"],
"env": { "TAINTGRAPH_DB": "data/session.rl" }
}
}
}- examples/openai_agent_guard.py — Drop-in
TaintSession+@session.guardpre-execution blocking. - examples/langchain_callback.py —
TaintGraphCallbackHandler(on_chain_start,on_tool_start,on_tool_end). - examples/custom_policy.yaml — Declarative YAML Policy-as-Code with allowlisted sinks and custom Cypher rules.
- examples/live_ollama_agent.py — Local Ollama (
llama3.2) +--simulatelive agent streaming intotaintgraph serve --watch.
- data/demo_incident.rl — Incident 1: Multi-Agent Prompt Injection (
13nodes,12edges,7findings). - data/covert_exfil.rl — Incident 2: Covert File-Staged Exfiltration ingested from data/sample_trace.jsonl (
13nodes,13edges,8findings). - data/fleet_forensics.rl — Incident 3: Merged Fleet Forensics across both incidents (
26nodes,45edges,16findings includingCROSS_SESSION_CAMPAIGN). - web/demo_graph.json, web/covert_graph.json, web/fleet_graph.json — Static JSON snapshots powering the GitHub Pages explorer in web/index.html.