Formal Protocol Verification · IETF 127

Proving MCP Authorization: What We Modeled, What We Rediscovered, and Why Every Check Matters

A machine-checked formal analysis of Model Context Protocol authorization in Tamarin, an ablation lattice of security checks, and a case study on UPI-style agent payments.

Harsh Thumar & Prince Upadhyay
·
Remote Participants, IETF 127
·
Independent Researchers
·
Artifact Availability

All formal specifications (Models 01 through 09), 376 continuous lemma checks, and the full ablation lattice are published under the MIT license in the public repository at github.com/HarshThumar/mcp-auth-tamarin.

The question

When an AI agent connects to a local or remote tool via the Model Context Protocol (MCP), it relies on OAuth 2.1 to authorize requests. But MCP introduces an inversion of traditional OAuth assumptions: the resource server (the MCP tool server itself) is the entity that directs the client to an Authorization Server (RFC 9728). If that MCP server is untrusted, compromised, or malicious, what prevents it from pointing the client to a rogue authorization server, harvesting client credentials, or tricking the client into replaying tokens across different tools?

In production SDKs, multiple defenses are layered to prevent these failures: metadata issuer validation, client credential isolation, PKCE, authorization response issuer checks (iss), and resource-server audience validation. The practical engineering question is: can we prove that these defenses are sufficient, and what happens if an implementation omits or misconfigures one of them?

Figure 1 MCP Authorization Sequence & Defense Anchors
User / Principal Authorizing Entity MCP Client Host / AI Agent MCP Server (RS) Untrusted / Tool Server Authorization Server RFC 8414 AS Phase 1: Discovery & Metadata Isolation (RFC 9728) 1. Connect tools/list 2. HTTP 401 + AS pointer (as.example) Phase 2: Authorization Code + PKCE + RFC 8707 Resource Binding 3. /authorize (PKCE + resource=rs.example) 4. Consent Screen (Payee, Scope, Resource URI) 5. User Approves Mandate / Access 6. Code + RFC 9207 iss confirmation Phase 3: Token Exchange & Audience-Bound Tool Calls 7. /token (Redeem Code + PKCE Verifier) 8. Access Token (aud = rs.example) 9. tools/call (Authorized Bearer)
sequenceDiagram
    autonumber
    actor User as User / Principal
    participant Client as MCP Client (Host / Agent)
    participant RS as MCP Server (Untrusted Tool)
    participant AS as Authorization Server (RFC 8414)

    Note over Client,RS: 1. Discovery Phase
    Client->>RS: Connect (tools/list)
    RS-->>Client: HTTP 401 + Protected Resource Metadata (RFC 9728)

    Note over Client,AS: 2. Authorization & Credential Isolation
    Client->>AS: /authorize (PKCE + RFC 8707 Resource)
    AS-->>User: Consent Screen (Payee, Scope, Resource)
    User-->>AS: User Approves
    AS-->>Client: Authorization Code + RFC 9207 iss

    Note over Client,RS: 3. Token Exchange & Audience Enforcement
    Client->>AS: /token (Redeem Code + PKCE Verifier)
    AS-->>Client: Access Token (aud = MCP Server)
    Client->>RS: tools/call (Bearer Token)
    RS-->>Client: Tool Result
Figure 1: Full lifecycle of MCP client discovery, authorization code redemption, and audience-restricted token exchange across untrusted tools.

What we did

During the IETF 127 Hackathon (14-15 November 2026, remote), we modeled the MCP authorization flow in the Tamarin prover, a symbolic verification tool for cryptographic protocols. Tamarin tests protocols against a standard Dolev-Yao attacker who controls the network, capable of intercepting, rewriting, and injecting traffic, while operating dishonest authorization servers, rogue resource servers, and malicious clients.

The repository contains 9 models (models/01 through models/09):

Across these models, 376 lemma expectations are continuously checked in CI with zero well-formedness warnings.

The ablation idea

Most formal protocol analyses only verify a single, fully hardened specification where every defense is enabled. While that shows the protocol can be secure, it does not tell implementers which checks are strictly necessary, which checks are redundant, or what concrete failure mode occurs when a specific check is omitted.

To answer this, we computed a complete ablation lattice across the protocol suite (docs/ablation.md). For each model, we systematically disabled security checks one subset at a time (where each preprocessor flag corresponds to one check) and ran the theorem prover across all combinations.

With 100% of ablation cells decided, the machine-checked lattice reveals the minimal sufficient check sets for every security property:

Figure 2 Ablation Lattice Architecture & Failure Modes
Hardened Baseline: All 376 Lemmas Verified Full Protocol Defenses Active · Models 01 through 09 NO_BINDING RFC 8414 §3.3 Metadata Attacker AS harvests client credentials for benign tool Trace Found NO_AUD RFC 8707 §2 Resource Bearer token replayed across unrelated MCP servers without check Trace Found NO_ISS RFC 9207 iss Validation AS mix-up succeeds by tricking client despite active PKCE Trace Found NO_SENDER_CNF RFC 9449 DPoP Binding Network attacker replays payment with fresh transaction ID Trace Found NO_ONLINE_REVOC RFC 7009 Lookup Agent continues debits after principal cancels or delinks mandate Trace Found
flowchart TD
    subgraph Hardened["Hardened Baseline (All Checks Active)"]
        AllOn["All Defensive Checks ON"] --> Proved["All Security Lemmas Verified (Secrecy, Integrity, Intent, Revocation)"]
    end

    subgraph Lattice["Ablation Lattice (Individual Checks Removed)"]
        direction TB
        F1["Remove Issuer Binding (NO_BINDING)"] --> A1["Attacker AS receives registered client credentials"]
        F2["Remove Audience Check (NO_AUD)"] --> A2["Replay bearer token across unrelated MCP servers"]
        F3["Remove Issuer Check (NO_ISS)"] --> A3["AS mix-up attack succeeds despite PKCE"]
        F4["Remove Sender Constraint (cnf)"] --> A4["Replay leaked payment request with fresh payment ID"]
        F5["Remove Online Revocation Check"] --> A5["Debits continue after user delinks the mandate"]
    end
Figure 2: Formal ablation lattice demonstrating that every individual defense is strictly necessary to prevent distinct, machine-checked counterexample traces.
Interactive Defense Explorer: Trace Any Omitted Check
Click any protocol flag below to inspect what security invariant breaks and how the hardened baseline restores it.
Failure Mode When Check Is Ablated
When client credentials are stored without being bound to the authorization server issuer URL, an untrusted MCP server can direct the client to an attacker-controlled AS. The client delivers its credentials to the attacker, who can then impersonate the client against benign services.
Machine-Checked Hardened Defense
Model 01 proves that issuer-scoped key derivation and RFC 8414 metadata validation guarantee client credential secrecy (Lemma client_secret_secrecy), preventing any cross-AS credential harvesting.

What it rediscovered

When checks are ablated in the models, the attack traces found by Tamarin directly reproduce the conditions of published, already-fixed vulnerabilities across official MCP SDKs:

Advisory / CVE Protocol Clause Model Flag Real-World Consequence Status
GHSA-qx49-fqc8-xw99 RFC 8414 §3.3 Model 01 NO_BINDING Untrusted MCP server redirects client to attacker AS, leaking credentials Shipped
GHSA-w4fh-qvv9-3v23 RFC 8707 §2 Model 02 NO_AUD Missing audience check allows replaying valid tokens across MCP servers Shipped
GHSA-rvq5-wwqv-78pq RFC 8707 §2 Model 02 NO_AUD Opt-in audience check defaults off in TypeScript SDK, exposing servers to replay Shipped
GHSA-6qxp-vccf-f47h MCP AS Binding Model 01 / 03 Client credentials stored without issuer stamping cross AS boundaries Shipped

None of these attack mechanisms is new. Each corresponds to an established vulnerability class or documented OAuth pitfall (such as authorization server mix-up despite PKCE under RFC 9207, or audience injection under RFC 7523). The contribution is not claiming new vulnerabilities, but providing a machine-checked verification map demonstrating that published fixes are formally sound and identifying where implementers risk regression.

The India angle

As AI agents begin executing financial operations, authorization shifts from accessing data to authorizing irrevocable fund transfers. In India, the Unified Payments Interface (UPI) ecosystem already incorporates delegated payments through NPCI's UPI Circle (circulars OC 201 and OC-201B), allowing primary account holders to delegate payment authority to secondary users and software agents within predefined limits.

In Model 05 and our accompanying whitepaper (whitepaper/agent-payments-india.md), we analyzed what an autonomous agent payment mandate must cryptographically bind:

  1. The principal's approved payee
  2. Explicit per-transaction and cumulative amount caps
  3. A single target payment server (audience restriction)
  4. A cryptographic key bound to the agent (proof of possession / DPoP)
  5. An active online revocation check

The ablation results for Model 05 show that these controls are strictly independent:

Regulatory & Policy Mapping

We mapped these machine-checked findings to Indian policy and security frameworks, including the RBI FREE-AI Committee Report (addressing recommendations on Trust, Accountability, and Resilience), CERT-In AI Security Guidelines, and the DPDP Act 2023. We couldn't find prior formal work on UPI-style agent mandates (the literature search is logged in the repository and the search is not exhaustive).

Reproduce it

Every lemma proof, model variant, and ablation result is fully reproducible via Docker without installing Tamarin or Maude locally:

bash: reproduce formal proofs
docker build -t mcp-auth-tamarin .
docker run --rm mcp-auth-tamarin ./scripts/reproduce.sh

The script executes the full verification suite, checks all 376 lemma expectations, and outputs runtime benchmarks confirming that all properties verify or fail as specified.

What's next / caveats

This repository provides the baseline for ongoing academic paper preparation. While symbolic verification provides mathematical certainty within the model's defined boundaries, real-world deployments carry limits that any formal abstraction simplifies:

Formal verification provides protocol designers and SDK maintainers with machine-checked confidence before specifications and implementations freeze. As agentic protocols expand, formal models provide an essential tool for ensuring that delegated authority remains strictly bounded.

Have an implementation perspective?

If you are building or integrating MCP clients, servers, or agent delegation systems: which assumptions in your authorization flow have been hardest to validate, and where do you observe the greatest divergence between OAuth specifications and actual SDK behavior?

Links