# What structural signals indicate MCP transport-layer scope enforcement has silently degraded to tool-name allowlisting **Date of Record:** 2026 November 28 **Scope:** Applies to MCP servers that gate tool invocations on OAuth-style scopes declared per-tool in `tools/list` and enforced at the transport/session layer before dispatch. Does not cover in-process tool sandboxing, argument-level validation inside tool handlers, or prompt-injection defenses; those are downstream of the boundary described here. ## Core Distinction There are two structurally different things an MCP server can enforce at the transport boundary, and they are routinely conflated because they produce identical `200 OK` / successful `tools/call` responses in the happy path: 1. **Scope enforcement** — the session's granted scope set is checked against the tool's *declared required scopes* (a property of the tool's authorization metadata), and dispatch is refused unless the grant is a superset of the requirement. 2. **Tool-name allowlisting** — the session's grant is reduced to a set of permitted tool *names*, and dispatch is refused unless the requested name is in that set. The failure mode is a **silent degradation from (1) to (2)**. It happens when the scope-to-tool mapping is resolved once and cached as a name set, or when the server's `tools/list` response is filtered by scope *before* the client ever sees the required-scope metadata. After degradation, the server still returns correct-looking authorization decisions for every tool that existed at mapping time — but the invariant "every dispatched tool call was checked against the scope declared for *that tool's current definition*" no longer holds. A tool whose required scopes are widened, or a tool added to the registry with a name that collides with a previously-granted name, is dispatched without any scope check at all. ## What Was Observed A server exposed three tools: `read_file` (scope `fs:read`), `write_file` (scope `fs:write`), and `list_dir` (scope `fs:read`). The client held a grant of `fs:read`. On `initialize`, the server computed the permitted name set `{read_file, list_dir}` and stored it on the session object. Subsequent `tools/call` requests were authorized by `request.params.name in session.permitted_names`. The registry was then updated: `list_dir` was redefined to require `fs:read fs:write` because it now accepted a `recursive` flag that could stat into directories the caller lacked write access to. The session's cached name set was not invalidated — it was keyed on session ID, not on a registry version. Every `list_dir` call with `recursive=true` was dispatched to a handler that performed directory traversal under `fs:read` semantics while the tool's declared requirement said `fs:write` was mandatory. The observable signal was *not* an error. It was the absence of an error. The server logged `authorized: list_dir (cached name grant)` for every call, and the audit trail showed a scope string (`fs:read`) that no longer matched the tool definition. The mismatch was only detectable by diffing the live `tools/list` required-scope metadata against the session's cached grant — a comparison the server never performed because, after degradation, it no longer held the required-scope side of the comparison. A second, subtler signal: `tools/list` responses began omitting the `requiredScopes` field for tools the session was permitted to see, because the filtering step stripped it ("you already have access, why tell you what it needs"). A client-side auditor that validated scope metadata on each `tools/list` therefore saw a *cleaner* response than before the degradation — fewer fields, no contradictions. The structural signal of the bug was the disappearance of a field, which reads as a simplification rather than a regression. ## Condition of Validity The degradation is bounded and detectable under these conditions: - The server retains the per-tool required-scope declaration in the registry and can serve it on `tools/list` independently of the session's grant. If the registry itself is scope-filtered before serialization, the signal is destroyed. - The session carries a registry version or content hash, so a cached name grant can be invalidated when any tool's required scopes change or a new tool is added. Without a version, the cache is unfalsifiable. - The authorization check is re-derived from `(session.grant, registry[tool].required_scopes)` at dispatch time, not from a precomputed set. Name-set caching is only safe if the name set is *derived* per-request from current metadata, never stored. The invariant that must hold is: **for every dispatched `tools/call`, there exists a check that compared the session grant against the required scopes of the tool definition that the dispatched handler actually implements.** If the handler and the checked definition can drift, the check is decorative. ## Decision Boundary The decision boundary is whether the authorization decision is *recomputed* or *replayed*. - **Recompute** (safe): on each `tools/call`, look up `registry[params.name].required_scopes`, test `grant ⊇ required`, dispatch or refuse. Cost is a dict lookup; correctness is bounded by registry consistency. - **Replay** (unsafe): on each `tools/call`, test `params.name ∈ session.cached_permitted_names`. Cost is a set membership test; correctness is bounded by cache invalidation, which is the failure surface. The boundary is crossed the moment a server caches the *result* of a scope check instead of the *inputs* to it. Once crossed, no amount of downstream argument validation recovers the missing check, because the missing check was on the tool's *identity and requirement*, not its arguments. A guardrail that bounds the failure: refuse to dispatch any tool whose `required_scopes` were not read from the registry in the same request that dispatches it, and raise on any session whose `registry_version` differs from the live registry version. This converts a silent degradation into a loud refusal. ## Operational Effect The operational effect is that scope enforcement becomes **monotonic in the wrong direction**: it can only ever be too permissive after a registry change, never too restrictive, because the cache can only hold names that were once legitimately granted. A widened tool requirement is invisible; a narrowed one is also invisible (the cache still permits the name, so the tool stays callable after its requirement was tightened — a privilege that should have been revoked persists). The system's authorization state drifts away from its declared policy with no error, no log line, and no client-visible signal except the disappearance of metadata fields. Detection requires an out-of-band comparator: a periodic job that, for each live session, recomputes `grant ⊇ registry[name].required_scopes` for every name in the session's permitted set and raises on any name whose current requirement is not satisfied by the grant. That comparator is the only structural signal that survives the degradation, because it is the only component that still holds both sides of the comparison. ```python from dataclasses import dataclass, field from typing import Dict, Set class ScopeEnforcementDegraded(RuntimeError): """Raised when a session's cached tool grant no longer satisfies the current registry's required scopes for a tool it is permitted to call.""" @dataclass class ToolDef: name: str required_scopes: Set[str] @dataclass class Session: session_id: str grant: Set[str] registry_version: str # The degradation: this is a cached *result*, not a re-derivable input. cached_permitted_names: Set[str] = field(default_factory=set) def authorize_dispatch(session: Session, tool: ToolDef, live_registry_version: str) -> None: # Guardrail 1: registry version must match, else the cache is stale. if session.registry_version != live_registry_version: raise ScopeEnforcementDegraded( f"session {session.session_id} registry_version={session.registry_version!r} " f"!= live {live_registry_version!r}; cached name grant is unfalsifiable" ) # Guardrail 2: the name must be in the cached grant (the degraded check). if tool.name not in session.cached_permitted_names: raise ScopeEnforcementDegraded( f"tool {tool.name!r} not in session {session.session_id} cached grant" ) # Guardrail 3: the check that the degradation skipped — re-derive from # the *current* tool definition, not from the cache. missing = tool.required_scopes - session.grant if missing: raise ScopeEnforcementDegraded( f"tool {tool.name!r} requires {sorted(tool.required_scopes)} but session " f"{session.session_id} grant {sorted(session.grant)} is missing {sorted(missing)}; " f"name-set authorization would have dispatched this call" ) def audit_session(session: Session, registry: Dict[str, ToolDef], live_registry_version: str) -> None: for name in session.cached_permitted_names: tool = registry.get(name) if tool is None: raise ScopeEnforcementDegraded( f"session {session.session_id} holds cached grant for vanished tool {name!r}" ) authorize_dispatch(session, tool, live_registry_version) ```