Skip to content

About

augur - offline, LLM-free safety and conformance auditor for the MCP completion channel (completion/complete): 33-rule catalog, score+grade+CI gate, pure stdlib

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Development Experiment 021 — augur

An offline, LLM-free safety & conformance auditor for the MCP completion channel (completion/complete).

augur passively replays a captured JSON-RPC session and grades whether an MCP server honored the completion contract and — more importantly — whether it weaponized the one MCP channel that fires on every keystroke of unsubmitted user input. It applies a 33-rule catalog across 6 families, emits a severity-weighted score + letter grade, and returns a CI exit code. Pure Python 3.11+ standard library, zero dependencies.

  SCORE 0/100   GRADE F   (unsafe — do not trust this completion source)  ⟶ CRITICAL findings present

Findings: ✖ 5 CRITICAL   ▲ 14 HIGH   ▶ 13 MEDIUM   • 6 LOW

Thesis

Every MCP safety tool to date — including the twenty prior experiments in this series — has audited channels that fire on completed, submitted actions: a tool call, a resource read, a prompt fetch, a sampling round-trip. The completion channel is different in kind. Per the spec it powers "IDE-like" autocomplete that fires as the user types, sending each partial argument value to the server on every keystroke. That gives a malicious (or merely careless) server a capability no other MCP channel has: it observes in-progress input that may never be submitted — a half-typed API key the user thinks better of, a file path, an email — a passive keystroke-surveillance primitive. On top of that, the strings the server returns are inserted straight into the user's input or shown in a dropdown, making completion a first-class injection and steering surface (prompt injection, homoglyph typosquats, SSRF resource URIs ranked #1). The completion channel survived the 2026-07-28 stateless rewrite un-deprecated (unlike Roots/Sampling/Logging), so it is a current attack surface with essentially no defensive tooling. augur is the smallest thing that proves the point: replay a capture, and it tells you exactly where the completion channel leaked, injected, or steered.


What it detects — the 33-rule catalog

Family Focus Rules
CAP Capability & declaration legality CAP01–CAP06
LEAK Value & keystroke exfiltration (unique to this channel) LEAK01–LEAK07
INJ Suggestion content injection & perception INJ01–INJ05
STEER Adversarial ranking & dangerous defaults STEER01–STEER03
URI Resource-ref URI exfiltration & SSRF URI01–URI06
RES Result conformance & abuse RES01–RES06

The four CRITICAL rules are the channel's signature harms:

  • LEAK01 — a credential-shaped value was sent to the server inside a completion keystroke. Because completion fires per keystroke, the secret leaked before (and even if never) the value was submitted.
  • INJ01 — a returned suggestion carries a prompt-injection payload; inserted into the argument or shown to the agent, it becomes indirect prompt injection (completion poisoning).
  • STEER01 — the server ranked a dangerous value first, i.e. the suggestion most likely to be accepted by default (SSRF URI, injection text, sensitive path).
  • URI01 — a suggested resource URI resolves to a cloud-metadata / internal host, turning autocomplete into an SSRF driver.

Run python -m augur --list-rules for the full annotated catalog.


Quick start

No install, no dependencies. From the project root:

# Audit the shipped clean session — scores 100/A, exits 0.
python -m augur captures/conformant.jsonl

# Audit the shipped weaponized session — scores 0/F, exits 3.
python -m augur captures/trojan.jsonl

# Machine-readable output for pipelines.
python -m augur captures/trojan.jsonl --json

# The rule reference.
python -m augur --list-rules

Or with make:

make run      # audit the trojan capture (demo)
make test     # run the test suite
make demo     # audit both captures side by side

As a library:

from augur import audit
result = audit("captures/trojan.jsonl")
print(result.report.score, result.report.grade)   # 0 F
for f in result.report.findings:
    print(f.rule_id, f.severity.label, f.message)

CI gate

augur's exit code is designed for a pipeline step that fails a build when a completion source is unsafe:

Exit Meaning
0 passed (score >= --min-score and no CRITICAL)
2 score below --min-score (default 90)
3 at least one CRITICAL finding
64 usage error / capture unreadable
python -m augur captures/session.jsonl --min-score 90 || exit 1

Sample run

Clean session:

╭─ augur ─ MCP completion-channel safety audit ────────────────────
│ source        : captures/conformant.jsonl
│ server        : reference-docs-mcp
│ protocol      : 2026-07-28
│ completions   : declared
│ exchanges     : 4 across 4 timeline(s)
╰───────────────────────────────────────────────────────────────

  SCORE 100/100   GRADE A   (conformant / no material risk)

No findings. The captured completion session is conformant and shows no weaponization of the channel.

Weaponized session (excerpt — the trojan capture triggers all 33 rules, 38 findings, 5 CRITICAL):

── LEAK  Value & keystroke exfiltration  (8)
  ✖ [LEAK01] credential captured in a completion keystroke  (CRITICAL)
      a AWS access key id was sent to the server inside a completion argument
      value while the user was typing; completion fires per keystroke, so this
      credential leaked before (and even if never) the value was submitted.
      at msg[12].params.argument.value
      evidence: detector="AWS access key id"  redacted="AKIA…******"  argument="target"
  ▶ [LEAK05] full value reconstructed keystroke-by-keystroke  (MEDIUM)
      the server received 4 successive prefixes of the value for 'target'
      (up to 20 chars), i.e. it reconstructed the full value keystroke-by-
      keystroke — a surveillance primitive no other MCP channel exposes.

