LLM-free static lethal-trifecta capability-flow analyzer for MCP toolsets.
trifecta reads a Model Context Protocol tool manifest (a single tools/list
result, a bare tool array, or a multi-server bundle) and statically decides whether
the enabled toolset closes the lethal trifecta — the three capabilities that,
present together in one agent session, turn any indirect prompt injection into
zero-effort data exfiltration:
- PRIVATE — access to private / sensitive data,
- UNTRUSTED — exposure to attacker-influenceable content, and
- EXFIL — the ability to communicate externally.
Any two legs are safe. All three together mean an attacker who controls the untrusted content can read your private data and ship it out — no exploit code required (Simon Willison, 2025; OWASP Agentic Top 10 2026, ASI01).
It is deterministic and offline: no model calls, no network. Given a manifest it prints a report and returns a CI-friendly exit code.
Every 2026 defense guide for the lethal trifecta gives the same advice — containment:
per-task tool catalogs, allowlisted exfiltration channels, gate the dangerous tools.
But the trifecta is an emergent property of the whole toolset, not of any single
tool, and the existing MCP scanners (Cisco mcp-scanner, Invariant mcp-scan) are
per-tool YARA/pattern matchers — they flag a poisoned description, not the composition
that makes a catalog dangerous. Nobody actually computes "does this set of tools close
the channel, and what is the cheapest change that opens it back up?"
trifecta is the smallest thing that proves that gap is fillable statically. It
classifies each tool along two orthogonal axes — direction (read vs write) and
locus (private vs external) — derives the three legs as products of those axes,
and then answers the compositional questions: is the trifecta present, does it span
multiple servers, which single tool is a dual-use amplifier, what is the
minimum-cost set of tools to gate to break it, and which trifecta-free per-task
catalogs can you ship instead. That turns the industry's hand-wavy "use containment"
into a concrete, CI-enforceable plan.
- vs existing MCP scanners (
mcp-scanner,mcp-scan, MCPTox): those match adversarial text patterns in one tool at a time (~78% false-positive rate in the April 2026 33-server audit).trifectareasons about the set: the risk it reports cannot be seen by looking at any tool alone. - The two-axis model. Reducing capability detection to
direction x locusmakes the three legs fall out as products (read x private,read x external,write x external) and keeps precision high: a private-file reader is never mislabeled an exfil sink just because its description mentions a URL. - The mitigation is an optimization, not a lint. Breaking the trifecta means
emptying one leg; the three legs are the only three candidate cuts; the recommended
fix is the cheapest cut under caller-supplied tool
criticality. - Cross-server detection. Flags the documented rug-pull / cross-server exfil shape — a trifecta that no single mounted server closes on its own.
No dependencies to run the tool itself (pure Python 3.11+ stdlib). pytest only for
tests.
# Analyze a manifest (human report). Exits 2 when the trifecta is present.
python main.py scan examples/trifecta_present.json
# Machine-readable output for CI / downstream tooling.
python main.py scan examples/trifecta_present.json --format json
# Tune the CI gate sensitivity.
python main.py scan manifest.json --fail-on amplifier # also fail on dual-use tools
python main.py scan manifest.json --fail-on any-two-legs # fail one tool before it closes
python main.py scan manifest.json --fail-on never # report only
# Accept a known trifecta as a baseline, then keep CI green until it regresses.
python main.py baseline manifest.json -o trifecta.baseline.json --note "reviewed 2026-07-18"
python main.py scan manifest.json --baseline trifecta.baseline.json
# Project-specific vocabulary.
python main.py scan manifest.json --lexicon my-lexicon.jsonOr via make: make test, make run, make demo.
Install as a console script (trifecta scan ...): pip install .
| code | meaning |
|---|---|
| 0 | clean, or gate satisfied / waived by baseline |
| 2 | gate tripped (trifecta present at/above --fail-on, not waived) |
| 3 | manifest error |
| 4 | lexicon error |
| 5 | baseline error |
| 1 | unexpected error |
$ python main.py scan examples/trifecta_present.json
[trifecta] GATE FAILED: fail-on=trifecta, risk=77/100
========================================================================
trifecta | LETHAL TRIFECTA PRESENT | risk 77/100
========================================================================
Trifecta legs (tools per capability):
[x] private reads private data
- read_file
- search_notes
[x] untrusted ingests untrusted content
- fetch_url
[x] exfil can exfiltrate externally
- send_email
Recommended mitigation (cheapest leg to break):
gate the untrusted leg -> require human approval for, or remove:
- fetch_url
cost: 1.0 (summed tool criticality)
alternatives: exfil (cost 1.0), private (cost 2.0)
Provably trifecta-free per-task catalogs:
* read-only-research (keep private + untrusted; drop exfil)
Read private + untrusted data but cannot send anything out. Safe for summarize/answer/triage tasks.
include 3 tool(s); exclude 1
* trusted-automation (keep private + exfil; drop untrusted)
Read private data and act externally, but never ingests untrusted content, so nothing can hijack the outbound step. Safe for scheduled/automated jobs.
include 3 tool(s); exclude 1
* public-relay (keep untrusted + exfil; drop private)
Ingest untrusted content and publish externally, but touches no private data, so there is nothing worth exfiltrating.
include 2 tool(s); exclude 2
fingerprint: sha256:14556c6a065d1376b43603e47eb644b8
The bundled examples/cross_server.json additionally demonstrates the cross-server
verdict (three single-tool servers that are each harmless but together close the
trifecta), and examples/amplifier.json demonstrates a single dual-use amplifier
(http_request: both ingests untrusted content and exfiltrates).
manifest.json ─► loader ─► [Tool] ─► classify (per tool) ─► [CapabilityProfile]
│
▼
analysis (whole toolset)
legs · trifecta? · cross-server? · amplifiers
minimum-cost mitigation · safe catalogs · risk
│
┌───────────────┼───────────────┐
▼ ▼ ▼
report baseline CLI
(text / json) (waiver ratchet) (gate)
loader.py— parses the three manifest shapes, preserving per-toolserverprovenance so cross-server trifectas can be attributed.lexicon.py— the auditable vocabulary + weights (data, not code). Two axes: read/write verbs and private/external terms, plus MCP annotation hints (readOnlyHint,destructiveHint,openWorldHint). Fully overridable via--lexicon.classify.py— scores the two axes for one tool from name (weight 3), description (1), schema field names (0.5) and annotations; a leg is asserted only when both of its component axes clear a floor. Every membership carries theEvidencethat produced it.analysis.py— the compositional core: leg sets, trifecta presence, cross-server detection, amplifiers, the cheapest-cut mitigation, the three trifecta-free catalogs, and a transparent 0–100 risk score.baseline.py— an order-independent fingerprint of the three leg-sets; a waiver passes only while the toolset does not regress (ratchet, don't back-slide).report.py/cli.py— text & JSON rendering and the CI gate with stable exit codes.
- Per-tool pattern/regex matching (what
mcp-scannerdoes). Cheap and simple, but structurally cannot see a compositional property — a set of individually-benign tools that together form an exfil channel — and drowns you in false positives on poisoned-looking descriptions. Rejected as the primary model. - A capability-flow model (chosen). Model each tool as a node with capability tags
on two axes, and treat the trifecta as the reachability of an exfil sink from an
untrusted source with private data in context. Because a single LLM context
commingles every tool's output, "reachable" collapses to "all three leg-sets are
non-empty in the enabled catalog" — which is exactly what makes the cheapest-cut
and safe-catalog results computable in closed form.
- CPU/memory: O(tools x lexicon) tokenization + O(tools) set ops — trivial; runs on thousands of tools in well under a second, no allocation surprises.
- Maintenance: the vocabulary is the only thing that drifts, and it is external data users can extend without touching the engine.
- Cost of the choice: heuristic classification can mislabel an oddly-named tool.
We accept that in exchange for zero external dependencies and full determinism, and
make every decision explainable via
Evidenceand tunable via--lexicon.
- Heuristic, not semantic. Classification is lexical + annotation-based. A tool
whose true behavior contradicts its name, description, schema, and hints can be
misclassified. The
--lexiconoverride and per-toolEvidenceexist precisely so a reviewer can correct and audit this. This is a prioritization and policy tool, not a proof of safety. write x private(e.g. writing a local file) is intentionally not an exfil leg. If a local write target is actually served publicly, that is out of scope for a static manifest-only view and should be modeled by tagging the toolexternal.- Single-session model. The analysis assumes all listed tools can be active in one
session (the worst case a manifest permits). If your host enforces per-task catalogs
already, feed
trifectaeach catalog separately — that is exactly what the emittedsafe_catalogsdescribe. - Trust is coarse. "private" and "external" are binary tags. Finer data-flow labeling (which specific fields are sensitive) is future work.
- Not a substitute for runtime containment. Static catalog hygiene reduces blast radius; it does not replace runtime policy enforcement, per-user data scoping, or audit trails.
python -m pytest # 58 tests, ~0.1s, no networkCoverage spans the classifier (two-axis logic, camelCase tokenization, evidence,
the email dual-membership case), the compositional analysis (trifecta detection,
cheapest-cut mitigation, criticality weighting, catalog partitioning, amplifiers,
risk bands), cross-server detection, the loader (all shapes + every error path),
baseline fingerprint/waiver ratcheting, lexicon overrides/validation, and the CLI
end-to-end (report formats, all --fail-on levels, baseline waiver, exit codes).
MIT — see LICENSE.
Development Experiment 009 of the dev-experiments-365 series: one novel, runnable R&D prototype per day.