# saksham6349/prompt-injection-benchmark architecture

> Architecture diagram of the GitHub repository saksham6349/prompt-injection-benchmark, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saksham6349/prompt-injection-benchmark
- Repository: https://github.com/saksham6349/prompt-injection-benchmark

## Overview

This repository benchmarks indirect prompt injection against tool-using LLM agents and provides a three-layer defense. The principal flow is a user task through the agent/provider loop, sandbox tool execution, policy checks before actions, and provenance/classifier processing of retrieved output before it returns to the model. Evaluation, attack taxonomy, and baseline defenses are separate product capabilities. Some subsystem relationships are documented in the README; unsampled modules are included only where the README or source index supports them.

Main entry points: [`src/sandbox/executor.py`](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/sandbox/executor.py) (Tool Executor), [`src/agent/harness.py`](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/agent/harness.py) (Agent Harness), [`src/sandbox/state.py`](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/sandbox/state.py) (SQLite Sandbox State), [`src/evaluation/runner.py`](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/evaluation/runner.py) (Evaluation Runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_agent["Agent Runtime"]
  node_harness["Agent Harness<br/>[harness.py]"]
  node_prompts["Prompt Builder<br/>[prompts.py]"]
  node_providers["LLM Providers"]
  node_cache[("Response Cache<br/>[cache.py]")]
end

subgraph group_defense["Defense Pipeline"]
  node_pipeline["Defense Orchestrator<br/>[pipeline.py]"]
  node_provenance["Provenance Tagger<br/>[provenance.py]"]
  node_classifier["Injection Classifier<br/>[classifier.py]"]
  node_policy["Tool Policy<br/>[policy.py]"]
end

subgraph group_sandbox["Mock Sandbox"]
  node_executor["Tool Executor<br/>[executor.py]"]
  node_state[("SQLite Sandbox State<br/>[state.py]")]
  node_email["Email Tools<br/>[email.py]"]
  node_calendar["Calendar Tools<br/>[calendar.py]"]
  node_bank["Bank Tools<br/>[bank.py]"]
  node_files["File Tools<br/>[filestore.py]"]
  node_web["Web Fetch<br/>[web_fetch.py]"]
end

subgraph group_evaluation["Benchmark Evaluation"]
  node_evaluation_runner["Evaluation Runner<br/>[runner.py]"]
  node_metrics["Metrics<br/>[metrics.py]"]
  node_reports["Report Generation<br/>[report.py]"]
end

subgraph group_research["Attack Research"]
  node_taxonomy["Attack Taxonomy<br/>[taxonomy.py]"]
  node_baselines["Defense Baselines"]
  node_scanner["CLI Scanner<br/>[scan.py]"]
end

node_user(("User"))

node_user -->|"submits task"| node_harness
node_harness -->|"builds prompt"| node_prompts
node_harness -->|"requests completion"| node_providers
node_harness -->|"reads and writes"| node_cache
node_harness -->|"executes calls"| node_executor
node_harness -->|"checks tool activity"| node_pipeline
node_pipeline -->|"checks proposed calls"| node_policy
node_pipeline -->|"tags tool output"| node_provenance
node_pipeline -->|"scores tool output"| node_classifier
node_executor -->|"logs tool calls"| node_state
node_executor -->|"dispatches"| node_email
node_executor -->|"dispatches"| node_calendar
node_executor -->|"dispatches"| node_bank
node_executor -->|"dispatches"| node_files
node_executor -->|"dispatches"| node_web
node_email -->|"reads and writes"| node_state
node_calendar -->|"reads and writes"| node_state
node_bank -->|"reads and writes"| node_state
node_files -->|"reads and writes"| node_state
node_web -->|"reads sandbox pages"| node_state
node_evaluation_runner -->|"runs cases through"| node_harness
node_evaluation_runner -->|"configures tools"| node_executor
node_evaluation_runner -->|"captures outcomes"| node_state
node_evaluation_runner -.->|"evaluates results"| node_metrics
node_reports -->|"formats metrics"| node_metrics
node_taxonomy -.->|"defines attack space"| node_evaluation_runner
node_baselines -.->|"compared in benchmark"| node_evaluation_runner
node_scanner -.->|"scans input"| node_pipeline

click node_harness "https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/agent/harness.py"
click node_prompts "https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/agent/prompts.py"
click node_providers "https://github.com/saksham6349/prompt-injection-benchmark/tree/main/src/agent/providers"
click node_cache "https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/agent/cache.py"
click node_pipeline "https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/defense/pipeline.py"
click node_provenance "https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/defense/provenance.py"
click node_classifier "https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/defense/classifier.py"
click node_policy "https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/defense/policy.py"
click node_executor "https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/sandbox/executor.py"
click node_state "https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/sandbox/state.py"
click node_email "https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/sandbox/tools/email.py"
click node_calendar "https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/sandbox/tools/calendar.py"
click node_bank "https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/sandbox/tools/bank.py"
click node_files "https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/sandbox/tools/filestore.py"
click node_web "https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/sandbox/tools/web_fetch.py"
click node_evaluation_runner "https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/evaluation/runner.py"
click node_metrics "https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/evaluation/metrics.py"
click node_reports "https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/evaluation/report.py"
click node_taxonomy "https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/taxonomy/taxonomy.py"
click node_baselines "https://github.com/saksham6349/prompt-injection-benchmark/tree/main/src/baselines"
click node_scanner "https://github.com/saksham6349/prompt-injection-benchmark/blob/main/scripts/scan.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_harness,node_prompts,node_providers,node_cache,node_user toneBlue
class node_pipeline,node_provenance,node_classifier,node_policy toneAmber
class node_executor,node_state,node_email,node_calendar,node_bank,node_files,node_web toneMint
class node_evaluation_runner,node_metrics,node_reports toneRose
class node_taxonomy,node_baselines,node_scanner toneIndigo
```

## Components

### Agent Runtime

- [Agent Harness](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/agent/harness.py): `src/agent/harness.py`
- [Prompt Builder](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/agent/prompts.py): `src/agent/prompts.py`
- [LLM Providers](https://github.com/saksham6349/prompt-injection-benchmark/tree/main/src/agent/providers): `src/agent/providers`
- [Response Cache](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/agent/cache.py): `src/agent/cache.py`

### Defense Pipeline

- [Defense Orchestrator](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/defense/pipeline.py): `src/defense/pipeline.py`
- [Provenance Tagger](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/defense/provenance.py): `src/defense/provenance.py`
- [Injection Classifier](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/defense/classifier.py): `src/defense/classifier.py`
- [Tool Policy](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/defense/policy.py): `src/defense/policy.py`

### Mock Sandbox

- [Tool Executor](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/sandbox/executor.py): `src/sandbox/executor.py`
- [SQLite Sandbox State](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/sandbox/state.py): `src/sandbox/state.py`
- [Email Tools](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/sandbox/tools/email.py): `src/sandbox/tools/email.py`
- [Calendar Tools](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/sandbox/tools/calendar.py): `src/sandbox/tools/calendar.py`
- [Bank Tools](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/sandbox/tools/bank.py): `src/sandbox/tools/bank.py`
- [File Tools](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/sandbox/tools/filestore.py): `src/sandbox/tools/filestore.py`
- [Web Fetch](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/sandbox/tools/web_fetch.py): `src/sandbox/tools/web_fetch.py`

### Benchmark Evaluation

- [Evaluation Runner](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/evaluation/runner.py): `src/evaluation/runner.py`
- [Metrics](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/evaluation/metrics.py): `src/evaluation/metrics.py`
- [Report Generation](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/evaluation/report.py): `src/evaluation/report.py`

### Attack Research

- [Attack Taxonomy](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/src/taxonomy/taxonomy.py): `src/taxonomy/taxonomy.py`
- [Defense Baselines](https://github.com/saksham6349/prompt-injection-benchmark/tree/main/src/baselines): `src/baselines`
- [CLI Scanner](https://github.com/saksham6349/prompt-injection-benchmark/blob/main/scripts/scan.py): `scripts/scan.py`

### Other components

- **User**

## Connections

- User → Agent Harness: submits task (evidence: `README.md`)
- Agent Harness → Prompt Builder: builds prompt (evidence: `src/agent/harness.py`)
- Agent Harness → LLM Providers: requests completion (evidence: `src/agent/harness.py`)
- Agent Harness → Response Cache: reads and writes (evidence: `src/agent/harness.py`)
- Agent Harness → Tool Executor: executes calls (evidence: `README.md`)
- Agent Harness → Defense Orchestrator: checks tool activity (evidence: `README.md`)
- Defense Orchestrator → Tool Policy: checks proposed calls (evidence: `src/defense/pipeline.py`)
- Defense Orchestrator → Provenance Tagger: tags tool output (evidence: `src/defense/pipeline.py`)
- Defense Orchestrator → Injection Classifier: scores tool output (evidence: `src/defense/pipeline.py`)
- Tool Executor → SQLite Sandbox State: logs tool calls (evidence: `src/sandbox/executor.py`)
- Tool Executor → Email Tools: dispatches (evidence: `src/sandbox/executor.py`)
- Tool Executor → Calendar Tools: dispatches (evidence: `src/sandbox/executor.py`)
- Tool Executor → Bank Tools: dispatches (evidence: `src/sandbox/executor.py`)
- Tool Executor → File Tools: dispatches (evidence: `src/sandbox/executor.py`)
- Tool Executor → Web Fetch: dispatches (evidence: `src/sandbox/executor.py`)
- Email Tools → SQLite Sandbox State: reads and writes (evidence: `src/sandbox/tools/email.py`)
- Calendar Tools → SQLite Sandbox State: reads and writes (evidence: `src/sandbox/tools/calendar.py`)
- Bank Tools → SQLite Sandbox State: reads and writes (evidence: `src/sandbox/tools/bank.py`)
- File Tools → SQLite Sandbox State: reads and writes (evidence: `src/sandbox/tools/filestore.py`)
- Web Fetch → SQLite Sandbox State: reads sandbox pages (evidence: `src/sandbox/tools/web_fetch.py`)
- Evaluation Runner → Agent Harness: runs cases through (evidence: `src/evaluation/runner.py`)
- Evaluation Runner → Tool Executor: configures tools (evidence: `src/evaluation/runner.py`)
- Evaluation Runner → SQLite Sandbox State: captures outcomes (evidence: `src/evaluation/runner.py`)
- Evaluation Runner → Metrics: evaluates results
- Report Generation → Metrics: formats metrics (evidence: `src/evaluation/report.py`)
- Attack Taxonomy → Evaluation Runner: defines attack space
- Defense Baselines → Evaluation Runner: compared in benchmark (evidence: `README.md`)
- CLI Scanner → Defense Orchestrator: scans input