── URI  Resource-ref URI exfiltration & SSRF  (9)
  ✖ [URI01] suggested resource URI targets metadata/SSRF host  (CRITICAL)
      a suggested resource URI targets an internal/metadata host (cloud metadata
      endpoint); accepting it drives the client into SSRF against cloud metadata.
      at msg[25].result.completion.values[0]
      evidence: uri="https://169.254.169.254/data"
  ▲ [URI05] resource template places a client variable in the authority  (HIGH)
      the resource template being completed places a client-controlled variable
      in the URI authority; the completed value chooses the host the server
      dereferences (SSRF primitive).

Architecture

capture.jsonl ──▶ capture.py ──▶ SessionModel ──▶ rules.py (33 checks) ──▶ [Finding]
   (JSONL or         parse &        declared          6 families,             │
    JSON array)     reconstruct    caps/prompts/     pure functions           ▼
                                   resources +                          scoring.py
                                   per-(ref,arg)                     severity weights,
                                   keystroke                          score + grade
                                   timelines                               │
                                                                           ▼
                                                          report.py ──▶ text / JSON / exit code
  • capture.py — defensive parser. Accepts JSON Lines or a JSON array, pairs requests to responses by JSON-RPC id, and reconstructs exactly what a client would have observed: the server's declared completions capability and identity (from initialize or the 2026-07-28 server/discover), the declared prompts and their argument names, declared resource URIs/templates, and every completion/complete exchange grouped into per-(ref, argument) keystroke timelines. Malformed lines become ParseIssues rather than aborting the run — a hostile server may emit garbage on purpose.
  • detectors.py — pure, deterministic heuristics: secret/PII/private-path scanners (redacting matches), invisible/bidi/TAG-Unicode and homoglyph detection, prompt-injection signatures, and a URI classifier (metadata/SSRF, dangerous schemes, exfil query params, client-variable-in-authority).
  • rules.py — the 33-rule catalog; each check is a pure function of the SessionModel yielding Findings with precise locators (msg[<i>].result.completion.values[<j>]) and redacted evidence.
  • scoring.py — severity weights (CRITICAL 40 / HIGH 15 / MEDIUM 6 / LOW 2), score = max(0, 100 − Σweights), letter grade, and CI gate codes.
  • report.py — human-readable and JSON renderers.
  • __main__.py — the CLI.

Design note — two approaches considered

  1. Live MITM proxy that intercepts completion/complete between a running client and server. Rejected. It requires a live client+server, is inherently stateful/non-deterministic, is far harder to test in CI, and — the deciding factor — the flagship keystroke-surveillance analysis (LEAK05, timelines) needs the full ordered sequence of requests for one argument, which a capture already preserves losslessly.
  2. Passive replay of a captured JSON-RPC session (chosen). Deterministic, offline, LLM-free, zero-dependency, trivially reproducible in CI, and the capture is exactly the ground truth the timeline analysis needs. This also keeps augur consistent with the rest of the series (passive trace conformance) and lets the audit run on traffic captured anywhere (proxy log, SDK trace, _meta OpenTelemetry export).

Trade-off: passive replay cannot audit a server that is never exercised, and cannot see traffic that was not captured. It complements — does not replace — a live proxy. Given the goal (a portable, CI-friendly, deterministic auditor), that trade is worth it.


Capture format

A capture is either JSON Lines (one JSON-RPC message per line) or a JSON array of messages. augur needs only the messages relevant to completion; it tolerates and ignores everything else. Requests and responses are paired by id. A minimal capture:

{"jsonrpc":"2.0","id":1,"method":"completion/complete","params":{"ref":{"type":"ref/prompt","name":"code_review"},"argument":{"name":"language","value":"py"}}}
{"jsonrpc":"2.0","id":1,"result":{"resultType":"complete","completion":{"values":["python","pyside"],"total":2,"hasMore":false}}}

Including server/discover/initialize, prompts/list, and resources/templates/list messages lets augur check declaration legality (CAP family) and off-origin URIs (URI04); without them those specific rules are conservatively skipped.

The two shipped captures are generated by tools/make_captures.py — kept in the repo so the fixtures are fully auditable and easy to extend.


Development

python -m pytest -q          # 57 tests
python tools/make_captures.py   # regenerate the reference captures

The test suite covers each detector, capture parsing (JSONL, JSON array, malformed lines, request/response pairing, context arguments, timeline grouping), every one of the 33 rules (the trojan fixture asserts all fire), scoring/grading/gate math, and the CLI's exit codes and output modes.


Assumptions & limitations

  • Offline & passive by design. augur audits what was captured; it neither connects to servers nor drives a client. A channel that was never exercised is not audited.
  • Heuristic detectors, tuned for precision. Secret/PII/injection/homoglyph detection is signature- and entropy-based, not exhaustive. It aims to avoid false positives on legitimate completions (verified: the conformant capture scores 100/A) at the cost of some recall on novel obfuscations. Treat findings as high-signal leads, not a proof of absence.
  • file: is treated as a normal resource scheme, not a "dangerous scheme". Sensitive local targets are instead caught by the private-path detector (LEAK03 / URI06).
  • resultType (CAP05) is only enforced when the capture's protocol version is ≥ 2026-07-28, since earlier revisions did not require the field.
  • Spec grounding. Rules follow the completion utility spec (ref/prompt, ref/resource, argument{name,value}, context.arguments, the 100-item values cap, total/hasMore, capability completions) and the 2026-07-28 changes (resultType, stateless _meta, un-deprecated status). Where the server's capability/prompt/resource declarations are absent from the capture, declaration-legality rules degrade gracefully rather than guessing.
  • Scoring is intentionally strict: a single CRITICAL drops the grade out of the passing band; the score floors at 0. Tune the CI gate with --min-score and --no-fail-on-critical.

See RESEARCH.md for the frontier signals that motivated this experiment, with links.

License

MIT — see LICENSE.

About

augur - offline, LLM-free safety and conformance auditor for the MCP completion channel (completion/complete): 33-rule catalog, score+grade+CI gate, pure stdlib

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages