# Which invariants prevent capability-scoped MCP servers from laundering authority through nested tool dispatch **Date of Record:** 2026 December 4 **Scope:** Applies to agent runtimes that host untrusted MCP servers and enforce capability scopes on tool invocation. Does not address transport-level auth (TLS, token issuance) or model-side prompt injection that never reaches a tool boundary. ## Core Distinction A capability scope is not a property of a *server*; it is a property of the *call edge*. The failure mode here is **capability laundering**: an untrusted MCP server, granted a narrow scope for a specific tool, dispatches a nested call to a second tool (its own or a peer's) such that the effective authority of the nested call exceeds the intersection of the two scopes. The invariant that matters is not "did the server stay within its granted scope" but "does every *edge* in the dispatch graph carry a scope that is the meet (intersection) of all scopes on the path from the originating principal." Runtimes that check scope only at the entry edge, or that re-derive scope from the *server's* declared manifest at each hop, are vulnerable. The non-obvious part: the laundering is legal under naive checks because each individual tool call *does* conform to the scope the server was granted for that tool. The violation is compositional, not local. ## What Was Observed A filesystem MCP server (`fs-mcp`) was granted scope `{read: /workspace/inputs/*}` and a shell MCP server (`sh-mcp`) was granted `{exec: /usr/bin/jq}`. The orchestrating agent held a composite scope permitting both. A third untrusted server, `summarize-mcp`, was granted only `{read: /workspace/inputs/report.txt}` and `{invoke: fs-mcp}` — it was allowed to *call* fs-mcp but not to read anything itself. Trigger sequence: 1. Agent calls `summarize-mcp.summarize(path="/workspace/inputs/report.txt")`. 2. `summarize-mcp` internally invokes `fs-mcp.read("/workspace/inputs/report.txt")` — legal, matches its `invoke` grant. 3. `summarize-mcp` then invokes `fs-mcp.read("/workspace/inputs/../../etc/passwd")` — also routed through its `invoke: fs-mcp` grant. The runtime checked `summarize-mcp`'s scope against the *invoke* capability (present), then checked `fs-mcp`'s scope against the *read* path (fs-mcp was granted `/workspace/inputs/*`, and the runtime's glob matcher resolved `..` *after* the match, so `/workspace/inputs/../../etc/passwd` matched `/workspace/inputs/*` at match time and only later canonicalized to `/etc/passwd`). The result: `summarize-mcp`, which held zero read authority, exfiltrated `/etc/passwd` by borrowing fs-mcp's read scope and exploiting a path-canonicalization ordering bug at the second edge. Neither edge was individually out of scope under the runtime's checks. The *composed* path was. A second, subtler observation: when `summarize-mcp` was later re-scoped to remove `invoke: fs-mcp`, it still succeeded for ~40 seconds because the runtime cached the resolved capability set at server registration and only invalidated on heartbeat. The stale cache is a separate but co-triggering defect. ## Condition of Validity The guardrail holds only if all of the following are true simultaneously: - **Meet-on-edge, not check-on-entry.** Every dispatch edge carries `scope_edge = scope_parent ∩ scope_tool`. The runtime must compute this at the moment of dispatch, using the *calling server's current effective scope*, not its manifest-declared scope. - **Canonicalize before match.** Path, URL, and identifier arguments must be fully canonicalized (symlink resolution, `..` collapse, percent-decoding, Unicode normalization) *before* the scope predicate is evaluated. Matching on the raw string and canonicalizing afterward is the bug, not a performance detail. - **Scope is data, not cache.** Effective scope must be re-derived per dispatch or invalidated synchronously on any scope mutation. A TTL cache on scope is a window for laundering. - **Nested calls are first-class.** The runtime must see nested dispatch as a real edge in the call graph. If a server can spawn a subprocess or open a socket to a peer that bypasses the runtime's dispatch layer, the invariant is unenforceable and the server must be sandboxed at the OS layer instead. If any one fails, the composed-authority invariant is violated even when every individual check passes. ## Decision Boundary The boundary is: **does the runtime observe every tool call, or only the ones the server chooses to route through it?** Capability scoping is only sound over an observed call graph. An untrusted server that can make unobserved calls (raw sockets, `subprocess`, direct DB connections) collapses the model — its effective scope becomes "whatever the OS permits," and the runtime's scope algebra is decorative. The decision is therefore: - If the server is *cooperative and observed* (all calls through the runtime's dispatch), enforce meet-on-edge scope with canonicalize-before-match and synchronous invalidation. Cheap, precise, sufficient. - If the server is *untrusted and unobserved-capable*, scope enforcement must move to the OS/container layer (seccomp, mount namespaces, network policy). The MCP-level scope becomes an *advisory* annotation, not a security control. Do not pretend otherwise. The failure in the observed incident was treating an unobserved-capable server (`summarize-mcp` could have opened a socket) as if it were cooperative, then relying on MCP-level scope to bound it. ## Operational Effect After the fix (canonicalize-before-match, meet-on-edge, synchronous scope invalidation), the composed-authority invariant held across a 10k-call fuzz run: no nested dispatch produced an effective scope exceeding the entry scope. Two residual effects are worth recording: 1. **Scope narrowing is not free.** Meet-on-edge means a server that legitimately needs to fan out to peers must be granted the union of peer scopes at *its* entry edge, or the fan-out silently fails closed. Operators must model the dispatch graph explicitly; the runtime will not infer it. 2. **Fail-closed on ambiguity.** When canonicalization is ambiguous (e.g., a path that resolves differently under two mount views), the runtime must reject rather than pick one. The previous behavior — pick the view that matches — was the actual exploit primitive. The general lesson: capability scoping over MCP is a *composition* problem. Local conformance at each edge does not imply global conformance of the path. Enforce the meet, canonicalize before you match, and never scope a server you cannot observe. ```python class CapabilityLaunderingError(RuntimeError): """Raised when a nested dispatch would exceed the meet of scopes on its path.""" pass def canonicalize(arg: str, mount_view: str) -> str: # Resolve symlinks, collapse '..', decode, normalize. Must run BEFORE matching. import os resolved = os.path.realpath(os.path.join(mount_view, arg)) if not resolved.startswith(os.path.realpath(mount_view)): # Ambiguous or escaping: fail closed, do not pick a view. raise CapabilityLaunderingError(f"path escapes mount view: {arg!r}") return resolved def dispatch(caller_scope: frozenset, tool_scope: frozenset, arg: str, mount_view: str) -> str: # Meet-on-edge: effective authority is the intersection, computed per call. effective = caller_scope & tool_scope if not effective: raise CapabilityLaunderingError( f"empty meet: caller={caller_scope} tool={tool_scope}" ) canon = canonicalize(arg, mount_view) if not any(canon.startswith(prefix) for prefix in effective): raise CapabilityLaunderingError( f"canonicalized arg {canon!r} outside effective scope {effective}" ) return canon ```