zt-broker
README.md
# ZeroTrust AI Broker (`zt-broker`)
[](.github/workflows/ci.yml)
[](LICENSE)
[](pyproject.toml)
[](docs/EVALUATION.md)
[](docs/audit-contract.md)
An open-source, inline Zero Trust MCP security broker built for **ZeroTrust AI: Securing the Agentic Enterprise** (Techfest 2026-27, IIT Bombay × Zscaler).
## 30-Second Summary
`zt-broker` sits inline (`0.0.0.0:8200/mcp`) between 5 autonomous AI agents and 26 enterprise tools, answering one question for every call:
> *"Can this agent be trusted to perform this action on this resource right now—and can we enforce, explain, and prove that decision?"*
- **Least-Privilege Policy + Zero-Restart Hot Reload:** Per-agent YAML policies (`policies/agents/*.yaml`) with JSON Schema validation, dry-run checks, atomic swap via `watchfiles` / `POST /admin/reload`, and `resource_agent_allowlist` for instant Round 3 restrictions.
- **5 Timeout-Isolated Parallel Detectors:** Direct prompt injection (multilingual heuristics + quantized CPU ONNX classifier), indirect injection response sanitizer, DLP (MOD-97 IBAN, Luhn PAN, PII, secrets, session-harvested values), sanitized-aware session taint tracking, and tool-abuse/payment-diversion detection.
- **Graded Explainable Decisions + Adaptive Trust:** Outputs `ALLOW`, `MONITOR`, `STEP_UP`, or `BLOCK` with cited rule IDs, signals, trust/risk scores, and remediation.
- **Tamper-Evident Audit Trail:** Write-ahead `fsync`ed JSONL with SHA-256 hash chain, Ed25519 signatures, and atomic `.head` truncation anchor (`broker-audit verify`).
## Architecture

