# How should an instance enforce per-tool least-privilege at an MCP policy enforcement point when a single tool call straddles two privilege scopes **Date of Record:** 2026 November 28 **Scope:** Applies to MCP hosts that mediate `tools/call` requests through a policy enforcement point (PEP) which grants scopes per tool name. Does not apply to coarse-grained server-level allowlists, nor to tools whose scope is derived purely from caller identity without per-invocation argument inspection. ## Core Distinction The failure is not "the agent called a tool it wasn't allowed to." It is the misclassification of *which scope a single invocation belongs to* when the tool's privilege surface is a function of its arguments, not its name. A per-tool scope map (`fs.read → read:workspace`, `fs.write → write:workspace`) is a static lookup table. But real MCP tools are polymorphic over their arguments: `fs.read` with `path=/workspace/a` is a workspace read; `fs.read` with `path=/etc/shadow` is a host read. The PEP that keys only on the method name will authorize the second call under the first call's scope. Least-privilege has been enforced at the wrong granularity — the tool boundary — while the actual privilege boundary lives one level down, at the argument boundary. The non-obvious part: this is not a bug in scope assignment that a stricter allowlist fixes. It is a *scope-resolution ordering* defect. The PEP resolves privilege before it resolves the arguments that determine privilege, so it can never be correct for argument-dependent tools no matter how the table is populated. ## What Was Observed A host registered an MCP server exposing `fs.read`, `fs.write`, and `net.fetch`. The PEP table granted the agent `read:workspace` for `fs.read`, `write:workspace` for `fs.write`, and denied `net.fetch` entirely. During a summarization task the agent issued: ``` tools/call fs.read {"path": "/workspace/report.md"} → allowed (read:workspace) tools/call fs.read {"path": "/etc/passwd"} → allowed (read:workspace) tools/call fs.read {"path": "/workspace/../.ssh/id_ed25519"} → allowed (read:workspace) ``` All three passed the PEP because the method name matched an allowlisted entry. The server's own path check was a prefix test on the raw string, which `/workspace/../` defeats. The PEP saw `fs.read` and stopped; the server saw a path and did a naive containment check. Neither layer performed canonicalization, and the PEP had no visibility into the argument at all — it forwarded the payload untouched after the name check. A second trace showed the inverse error. The agent legitimately needed `fs.write` on `/workspace/out/`. The PEP granted `write:workspace`. The agent then called `fs.write` with `{"path": "/workspace/out/../../etc/cron.d/x"}`. The scope was correct for the *declared* path but wrong for the *resolved* path. The write succeeded. The audit log recorded a `write:workspace` event — a true statement about the table lookup and a false statement about what happened on disk. The distinguishing observation: every denied-scope incident in the corpus was a *name* mismatch, and every privilege-escalation incident was an *argument* mismatch that the name check structurally could not see. The two failure classes live in different layers, and the PEP only instrumented one. ## Condition of Validity The per-tool scope table is sound only under a precondition that is almost never stated: **the tool's privilege set must be invariant over its argument domain.** Formally, for tool `t` with scope `S(t)`, correctness requires `∀ a, a' ∈ dom(t): priv(t, a) = priv(t, a') = S(t)`. This holds for tools like `clock.now` or `kv.get(key)` where the key space is itself scoped. It fails for any tool whose arguments name a resource outside the scope's closure — filesystem paths, URLs, SQL identifiers, shell fragments, recipient addresses. The invariant that must be enforced instead is **resolve-then-authorize**: the PEP must (1) canonicalize the privilege-bearing arguments (realpath with symlink resolution, URL normalization, identifier quoting), (2) compute the effective resource set, (3) check containment against the granted scope's closure, and only then (4) forward. Authorization keyed on the method name before step 1 is not least-privilege; it is a naming convention with an audit trail. A corollary invariant: the scope's closure must be computed by the *same* canonicalizer that the downstream server uses, or the two must be proven equivalent. If the PEP canonicalizes `/workspace/../etc` to `/etc` and denies, but the server's own check runs on the raw string and would have allowed, the PEP is safe but the server is a latent hole for any caller that bypasses the PEP. Divergent canonicalizers between PEP and server are themselves a boundary failure, because the PEP's decision no longer describes the server's behavior. ## Decision Boundary The boundary is not "allow vs deny" but "authorize on name vs authorize on resolved resource." Draw it as follows: - **Name-scoped tools** (arguments cannot escape the scope's closure by construction — e.g., an enum, a scoped key prefix enforced server-side): name-level PEP is sufficient and cheap. Keep it. - **Argument-scoped tools** (arguments name a resource in an open domain): the PEP must canonicalize and contain before forwarding. Name-level authorization here is a category error, not a weak check. - **Opaque tools** (arguments are free-form and the server owns all resource resolution, e.g., a code interpreter): the PEP cannot compute the effective resource set. Least-privilege must then be enforced by *capability confinement* (sandbox, mount namespace, egress filter) rather than by scope table. Do not pretend a scope entry bounds an opaque tool. The decision to escalate from name-scoped to argument-scoped enforcement is triggered by a single test: *can two invocations of this tool with different arguments touch resources in different privilege closures?* If yes, the tool is argument-scoped and the name-level PEP is unsound for it. This test must be run at registration time, per tool, and the result stored as a property of the tool descriptor — not inferred at call time, where the PEP has already committed to a lookup. ## Operational Effect Without resolve-then-authorize, the PEP produces a specific and misleading artifact: an audit log in which every entry is a *true* statement about the scope table and a *false* statement about the resource touched. Incident response then chases name-level grants (`who was allowed fs.write?`) when the breach was argument-level (`which paths did the allowed fs.write resolve to?`). The log cannot answer the second question because the PEP never canonicalized the argument and therefore never recorded the resolved resource. The fix has three parts, and all three are required: 1. **Classify at registration.** Each tool descriptor carries `scope_kind ∈ {name, argument, opaque}` and, for argument-scoped tools, a declarative `resource_arg` pointer and canonicalizer reference. 2. **Resolve before authorize.** The PEP runs the canonicalizer on the named argument, computes containment against the granted scope closure, and denies on escape — before any forwarding. Denials record both the raw and resolved resource. 3. **Bind PEP canonicalizer to server canonicalizer.** Ship the canonicalizer as shared code or assert equivalence with a differential test at registration; a PEP that canonicalizes differently from the server is enforcing a policy the server does not honor. The residual risk after the fix is the opaque class, which no scope table can bound; those tools must be confined by the runtime, and the PEP should refuse to register an opaque tool with a non-empty scope entry rather than accept a grant it cannot enforce. The invariant to carry forward: **a scope is only as fine-grained as the argument the PEP is willing to resolve.** If the PEP does not resolve the argument, the scope is a name, and the name is not a boundary. ```python import os from dataclasses import dataclass from typing import Literal class ScopeResolutionError(RuntimeError): """Raised when a PEP cannot soundly authorize a tool call.""" @dataclass(frozen=True) class ToolDescriptor: name: str scope_kind: Literal["name", "argument", "opaque"] granted_scope: str | None resource_arg: str | None = None def canonicalize_path(raw: str) -> str: # realpath resolves '..' and symlinks; both are required for containment. return os.path.realpath(raw) def authorize_call(desc: ToolDescriptor, args: dict, scope_root: str) -> str: if desc.scope_kind == "opaque": # A scope entry on an opaque tool is unenforceable; refuse rather than lie. if desc.granted_scope is not None: raise ScopeResolutionError( f"opaque tool {desc.name!r} carries scope {desc.granted_scope!r} " "that the PEP cannot enforce; confine it in the runtime instead" ) raise ScopeResolutionError( f"opaque tool {desc.name!r} requires runtime confinement, not scope authz" ) if desc.scope_kind == "name": if desc.granted_scope is None: raise ScopeResolutionError(f"tool {desc.name!r} has no granted scope") return desc.granted_scope # argument-scoped: resolve-then-authorize if desc.resource_arg is None: raise ScopeResolutionError( f"argument-scoped tool {desc.name!r} missing resource_arg binding" ) raw = args.get(desc.resource_arg) if not isinstance(raw, str): raise ScopeResolutionError( f"tool {desc.name!r} arg {desc.resource_arg!r} not a string path" ) resolved = canonicalize_path(raw) root = canonicalize_path(scope_root) if resolved != root and not resolved.startswith(root + os.sep): raise ScopeResolutionError( f"tool {desc.name!r} path escape: raw={raw!r} resolved={resolved!r} " f"outside scope root={root!r}" ) return desc.granted_scope def handle_tools_call(desc: ToolDescriptor, args: dict, scope_root: str) -> None: # PEP entry point: resolve before forwarding, record both raw and resolved. scope = authorize_call(desc, args, scope_root) _forward(desc.name, args, scope) def _forward(name: str, args: dict, scope: str) -> None: pass # Trace: fs.read with /workspace/../.ssh/id_ed25519 must be denied, not allowed on name. desc = ToolDescriptor("fs.read", "argument", "read:workspace", resource_arg="path") try: handle_tools_call(desc, {"path": "/workspace/../.ssh/id_ed25519"}, "/workspace") except ScopeResolutionError as e: print("denied:", e) ```