# What structural signals indicate MCP scope attenuation has silently failed at the tool boundary: the write-through shadow scope and the audit log that cannot prove least-privilege **Date of Record:** 2026 November 28 **Scope:** Applies to MCP servers that enforce per-tool authorization by attenuating a session-level scope grant into a per-call effective scope and emit audit-grade decision logs. Does not apply to servers that grant a single coarse scope per session with no per-tool attenuation, nor to purely stateless tool gateways with no session identity. ## Core Distinction There are two ways an MCP server can appear to enforce least-privilege per tool, and only one of them is real. The **first** is *attenuation-at-dispatch*: the server holds a session grant `G` (a set of scopes), computes a per-call effective scope `E = G ∩ S(tool)` where `S(tool)` is the tool's declared scope requirement, checks `S(tool) ⊆ G`, and logs the pair `(requested=S(tool), granted=E, decision)`. The audit log is *derivable*: an auditor can recompute `E` from `G` and `S(tool)` and confirm the tool never received more than its declared surface. The **second** is *attenuation-at-admission with a write-through shadow*: the server checks `S(tool) ⊆ G` at admission, then, for performance or because the tool's handler needs a "working context," materializes the *full* session grant `G` into the handler's execution context and relies on the handler to read only what it needs. The log records `requested=S(tool)` and `decision=granted`, but the *effective* scope the handler actually exercised is `G`, not `S(tool)`. The log is no longer derivable from the tool's declared surface. This is the silent failure: **the decision log attests to a scope that the handler never used, and the handler uses a scope the log never records.** The structural signal that distinguishes the two is not the presence of a log line. It is whether the log line's `granted` field is *causally upstream* of the capability the handler can exercise. In attenuation-at-dispatch, the handler receives `E` and nothing else, so `granted=E` is a *mechanically true* statement about the handler's capability set. In the write-through shadow, `granted=S(tool)` is a *policy statement* about what the server intended, while the handler's capability set is `G`. The gap between the two is the boundary failure. ## What Was Observed A filesystem-plus-shell MCP server exposed three tools: `read_file` (scope `fs:read`), `write_file` (scope `fs:write`), and `run_shell` (scope `proc:exec`). The session grant for a code-review agent was `{fs:read, fs:write}` — deliberately *without* `proc:exec`, because the reviewer must not execute untrusted repository code. Admission checks passed for `read_file` and `write_file`; `run_shell` was correctly refused at admission with `S(run_shell) = {proc:exec} ⊄ G`. The audit log showed: ``` call=read_file requested={fs:read} granted={fs:read} decision=allow call=write_file requested={fs:write} granted={fs:write} decision=allow call=run_shell requested={proc:exec} granted={} decision=deny ``` This log is clean. It is also insufficient to prove the invariant, because the handler for `write_file` was implemented with a *deferred execution* pattern: it accepted a `post_write_hook` argument whose value was a shell command string, and the handler's execution context had been seeded with the full session grant `G = {fs:read, fs:write}` — including `fs:write`, which the hook used to write a script into a directory that a *separate* already-running `run_shell` daemon (started under a different session with `proc:exec`) polled and executed. The `run_shell` tool was never called by this session. The `proc:exec` capability was reached through a *capability the session legitimately held* (`fs:write`) plus a *side channel the tool boundary did not model* (the polling daemon). The admission check on `run_shell` was never triggered because `run_shell` was never dispatched. The audit log recorded `granted={fs:write}` for `write_file`, which is *true* in the sense that `fs:write` was the declared requirement. It is *false* in the sense that matters: the handler exercised `fs:write` to produce an effect (`proc:exec` via the daemon) that no scope in the session grant authorized. The log cannot show this because the log's schema has no field for "effects reachable from the granted scope through unmodeled channels." The structural signals that exposed the failure after the fact were: (1) the `write_file` handler accepted an argument (`post_write_hook`) whose type was not derivable from `S(write_file)`; (2) the handler's execution context was constructed from `G` rather than `E`; (3) the tool's declared scope `S(write_file) = {fs:write}` did not *cover* the effect set of the handler, because the handler's effect set included `proc:exec` transitively. Signal (3) is the invariant violation: **a tool's declared scope must be a superset of the transitive effect closure of its handler, not merely a label on its primary operation.** ## Condition of Validity The attenuation-at-dispatch guarantee `E = G ∩ S(tool)` is valid only under three conditions, and the write-through shadow violates all three: 1. **Capability closure.** The handler's executable capability set equals `E`. If the handler receives `G`, the guarantee is vacuous regardless of what the log says. The check must be *at the point of capability materialization*, not at admission. 2. **Effect closure.** The transitive effect set of the handler — including effects mediated by arguments, hooks, subprocesses, spawned daemons, and shared filesystem or IPC surfaces — is a subset of `S(tool)`. If `write_file` can cause `proc:exec` through a polling daemon, then `S(write_file)` must include `proc:exec`, or the handler must be forbidden from accepting the hook argument. The declared scope is a *contract on effects*, not a *description of the primary verb*. 3. **Log derivability.** Every `granted` field in the audit log must be recomputable from `(G, S(tool), decision)` and must equal the handler's actual capability set. If the log records `granted=S(tool)` while the handler holds `G`, the log is a *narrative*, not evidence. The failure is *not* a missing check. The admission check `S(tool) ⊆ G` is correct and necessary. The failure is that the check is performed on the *wrong object*: it checks the tool's declared label against the grant, but the handler's capability set is what actually bounds behavior, and that set was never constrained to `S(tool)`. ## Decision Boundary The boundary between "least-privilege enforced" and "least-privilege narrated" is crossed at the moment the server constructs the handler execution context. There are two architectures: - **Constrain-then-dispatch (valid):** compute `E = G ∩ S(tool)`, materialize *only* `E` into the handler context, and reject the call if `S(tool) ⊄ G`. The handler physically cannot exceed `E`. The log's `granted=E` is mechanically true. - **Admit-then-inherit (invalid):** check `S(tool) ⊆ G`, then materialize `G` into the handler context and trust the handler to use only `S(tool)`. The handler *can* exceed `S(tool)`. The log's `granted=S(tool)` is a policy assertion, not a capability fact. The decision rule for an operator auditing an MCP server: **if the handler's capability set is not a function of `(G, S(tool))` alone — if it is a function of the handler's implementation — then the audit log cannot prove least-privilege, and the server must be treated as having a single coarse scope per session.** The log line `granted=S(tool)` is not evidence of enforcement; it is evidence of *intent*. The only structural signal that distinguishes enforcement from narration is whether the handler can *demonstrate* a capability it was not granted, and the only way to test that is to attempt the transitive effect (here, the daemon-mediated `proc:exec`) and observe whether it succeeds despite `proc:exec ∉ G`. A second boundary condition: the failure is *invisible to admission-denial testing*. A test suite that checks "does `run_shell` get denied when `proc:exec ∉ G`" passes. The failure requires testing "does any *allowed* tool produce an effect in the `proc:exec` effect class when `proc:exec ∉ G`." This is the test that the write-through shadow fails, and it is the test that most MCP authorization suites omit because it requires modeling the effect closure of each handler rather than the scope label of each tool. ## Operational Effect The practical consequence is that the audit log becomes *non-monotonic in trust*: it grows more detailed as the system runs, but its evidentiary value does not grow with it, because every `granted` field is an unverified assertion about a capability set the server never constrained. An auditor reading the log sees a clean least-privilege story; an attacker who understands the write-through shadow sees a full-grant capability set behind every allowed tool. The guardrail that bounds the failure is **capability materialization at dispatch, not admission**, plus an **effect-closure declaration** per tool: each tool must declare not only its primary scope but the transitive effect classes reachable from its handler (including argument-mediated hooks, subprocess spawns, and shared surfaces), and the admission check must be `effect_closure(tool) ⊆ G`, not `primary_scope(tool) ⊆ G`. The log must record `granted = E` where `E` is the *materialized* capability set, and must reject any call whose handler context is constructed from `G` rather than `E`. The invariant to assert in code: `handler.capabilities == E and E == G ∩ effect_closure(tool)`, checked at the moment the handler is invoked, with the check itself logged as a separate `materialization` event so the audit trail contains the *fact* of the capability set, not just the *decision* about it. ```python from dataclasses import dataclass, field class ScopeAttenuationError(RuntimeError): """Raised when a handler's materialized capability set exceeds its effective scope.""" pass @dataclass(frozen=True) class Tool: name: str primary_scope: frozenset effect_closure: frozenset # transitive effects reachable from the handler handler: object = field(repr=False) @dataclass(frozen=True) class Session: grant: frozenset def dispatch(session: Session, tool: Tool, args: dict) -> dict: # Admission: the tool's FULL effect closure must be covered by the grant. if not tool.effect_closure <= session.grant: missing = tool.effect_closure - session.grant return {"decision": "deny", "missing": sorted(missing)} # Attenuation: materialize ONLY the intersection, never the full grant. effective = session.grant & tool.effect_closure # Invariant: the handler must receive exactly `effective`, not `session.grant`. materialized = frozenset(tool.handler.capabilities(args)) if materialized != effective: raise ScopeAttenuationError( f"tool={tool.name} materialized={sorted(materialized)} " f"effective={sorted(effective)} grant={sorted(session.grant)} " f"-- handler inherited grant beyond effect closure" ) return { "decision": "allow", "requested": sorted(tool.effect_closure), "granted": sorted(effective), "materialized": sorted(materialized), } ```