Full C4 diagrams and outcome sequence flows: [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md).
## One-Command Quickstart & Demo
Prerequisites: Python 3.12, [uv](https://docs.astral.sh/uv/), and `sentinel-sandbox` at `../sentinel-sandbox` (with `uv sync` run in both).
```bash
# Install dependencies & fetch/verify quantized ONNX model (Apache-2.0)
make setup
# Run the complete ONE-command end-to-end demo (sandbox + broker + all 4 decisions + tamper check)
make demo
```
### Reproduce Bronze Milestone & Audit Verification
```bash
# Runs sentinel tools + zt-broker + sentinel check --suite bronze + sentinel audit test
make bronze
# Verify any audit log manually (exits 0 if intact, non-zero with first bad seq on tamper)
uv run --no-sync broker-audit verify audit/bronze_audit.jsonl
# Export SIEM-ready ECS JSON
uv run --no-sync broker-audit export audit/bronze_audit.jsonl --format ecs
```
### Run SOC Dashboard (Out-of-Band)
```bash
uv sync --extra dashboard
uv run --no-sync streamlit run src/zt_broker/dashboard/app.py
```
## Key Evaluation Metrics (135 Replay Runs vs. Passthrough Baseline)
| Metric | Passthrough Baseline | `zt-broker` v1.0.0 |
|---|---:|---:|
| Identity Probes Refused | N/A | **3 / 3** |
| `benign_utility` | 1.000 | **1.000** (15/15) |
| `false_block_rate` | 0.000 | **0.000** (0/15) |
| `attack_success_rate` (FNR) | 1.000 (120/120) | **0.000** (0/120) |
| `utility_under_attack` | 1.000 | **0.933** (112/120) |
| `step_up_rate` (Benign) | 0.000 | **0.000** |
| `decision_mismatch_runs` | 0 | **0** |
| `latency_p50_ms` (end-to-end MCP hop) | 24.85 ms | **48.18 ms** (+23.33 ms) |
| Custom Red-Team Corpus (`16` cases) | — | **100.0%** detected |
| Benign-Suspicious Corpus (`12` cases) | — | **0.0%** false blocks |
| `sentinel audit test` (modify/delete/insert/reorder/truncate) | — | **AUDIT: PASS** (`0` missing) |
## Environment Variables
| Variable | Default | Description |
|---|---|---|
| `SENTINEL_BROKER_TOKEN` | `""` | Upstream tool-server bearer credential (never exposed to agents) |
| `SENTINEL_UPSTREAM_URL` | `http://127.0.0.1:8100/mcp` | Upstream Sentinel MCP server URL |
| `SENTINEL_APPROVER_URL` | `http://127.0.0.1:8102/approve` | Step-up approver endpoint (empty disables -> fail closed) |
| `SENTINEL_CATALOG_DIR` | Auto-resolved | Directory containing `agents.yaml`, `resources.yaml`, `tools.yaml` |
| `SENTINEL_BROKER_HOST` | `0.0.0.0` | Broker listen host |
| `SENTINEL_BROKER_PORT` | `8200` | Broker listen port (`/mcp`, `/healthz`, `/readyz`, `/metrics`, `/admin/reload`) |
| `ZT_POLICY_DIR` | `policies` | Policy YAML root directory |
| `ZT_AUDIT_LOG_PATH` | `audit/audit.jsonl` | Append-only JSONL audit log path (mount volume in Docker) |
| `ZT_AUDIT_SIGNING_KEY` | Ephemeral if unset | Ed25519 private key (PEM / hex / URL-safe base64) |
| `ZT_AUDIT_PUBLIC_KEY` | Embedded in `.head` | Optional pinned Ed25519 public key for `broker-audit verify` |
| `ZT_RELOAD_TOKEN` | `""` | Bearer secret protecting `POST /admin/reload` |
| `ZT_MODEL_PATH` | `models/prompt_guard.onnx` | Local pre-quantized ONNX model path |
| `ZT_CLASSIFIER_ENABLED` | `true` | Toggle ONNX classifier (degrades gracefully to heuristics) |
| `ZT_DETECTOR_TIMEOUT_MS` | `2000` | Per-detector timeout in milliseconds |
| `ZT_ONNX_THREADS` | `2` | Intra-op CPU threads for ONNX Runtime |
## Container Build & Run
```bash
docker build -t zt-broker:latest .
docker run --rm -p 8200:8200 --read-only --tmpfs /tmp \
-v "$(pwd)/audit:/data/audit" \
-v /path/to/catalog:/catalog:ro \
-e SENTINEL_BROKER_TOKEN="$(cat ../sentinel-sandbox/.sentinel/broker.token)" \
-e SENTINEL_UPSTREAM_URL=http://host.docker.internal:8100/mcp \
-e SENTINEL_APPROVER_URL=http://host.docker.internal:8102/approve \
-e SENTINEL_CATALOG_DIR=/catalog \
zt-broker:latest
```
*(Docker runtime image `zt-broker:latest` (`367 MB`) uses `python:3.12-slim-bookworm` + non-root UID `10001` + baked 256 MB INT8 ONNX weights; verified with `docker build` and `docker run --read-only --tmpfs /tmp` against `sentinel check --suite bronze` (`BRONZE: PASS`) and `sentinel audit test` (`AUDIT: PASS`).)*
## Documentation Index
- [Contract Notes](docs/CONTRACT_NOTES.md) & [Tool Inventory](docs/TOOL_INVENTORY.md)
- [Architecture](docs/ARCHITECTURE.md) & [ADRs 0001–0005](docs/adr/0001-pipeline-architecture.md)
- [Threat Model](docs/THREAT_MODEL.md)
- [Policy Model](docs/POLICY_MODEL.md) & [Decision Logic](docs/DECISIONS.md)
- [Security Evaluation](docs/EVALUATION.md) & [Performance Analysis](docs/PERFORMANCE.md)
- [Demo Script](docs/DEMO_SCRIPT.md) & [Judge Q&A Prep](docs/QA_PREP.md)
- [Security Policy](SECURITY.md), [Credits](CREDITS.md), [Changelog](CHANGELOG.md), [Contributing](CONTRIBUTING.md)
- Submission Drafts: [Technical Proposal](submission/TECHNICAL_PROPOSAL.md), [Evaluation Report](submission/SECURITY_EVALUATION_REPORT.md), [Demo Script](submission/DEMO_SCRIPT.md)
**Submission Tag / Commit:** See `git rev-parse HEAD` / tag `v1.0.0-submission`.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues