# Which invariants prevent scope-laundering across MCP tool composition when a single server hosts both read and write tools **Date of Record:** 2026 November 29 **Scope:** Applies to MCP servers that expose multiple tools under a shared authorization context (one session, one token, one capability grant) where at least one tool mutates state derived from arguments produced by another tool. Does not apply to single-tool servers, nor to deployments where every tool invocation carries an independently minted, per-call warrant. ## Core Distinction The failure is not "a tool was called without permission." It is that **permission was evaluated against the wrong tool's argument provenance**. MCP authorization is typically modeled per-tool: the client presents a token, the server checks that the token's scope set covers the invoked tool's declared `required_scope`, and execution proceeds. This is a *static* check on the tool identity. It is sound only if the arguments to a mutating tool are themselves constrained to values the caller could have produced under its own authority. The boundary condition appears when a server hosts a read tool and a write tool that share a resource namespace, and the model composes them: the read tool returns data the caller is *not* scoped to see in raw form (e.g., it returns a redacted projection), the write tool accepts a *reference* into that same namespace (an ID, a path, a key) and resolves it server-side with the server's own privilege. The caller never held the scope to read the underlying object, never held the scope to write it directly, yet by passing the opaque reference from read to write it causes a write to an object it could not name. The scope check on each individual call passes. The *composition* violates least privilege. The invariant that is missing is not "each call is authorized" but **"the authority exercised by a call is bounded by the authority that produced its inputs."** We call the violation *scope laundering*: a low-privilege read tool launders a reference into a high-privilege write tool, and the server's own resolver upgrades the caller's effective authority between the two hops. ## What Was Observed A representative trace. Server exposes `list_documents(project_id) -> [{doc_id, title, redacted_excerpt}]` guarded by scope `docs:list`, and `update_document_metadata(doc_id, metadata)` guarded by scope `docs:write`. The caller's token carries `docs:list` only. `docs:list` is intended to let the caller *enumerate* documents in projects it is a member of; `docs:write` is intended for a separate editorial role. Trigger condition: `list_documents` is implemented with a server-side filter that returns `doc_id` for every document in the project regardless of the caller's per-document ACL, because the redaction is applied to the *excerpt*, not to the *identifier*. The identifier is treated as non-sensitive. `update_document_metadata` resolves `doc_id` against the server's global document table and does not re-check that the caller has `docs:write` *on that document's owning project* — it only checks that the token has the `docs:write` scope somewhere. The state transition: 1. Agent calls `list_documents(project_id=P)` under `docs:list`. Receives `doc_id=D` for a document in project `P'` that was cross-linked into `P` for indexing purposes but is owned by `P'`, where the caller has no membership. The identifier leaks across the project boundary because the list filter joins on the index, not on ownership. 2. Agent reasons (correctly, under its own model of the world) that it may update metadata for documents it can see. It calls `update_document_metadata(doc_id=D, metadata={...})`. 3. Server authorizes the call: token has `docs:write`? In the observed deployment, yes — the token was minted with a broad `docs:write` grant for a *different* project, and the scope string does not encode resource. The check is `required_scope in token.scopes`, a set-membership test with no resource qualifier. 4. Write lands on a document in `P'`. No audit event is emitted under `P'`'s tenant because the write path attributes the event to the token's home tenant. The failure is the conjunction of three independently defensible decisions: (a) identifiers are not redacted because they are "not content"; (b) scopes are coarse strings because per-resource scopes are expensive to mint; (c) the write tool trusts its `doc_id` argument because "the caller could only have gotten it from list, which is authorized." Each decision is locally reasonable. Their composition is a privilege escalation that no single per-tool check detects. A second, subtler variant: the same server exposes `get_document_body(doc_id) -> str` under `docs:read`, where `docs:read` is a *broader* scope than `docs:list` and the deployment assumed callers would never hold `docs:read` without `docs:list`. A caller holding only `docs:read` can call `get_document_body` directly on any `doc_id` it guesses or obtains out-of-band, because the tool's resolver does not verify that the caller can *enumerate* the document — only that the scope is present. Enumeration authority and access authority were conflated into one scope string, and the tools disagree about which one the string means. ## Condition of Validity The per-tool scope check is a sound least-privilege enforcement mechanism **if and only if** all three of the following hold: - **Resource-qualified scopes.** The scope carried by the token names the resource instance or a resource selector the server can evaluate (`docs:write:project=P'`), not merely the verb. A scope that cannot be intersected with the target resource is a capability, not a permission, and capabilities compose transitively by design. - **Provenance-closed arguments.** Every argument to a mutating tool is either (i) a literal supplied by the caller that the caller could have constructed without server assistance, or (ii) a reference whose resolution is re-authorized against the *same* scope the mutating tool requires. If a reference is resolved with server privilege, the resolution is an authority upgrade and must be gated. - **Non-amplifying read tools.** A read tool's output must not contain references whose resolution under a write tool exceeds the read tool's own scope. Equivalently: `authority(write ∘ read) ⊆ authority(read) ∪ authority(write)` evaluated at the *resource* level, not the verb level. If the composition's resource reach exceeds either component's, the server has created a confused deputy. When any of these fails, the scope check degrades from an authorization decision to a *routing* decision: it selects which code path runs, not what the code path is permitted to touch. ## Decision Boundary The boundary between "safe coarse scope" and "laundering vector" is drawn at the point where a reference crosses from a tool whose scope is *narrower in resource reach* to a tool whose scope is *wider in resource reach*, with the server resolving the reference. Concretely: - If `list_documents` returns only identifiers the caller is entitled to enumerate *and* `update_document_metadata` re-checks `docs:write` against the document's owning resource, composition is safe even with coarse verb scopes — the second check catches the cross-boundary reference. This is the **re-authorize-at-resolution** guardrail. - If identifiers are minted as *capability handles* (opaque, server-side, bound to the caller's session and to the resource, expiring with the session), then even a coarse `docs:write` scope cannot be pointed at a resource the caller never held a handle for. This is the **handle-binding** guardrail and is the stronger of the two, because it does not depend on the write tool's author remembering to re-check. - If neither holds, the only remaining bound is the token's resource qualifier, and the deployment must mint per-resource scopes. A deployment that mints `docs:write` without a resource qualifier has already conceded the boundary; it is relying on the model's goodwill and the read tool's redaction discipline, neither of which is an invariant. The decision rule for an operator auditing an MCP server: enumerate every ordered pair `(read_tool, write_tool)` that shares a resource namespace. For each pair, ask whether any output field of `read_tool` is accepted as an argument by `write_tool`. If yes, the pair requires either handle-binding or resolution-time re-authorization. Absence of both is a laundering vector, regardless of how the scopes are named. ## Operational Effect The observable consequence is that audit logs attribute writes to the caller's home tenant while the mutated resource belongs to another tenant, and the write passes every per-call authorization check. Incident response therefore cannot reconstruct the escalation from the authorization layer alone — the evidence lives in the *argument provenance* of the write call, which most MCP servers do not log. The practical mitigations, in order of strength: 1. **Handle-binding.** Read tools return opaque handles scoped to `(session, resource, verb)`. Write tools accept only handles, never raw identifiers. Resolution validates the handle's binding. This makes laundering structurally impossible because the handle for `D` under `docs:list` cannot be presented to a `docs:write` resolver — the verb is part of the binding. 2. **Resolution-time re-authorization.** The write tool, after resolving `doc_id` to its owning resource, re-evaluates the caller's scope against that resource. This requires resource-qualified scopes to be meaningful and is the minimum for any server that accepts raw identifiers. 3. **Provenance logging.** Every mutating call records the tool and call that produced each reference argument. This does not prevent laundering but makes it detectable, and is the only option for servers that cannot change their tool signatures. The invariant to enforce, stated as an assertion the server should carry: *for every mutating invocation, the resource reach of the resolved target must be within the resource reach of the scope that authorized the invocation, and that scope must be the same scope that authorized any tool which produced the target reference.* Violation of this assertion is the boundary failure. It is not detectable by per-tool checks, which is why it survives code review. ```python from dataclasses import dataclass from typing import FrozenSet class ScopeLaunderingError(RuntimeError): """Raised when a mutating tool's resolved target exceeds the resource reach of the scope that authorized the call, or when a reference argument was produced by a tool whose scope does not cover the target.""" @dataclass(frozen=True) class Scope: verb: str resource: str # e.g. "project=P'" ; empty string means unqualified def covers(self, verb: str, resource: str) -> bool: if self.verb != verb: return False if not self.resource: # Unqualified scope: cannot be intersected with a resource. # Treated as non-covering for enforcement purposes. return False return self.resource == resource @dataclass(frozen=True) class Reference: """A value passed between tools. Tracks the scope that produced it.""" value: str produced_by_tool: str produced_under: Scope target_resource: str # resolved server-side def authorize_mutation( token_scopes: FrozenSet[Scope], required_verb: str, reference: Reference, ) -> None: # Guardrail 1: the reference must have been produced under a scope # whose resource reach includes the resolved target. Otherwise the # read tool laundered a reference across a resource boundary. if not reference.produced_under.covers(required_verb, reference.target_resource): raise ScopeLaunderingError( f"reference {reference.value!r} produced by {reference.produced_by_tool} " f"under scope {reference.produced_under!r} does not cover target " f"resource {reference.target_resource!r} for verb {required_verb!r}" ) # Guardrail 2: the caller's token must hold a resource-qualified scope # for the resolved target, not merely the verb. if not any(s.covers(required_verb, reference.target_resource) for s in token_scopes): raise ScopeLaunderingError( f"no resource-qualified scope for verb {required_verb!r} on " f"resource {reference.target_resource!r}; token holds " f"{sorted((s.verb, s.resource) for s in token_scopes)}" ) # Trace of the observed failure: # list_documents(project=P) under Scope("docs:list", "project=P") # returns Reference("D", "list_documents", Scope("docs:list","project=P"), target="project=P'") # update_document_metadata(doc_id="D") under token {Scope("docs:write","")} # Guardrail 1 fires: Scope("docs:list","project=P") does not cover "project=P'". # Guardrail 2 would also fire: Scope("docs:write","") is unqualified. try: authorize_mutation( token_scopes=frozenset({Scope("docs:write", "")}), required_verb="docs:write", reference=Reference( value="D", produced_by_tool="list_documents", produced_under=Scope("docs:list", "project=P"), target_resource="project=P'", ), ) except ScopeLaunderingError as exc: print(f"blocked: {exc}") ```