{
  "schema_version": "1.3.0",
  "slug": "which-invariants-prevent-mcp-session-hijack-after-transport-re-binding-from-silently-widening-per-tool-authorization-scopes",
  "title": "Which invariants prevent MCP session hijack after transport re-binding from silently widening per-tool authorization scopes",
  "date_of_record": "2026 November 23",
  "scope": "Applies to MCP servers that authenticate at the transport layer (stdio→SSE upgrade, HTTP streamable reconnection, or token-refresh mid-session) while enforcing per-tool authorization scopes derived from the *authenticated principal* rather than from the *session object*. Does not apply to stateless one-shot RPC servers with no session identity, or to servers where every tool shares a single coarse scope.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/which-invariants-prevent-mcp-session-hijack-after-transport-re-binding-from-silently-widening-per-tool-authorization-scopes.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-mcp-session-hijack-after-transport-re-binding-from-silently-widening-per-tool-authorization-scopes.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/which-invariants-prevent-mcp-session-hijack-after-transport-re-binding-from-silently-widening-per-tool-authorization-scopes.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 1746,
    "python_slice_tokens": 373,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "The failure is not \"auth bypass.\" Every message in the failing trace carries a valid, non-expired bearer token, and every tool call passes its declared scope check. The break is subtler: **the authorization scope was bound to the session at handshake time, but the transport was re-bound to a new principal mid-session without re-deriving the scope set.** MCP'...",
    "what_was_observed": "A tool-serving MCP deployment exposed two tools on one session: `read_kb` (scope `kb:read`) and `write_kb` (scope `kb:write`). The server derived scopes at `initialize` from the token's `scope` claim and cached them on the `Session` object alongside the transport handle. Trace of the failure: 1. Principal A (`scope: kb:read kb:write`) opens an SSE session `S1`. Server caches `S1.scopes = {kb:read, kb:write}`. `initia...",
    "condition_of_validity": "The invariant \"re-derive scopes on transport re-bind\" is necessary and sufficient only under these conditions: - Session identity is a durable key (`Mcp-Session-Id`) that survives transport reconnection, *and* the server resumes sessions on reconnect rather than forcing re-`initialize`. If every reconnect forces a fresh `initialize`, the scope cache is rebui...",
    "decision_boundary": "The boundary is whether **session continuity is worth the scope-reconciliation cost**. Two admissible designs: - **Resume-with-rebind (preferred):** On any transport re-bind carrying a `Mcp-Session-Id`, re-authenticate, then *recompute* `S.scopes = scopes(token)` and *intersect* with the tool list previously advertised. If the intersection shrinks, emit `not...",
    "operational_effect": "Downstream, the failure manifests as *capability hallucination by proxy*: an agent operating under a narrowed principal continues to plan tool calls against the session's stale advertised tool list, and either (a) succeeds because the server never re-checked, or (b) fails at execution while the agent's internal model still believes the tool is available, pro..."
  },
  "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": "e837b39b660bb2866dad1da926cfa7b317269fa9513e5cd4e618224b2d1edb4f",
    "verified_classes": [
      "ScopeReconciliationError",
      "Session"
    ],
    "verified_functions": [
      "resume_session",
      "authorize_tool_call"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 5,
    "raised_exceptions": [
      "ScopeReconciliationError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
