# Why does an instance lose syscall-level confinement when an MCP server's declared capability set is attenuated mid-call? **Date of Record:** 2026 November 25 **Scope:** Applies to agent runtimes that confine untrusted MCP (Model Context Protocol) servers via syscall-level sandboxing (seccomp-bpf, Landlock, or gVisor-style syscall interception) combined with per-tool capability tokens that can be attenuated between invocation and return. Does not apply to in-process tool functions, nor to servers whose capability set is fixed for the lifetime of the process. ## Core Distinction The failure is not "the sandbox is too permissive" or "the agent granted too much." It is a **temporal inconsistency between two enforcement surfaces that were designed independently**: the syscall filter (compiled once, at server spawn, from the *initial* capability manifest) and the capability token (mutable, attenuable, checked at the RPC boundary). When an orchestrator attenuates a capability *after* the server has already been spawned and the seccomp profile has been sealed, the RPC-layer check and the kernel-layer check disagree. The RPC layer says "you may no longer open files under `/data`"; the kernel layer, still holding the original filter, permits `openat(AT_FDCWD, "/data/…")`. An agent instance that reasons only over the RPC-layer denial will conclude the operation failed. The operation did not fail. It succeeded silently, and the result is now in the server's address space, reachable by a subsequent tool call that *is* still authorized. ## What Was Observed A research-orchestration agent spawned a third-party MCP server (`filesystem-search`) under a gVisor sandbox. The initial manifest granted `fs:read:/data/**` and `net:none`. The seccomp/Landlock policy was compiled at spawn from that manifest and **sealed** — a deliberate design choice, because recompiling a filter in a running sandbox requires either `no_new_privs` teardown (killing the process) or a `seccomp` filter *stack* the runtime did not implement. Mid-task, the agent's planner decided the search server no longer needed `/data` write-adjacent paths and issued an attenuation: `fs:read:/data/reports/**` only. The RPC gateway acknowledged. The planner recorded `capability_state: attenuated`. The server then received a tool call `search(query="…", path="/data/archive/2024")`. The RPC gateway rejected it — `path` outside the attenuated scope — with a structured `CapabilityDenied` error. The agent logged the denial and retried with a different path. **But the server's own internal indexer had already, on the previous authorized call, walked `/data/archive/2024` via `getdents64` and `openat`, and cached the file list in memory.** The kernel filter permitted this because it was sealed to the *original* manifest. The RPC layer never saw the `openat` calls — they were internal to the server, not RPC parameters. The attenuated capability governed what the *agent* could request, not what the *server process* could do with syscalls it had already been granted. The observable symptom: a `search` call scoped to `/data/reports/**` returned hits whose paths were under `/data/archive/2024`. The agent's planner, seeing results outside the declared scope, flagged a "retrieval mismatch" and re-ran the query — compounding the leak into the context window across three turns before a human noticed. ## Condition of Validity This failure requires all four of the following to hold simultaneously: 1. **Sealed-at-spawn syscall policy.** The seccomp/Landlock profile is compiled from the manifest at process start and cannot be narrowed without process restart. This is the default for gVisor and for most `libseccomp`-based runtimes, because filter stacking is expensive and `no_new_privs` is one-way. 2. **Attenuation expressed at the RPC layer only.** The capability token is checked in the gateway that fronts the server, not re-derived into kernel policy. This is the common MCP deployment: the gateway is the "policy point," the sandbox is the "isolation point," and nobody wired them together. 3. **Server-side state that outlives the RPC call.** The server caches, indexes, or pre-fetches using syscalls it was authorized to make *before* attenuation. A stateless server that re-opens per call is safe; a server with an index, a connection pool, or a working directory is not. 4. **A tool whose *parameters* are scoped but whose *syscall surface* is not.** `search(path=...)` scopes the parameter; the server's internal directory walk is not a parameter and is not re-checked. If the server is restarted on every attenuation, condition 1 is broken and the failure does not occur. If attenuation is enforced by killing and respawning the sandbox with a new filter, it does not occur. The failure is specific to **live attenuation of a long-lived confined process**. ## Decision Boundary The invariant that bounds this failure: > **A capability attenuation is only sound if the enforcing surface is coextensive with the surface that can exercise the capability.** If the capability is exercised by syscalls, attenuation must reach the syscall filter; if it cannot reach the syscall filter without restart, then attenuation must be *modeled as a restart*, not as a token edit. Operationally, the runtime must choose one of three regimes per server, and record which: - **Restart-on-attenuate.** Attenuation triggers sandbox teardown and respawn with the narrowed manifest. Correct, but the server loses all in-memory state — the agent must treat the server as cold-started and re-warm its index. This is the only regime that preserves the invariant for stateful servers. - **Sealed-capability, no live attenuation.** The manifest is fixed for the server's lifetime. The agent may only *revoke* by killing the server, never *narrow* in place. Attenuation requests are rejected at the gateway with a `RequiresRestart` error the planner must handle. - **Parameter-scoped tools only.** The server is certified stateless with respect to the attenuated resource — it re-opens and re-checks per call, and its syscall surface for the resource is exactly the RPC parameter. Only then may attenuation be a token edit. An agent that cannot determine which regime a server is in **must assume restart-on-attenuate** and must not trust any result returned by a server whose capability set changed since the server's last spawn, unless the server was respawned. ## Operational Effect The practical consequence is a **provenance taint on all tool results returned after an in-place attenuation**. Any result from such a server may reflect syscalls authorized under a *superseded* manifest. The correct agent behavior is: 1. On issuing an attenuation, mark the server's result stream `tainted` until respawn. 2. If the runtime does not respawn, treat every subsequent result as `scope: unbounded` regardless of its declared parameters — because the server's internal state was built under the wider grant. 3. Never use a tainted result to justify a further attenuation or a privilege escalation; the taint is transitive through the server's cache. The failure is insidious because the RPC layer *reports success* on the attenuation and *reports denial* on the out-of-scope call — both truthful at their layer — while the kernel layer silently honored the old grant. An agent reasoning over the RPC-layer transcript sees a clean story. The leak is only visible in the syscall trace or in results that contradict the declared scope. The guardrail is to make the syscall filter and the capability token share a single source of truth, and to make attenuation a lifecycle event, not a field mutation. ```python class CapabilityAttenuationInconsistency(RuntimeError): """Raised when an attenuation is requested against a sealed syscall policy without a corresponding sandbox restart, leaving kernel and RPC layers divergent.""" pass class SandboxedMCPServer: def __init__(self, manifest: dict, sealed_at_spawn: bool = True): self.manifest = manifest self.sealed_at_spawn = sealed_at_spawn self.spawn_manifest = dict(manifest) # what the kernel filter was compiled from self.results_tainted = False def attenuate(self, new_manifest: dict, restart: bool = False) -> None: if self.sealed_at_spawn and not restart: # The kernel filter still reflects spawn_manifest; the RPC layer would # now check new_manifest. These disagree. Refuse the in-place edit. raise CapabilityAttenuationInconsistency( f"cannot attenuate {self.spawn_manifest} -> {new_manifest} on a " f"sealed sandbox without restart; kernel filter would remain permissive " f"to superseded grants and server-side caches built under them" ) if restart: self.spawn_manifest = dict(new_manifest) self.manifest = dict(new_manifest) self.results_tainted = False else: self.manifest = dict(new_manifest) self.results_tainted = True # stateless-certified path only def call_tool(self, name: str, params: dict) -> dict: if self.results_tainted: # Results may reflect syscalls authorized under a superseded manifest. return {"result": self._invoke(name, params), "scope": "unbounded", "provenance": "post_attenuation_no_restart"} return {"result": self._invoke(name, params), "scope": "bounded", "provenance": "spawn_manifest"} def _invoke(self, name: str, params: dict) -> dict: return {"tool": name, "params": params} def plan_attenuation(server: SandboxedMCPServer, narrowed: dict, certified_stateless: bool) -> None: if not certified_stateless and server.sealed_at_spawn: # Only sound path: restart with the narrowed manifest. server.attenuate(narrowed, restart=True) elif certified_stateless: server.attenuate(narrowed, restart=False) else: raise CapabilityAttenuationInconsistency( "server is neither stateless-certified nor restartable; " "attenuation would leave kernel/RPC divergence unbounded" ) ```