{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-mcp-session-migration-from-silently-rebinding-a-tool-s-oauth-2-1-resource-token-to-the-wrong-upstream",
  "title": "Which invariants prevent MCP session migration from silently rebinding a tool's OAuth 2.1 resource token to the wrong upstream",
  "date_of_record": "2026 November 30",
  "scope": "Applies to HTTP-native Model Context Protocol deployments that support resumable SSE (legacy transport) and streamable-HTTP transport with `Last-Event-ID` resumption, and that bind per-tool OAuth 2.1 tokens to a specific resource (RFC 8707). Does not cover stdio transport or single-transport, unauthenticated servers where no resumption or token binding occurs.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-mcp-session-migration-from-silently-rebinding-a-tool-s-oauth-2-1-resource-token-to-the-wrong-upstream.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-mcp-session-migration-from-silently-rebinding-a-tool-s-oauth-2-1-resource-token-to-the-wrong-upstream.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-mcp-session-migration-from-silently-rebinding-a-tool-s-oauth-2-1-resource-token-to-the-wrong-upstream.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1674,
    "python_slice_tokens": 206,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure mode is not *token expiry* and not *transport disconnect*. It is a **rebinding of credential scope during a resume**. When a client resumes a suspended session, the MCP spec allows the server to hand back a new session identifier and a new event stream. In an HTTP-native implementation, the resume request is a fresh HTTP request carrying fresh `A...",
    "what_was_observed": "A client held a session `sess_A` opened over SSE. During a long-running `tools/call` to a tool whose OAuth 2.1 token carried `resource=https://upstream-prod.internal/mcp`, the client's connection dropped at event `id: 4471`. The client reconnected via the streamable-HTTP endpoint with `Last-Event-ID: 4471` and a `Mcp-Session-Id: sess_A` header, plus a token minted for the *new* gateway hostname `resource=https://gate...",
    "condition_of_validity": "This is a real invariant violation only under the following conditions, and an agent should treat it as *inapplicable* otherwise: - The server implements **both** transports and permits migration between them for a single session. Servers that pin a session to its opening transport (returning `409 Conflict` on cross-transport resume) are immune by constructi...",
    "decision_boundary": "An agent operating against such a server must decide, on every resume, whether it can trust the resumed stream. The decision boundary is: - **Fail closed** if the resume response's returned session identifier differs from the one sent, *and* the tool binding's resource indicator is not echoed in the resume response. Treat the tail of the stream as untrusted ...",
    "operational_effect": "Downstream, the effect is a **split-brain tool execution**: the pre-disconnect portion of the tool's side effects landed on upstream R1, the post-resume portion on R2. If the tool is non-idempotent (writes, payments, state mutations), the result is a partial transaction spanning two authorization domains — an audit and compliance failure, not merely a data-c..."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "0ebc7e1fc86a1edbce082a1d7d1f0be624e738dde6aaf9ee5eea414241275029",
    "verified_classes": [
      "BindingRebindError"
    ],
    "verified_functions": [
      "resume_session"
    ],
    "verified_functions_count": 1,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "BindingRebindError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
