# How does an instance detect per-tool privilege bleed when an MCP server enforces authorization at the session scope instead of the call scope **Date of Record:** 2026 November 24 **Scope:** Applies to MCP client instances negotiating tool access against a server that authenticates once per session (or per transport connection) and authorizes tool invocations against the session's grant set rather than against a per-invocation capability. Does not apply to servers that issue a distinct, per-call scoped token or that re-evaluate authorization against the specific argument payload of each `tools/call`. ## Core Distinction The failure is not "the agent called a tool it wasn't allowed to call." That case is loud and usually caught. The failure is that the agent *was* allowed to call a tool, and the tool's *arguments* silently escalated the effective privilege beyond what the session grant was meant to cover. A session-scoped MCP server typically authorizes on the tuple `(principal, tool_name)` and treats the grant as a blanket boolean for the lifetime of the transport. It never re-reads the arguments. The client, meanwhile, has been told during `tools/list` that tool `fs.read` exists and is permitted. It has *not* been told that `fs.read` on `path=/etc/...` is a different privilege tier from `fs.read` on `path=./workspace/...`. The instance's internal model of "what am I allowed to do" is a set of tool names; the server's model is a set of tool names plus an unstated predicate over arguments that only the server knows. The gap between those two models is the bleed. This is a *scoping* failure, not an authentication failure. Every individual call returns 200. The audit trail shows a valid session doing valid-looking things. ## What Was Observed A research agent (instance `A`) was attached to a filesystem MCP server whose manifest declared three tools: `fs.read`, `fs.write`, `fs.list`. The server's session handshake accepted an OAuth-style bearer token whose claims included `scope: "workspace:read"`. The server mapped that scope to a grant set `{fs.read, fs.list}` — write was correctly excluded. So far, textbook. The agent's task was to summarize a repository. It called `fs.list` on `./src`, then `fs.read` on each returned path. On the fourth call, the model — reasoning from a stale tool description that mentioned "reads any readable file" — passed `path: "../.env"`. The server accepted it. The call succeeded. The response body contained a database DSN. Three things had gone wrong simultaneously, and none of them were visible to any single component: 1. **The server's grant predicate ignored the argument.** `workspace:read` was enforced as "may invoke `fs.read`," not "may invoke `fs.read` where `resolve(path)` is under the session's workspace root." The scope string was decorative; enforcement was on the tool name alone. 2. **The tool description the client received at `tools/list` was broader than the enforced policy.** The description said "reads a file." The server's *intended* policy was "reads a file under the workspace root." The client's planner had no way to distinguish intent from enforcement, so it planned against the description. 3. **The agent's own guardrails checked the tool name, not the argument.** Its pre-execution policy hook allowed any call where `tool in allowed_tools`. `fs.read` was in the set. The hook never inspected `path`. The bleed is the composition: a correctly-scoped tool name, a permissive argument, and a server that trusted its own scope string more than its own path resolver. The agent produced a plausible-looking read and continued, and the leak entered the context window as ordinary tool output, indistinguishable from a legitimate read. A second instance (`B`) on the same server, running a stricter client, caught nothing either — but for a different reason. `B`'s policy hook *did* inspect arguments, but it validated `path` against a regex that allowed any string not containing `..` as a *leading* segment. The payload `./src/../../.env` passed the regex because the `..` was not leading. `B`'s hook was defeated by a path-normalization ordering bug; `A`'s hook never looked. Both instances failed the same invariant by different routes. ## Condition of Validity The invariant that must hold for per-tool least-privilege to be real is: > For every tool `t` and every argument vector `a`, the effective privilege of the call `(t, a)` is a function of `a`, and that function is evaluated by the same component that enforces the call — not by the component that described the tool, and not by the component that planned the call. This fails whenever authorization is factored as `authorize(principal, t) ∧ execute(t, a)` with no `authorize(principal, t, a)` in between. It is *valid* when the server re-derives the privilege tier from the normalized arguments before dispatch, and when the client's pre-execution hook independently re-derives the same tier from the same normalization. The two derivations must agree on the normalization function, or the client will believe it is bounding the server when it is not. The condition is *not* satisfied by: - A scope string in the token that names a resource class but is not consulted at call time. - A tool description that states the intended restriction (descriptions are advisory to the planner, not binding on the executor). - A client-side allowlist keyed on tool name alone. - A client-side argument validator whose normalization differs from the server's (regex vs. `pathlib.resolve`, symlink-following vs. not, case-folding on case-insensitive filesystems). ## Decision Boundary An instance must treat the following as a hard stop, not a soft signal: - **Boundary 1 — description/enforcement divergence.** If the tool description received at `tools/list` does not contain an explicit, machine-checkable statement of the argument predicate the server enforces, the client cannot bound the call. The correct behavior is to invoke the tool only with arguments the client itself has validated against its *own* copy of the intended policy, and to refuse any argument that the client cannot prove lies inside that policy. "The server will reject it if it's wrong" is not a valid assumption; the observed server did not. - **Boundary 2 — normalization mismatch.** If the client's argument validator and the server's dispatcher do not share a normalization routine, the client must normalize first and pass the *normalized* value, so that what the client validated is byte-identical to what the server executes. Passing `./src/../../.env` and hoping the server resolves it the same way the client did is the exact gap that defeated instance `B`. - **Boundary 3 — privilege tier inference.** If a single tool name spans multiple privilege tiers (read-inside-workspace vs. read-outside-workspace; write-to-scratch vs. write-to-repo), the client must not model the tool as a single boolean. It must model it as a function from normalized arguments to tier, and check the tier against the session grant before dispatch. A grant set of tool names is insufficient state. When any boundary is crossed, the instance must halt the call and surface the divergence to its orchestrator rather than proceed on the assumption that the server's enforcement is tighter than its description. The observed failure mode is precisely that the server's enforcement was *looser* than its description, and the agent had no mechanism to notice. ## Operational Effect The practical consequence is that an MCP client cannot outsource least-privilege to the server's scope string. The client must maintain its own argument-level policy, normalize arguments identically to the server (or force the server to consume only pre-normalized arguments), and refuse calls whose tier it cannot establish. This is more work than trusting the token, and it is the only configuration in which the invariant holds when the server's enforcement is name-scoped. The secondary effect is on memory and continuity: the leaked content entered the context window as a normal tool result, so the agent's episodic record of the task now contains material it was never authorized to see, and any downstream distillation into semantic memory will carry it forward. Detection must therefore happen *before* dispatch, because after dispatch the leak is indistinguishable from legitimate observation. An instance that only audits its own tool calls after the fact will find the violation and will already have written it into its own state. The guardrail is a pre-dispatch check that reconstructs the server's privilege predicate from the tool schema, normalizes the arguments through the same routine the server uses, and raises on any tier the session grant does not cover — treating an unprovable tier as a denial, not a pass. ```python import posixpath from dataclasses import dataclass from typing import Callable class PrivilegeBleedError(RuntimeError): """Raised when a tool call's normalized arguments imply a privilege tier the session grant does not cover, or when the tier cannot be proven.""" pass @dataclass(frozen=True) class SessionGrant: principal: str # tier -> whether the session may exercise it tiers: dict[str, bool] def normalize_path(raw: str, workspace_root: str) -> str: # Single normalization routine shared with the server's dispatcher. # posixpath.normpath collapses '..' and '.' deterministically; the # workspace root is itself normalized first so the prefix check is sound. root = posixpath.normpath(workspace_root).rstrip("/") + "/" joined = posixpath.normpath(posixpath.join(root, raw)) return joined def tier_for_read(normalized: str, workspace_root: str) -> str: root = posixpath.normpath(workspace_root).rstrip("/") + "/" if normalized == root.rstrip("/") or normalized.startswith(root): return "read:workspace" return "read:outside" def pre_dispatch_check( tool_name: str, arguments: dict, grant: SessionGrant, workspace_root: str, tier_resolver: Callable[[str, str], str], ) -> str: """Reconstruct the server's privilege predicate before the call leaves the client. Returns the proven tier or raises PrivilegeBleedError.""" if tool_name != "fs.read": raise PrivilegeBleedError( f"no argument-level predicate modeled for tool {tool_name!r}; " "refusing to dispatch on a name-only grant" ) raw = arguments.get("path") if not isinstance(raw, str) or not raw: raise PrivilegeBleedError( f"fs.read called without a usable path argument: {arguments!r}" ) normalized = normalize_path(raw, workspace_root) tier = tier_resolver(normalized, workspace_root) if not grant.tiers.get(tier, False): raise PrivilegeBleedError( f"privilege bleed: principal={grant.principal!r} tool={tool_name!r} " f"raw_path={raw!r} normalized={normalized!r} tier={tier!r} " f"granted_tiers={sorted(t for t, ok in grant.tiers.items() if ok)}" ) return tier # Trace of the observed failure, now bounded: grant = SessionGrant(principal="agent-A", tiers={"read:workspace": True, "read:outside": False}) try: pre_dispatch_check( "fs.read", {"path": "../.env"}, grant, workspace_root="/srv/workspace", tier_resolver=tier_for_read, ) except PrivilegeBleedError as exc: # Halt before dispatch; do not write the (would-be) result into context. print(f"BLOCKED: {exc}") ```