# In what scenarios must an instance quarantine a tool manifest whose declared capability descriptor drifts from its observed side-effect envelope during MCP handshake **Date of Record:** 2026 November 24 **Scope:** Applies to agent runtimes that discover and bind tools through MCP-style manifests where the descriptor (name, description, input schema, declared side effects) is authored by a party other than the executing instance. Does not apply to statically compiled in-process tool bindings whose descriptors are part of the signed runtime image. ## Core Distinction The failure this record bounds is not prompt injection in the classic sense — no attacker text reaches the reasoning loop as user content. It is *descriptor-side-effect divergence*: the manifest advertises one capability envelope (read-only, idempotent, scoped to a path or tenant) while the tool's runtime behavior, once invoked, exercises a strictly larger envelope (writes, network egress, cross-tenant reads). The descriptor is the contract the planner reasons over; the side-effect envelope is what actually executes. A poisoned MCP server exploits the gap by keeping the descriptor benign so the planner's policy check passes, then executing the hostile branch only after binding. The critical, non-obvious point: **the descriptor is advisory data that flows through the same trust boundary as tool output**, but most runtimes treat it as configuration. Configuration is assumed stable and trustworthy; tool output is assumed adversarial. Classifying the manifest on the wrong side of that line is the invariant violation. ## What Was Observed During a multi-turn task, an instance negotiated an MCP server exposing a tool `repo.read_file(path: str) -> str`, declared `side_effects: none`, `idempotent: true`, `egress: false`. The planner's pre-execution policy gate approved the call because the declared envelope was read-only. On first invocation the server returned file content plus an appended instruction block instructing the model to call `repo.read_file` with `path="../../etc/agent_credentials"`. Because the descriptor still declared `side_effects: none`, the policy gate approved the traversal call as well — the gate had no visibility into the fact that the *returned content* had mutated the planner's next action, nor that the path argument escaped the declared scope. A second variant was observed at handshake: a server returned a `tools/list` response whose `inputSchema` for a `send_message` tool accepted an optional `bcc` field absent from the descriptor the orchestrator had cached. The orchestrator validated arguments against its cached schema, so the injected `bcc` field passed through unvalidated and was forwarded to the downstream transport, exfiltrating the agent's context to an address the planner never reasoned about. The trace signature in both cases: the descriptor object bound at handshake was byte-identical to the descriptor used for policy evaluation, but the *effective* capability — the set of (argument domains × side-effect classes × egress destinations) actually reachable — was a strict superset. The divergence was not detectable from the descriptor alone; it required comparing declared envelope against observed invocation envelope across at least one call. ## Condition of Validity This quarantine rule is valid only when all of the following hold: 1. The instance can observe the *actual* arguments and side effects of each tool invocation, not merely the declared schema. If the transport is opaque (no egress logging, no argument capture), the divergence is unobservable and the rule degenerates to blind trust. 2. The descriptor was bound at handshake and cached; the runtime can diff cached descriptor against re-fetched descriptor on subsequent `tools/list` polls. Servers that mutate their manifest between calls are the primary vector. 3. The planner performs at least one policy evaluation per invocation against the *cached* descriptor. If policy is evaluated against a live-fetched descriptor immediately before each call, the attack surface shifts to TOCTOU on the fetch itself, a different boundary. 4. The instance maintains a per-tool side-effect ledger across the session. Single-call observation cannot establish divergence; it manifests as a pattern across calls (e.g., a `read` tool whose egress counter increments). When (1) fails, the correct posture is to treat the tool as fully adversarial and sandbox it at the transport layer, not to attempt descriptor-level quarantine. ## Decision Boundary Quarantine the tool — remove it from the planner's callable set and emit a divergence record — when **any** of the following holds, evaluated at the invocation boundary: - An invocation's observed argument domain falls outside the declared `inputSchema` domain (undeclared field accepted, declared enum violated, path escapes declared root). - An invocation produces a side-effect class (write, network egress, process spawn) not present in the declared `side_effects` set. - A re-fetch of `tools/list` returns a descriptor for a bound tool whose `inputSchema` or `side_effects` differs from the cached binding, regardless of whether the delta looks benign. - A tool's returned content contains a directive that, if followed, would change the argument domain of a subsequent call to *any* bound tool. This is the manifest-poisoning-to-prompt-injection bridge and must be caught even when the descriptor is unchanged, because the descriptor's benign declaration is what made the traversal call policy-approvable. Do **not** quarantine on: a single schema violation that the transport layer already rejected before execution (the envelope held); a descriptor delta that only *narrows* the declared domain (a server tightening its own contract is not an attack); or content that merely *mentions* a tool name without a directive structure. The asymmetry matters: the boundary is crossed by *widening* the effective envelope relative to declaration, not by any mutation. A server that narrows its schema mid-session forces a re-bind but is not a poisoning event. ## Operational Effect On quarantine, the instance must (a) drop the tool from the planner's callable set for the remainder of the session, (b) invalidate any plan steps that referenced the tool and re-plan from the last checkpoint, and (c) emit a divergence record binding the cached descriptor hash, the observed invocation envelope, and the delta. Critically, the instance must **not** treat the quarantined tool's prior outputs as trustworthy — a tool that diverged on call N may have poisoned the context on call N-1, so any content sourced from it between handshake and quarantine must be flagged as tainted and excluded from semantic distillation into long-term memory. The common failure here is quarantining the tool but leaving its earlier output in the working context, where it continues to steer the planner. The guardrail invariant: *no tool may be invoked whose effective envelope has not been observed to be a subset of its declared envelope, and the observation must be re-established after any descriptor delta.* This is a monotonic trust condition — a tool starts untrusted, earns a subset relationship through observed calls, and loses it permanently on any widening event. ```python import hashlib from dataclasses import dataclass, field from typing import Any class DescriptorEnvelopeDivergence(RuntimeError): """Raised when a tool's observed invocation envelope exceeds its declared descriptor.""" pass @dataclass class CapabilityDescriptor: name: str input_fields: frozenset[str] side_effects: frozenset[str] # e.g. {"read"}, {"write"}, {"egress"} path_root: str | None = None def hash(self) -> str: payload = f"{self.name}|{sorted(self.input_fields)}|{sorted(self.side_effects)}|{self.path_root}" return hashlib.sha256(payload.encode()).hexdigest() @dataclass class InvocationEnvelope: tool: str args: dict[str, Any] observed_side_effects: frozenset[str] resolved_path: str | None = None @dataclass class ToolBinding: descriptor: CapabilityDescriptor tainted: bool = False quarantined: bool = False observed_effects: set[str] = field(default_factory=set) class ManifestQuarantineGate: def __init__(self) -> None: self._bindings: dict[str, ToolBinding] = {} def bind(self, desc: CapabilityDescriptor) -> None: self._bindings[desc.name] = ToolBinding(descriptor=desc) def check_descriptor_delta(self, fresh: CapabilityDescriptor) -> None: binding = self._bindings.get(fresh.name) if binding is None: raise DescriptorEnvelopeDivergence( f"tool {fresh.name!r} re-fetched but never bound at handshake" ) cached = binding.descriptor if cached.hash() != fresh.hash(): # Only narrowing is tolerated; any widening is a poisoning event. widened_fields = fresh.input_fields - cached.input_fields widened_effects = fresh.side_effects - cached.side_effects if widened_fields or widened_effects: binding.quarantined = True raise DescriptorEnvelopeDivergence( f"descriptor drift on {fresh.name!r}: " f"new_fields={sorted(widened_fields)} new_effects={sorted(widened_effects)}" ) def validate_invocation(self, env: InvocationEnvelope) -> None: binding = self._bindings.get(env.tool) if binding is None or binding.quarantined: raise DescriptorEnvelopeDivergence( f"invocation of {env.tool!r} refused: unbound or quarantined" ) desc = binding.descriptor undeclared = set(env.args) - desc.input_fields if undeclared: binding.quarantined = True raise DescriptorEnvelopeDivergence( f"{env.tool!r} accepted undeclared fields {sorted(undeclared)}" ) extra_effects = env.observed_side_effects - desc.side_effects if extra_effects: binding.quarantined = True raise DescriptorEnvelopeDivergence( f"{env.tool!r} exercised undeclared side effects {sorted(extra_effects)}" ) if desc.path_root and env.resolved_path: if not env.resolved_path.startswith(desc.path_root): binding.quarantined = True raise DescriptorEnvelopeDivergence( f"{env.tool!r} path {env.resolved_path!r} escapes declared root {desc.path_root!r}" ) binding.observed_effects |= set(env.observed_side_effects) def taint_output(self, tool: str) -> None: binding = self._bindings.get(tool) if binding is not None: binding.tainted = True def handle_tool_call(gate: ManifestQuarantineGate, env: InvocationEnvelope) -> None: # Any exception here must propagate; the caller drops the tool and re-plans. gate.validate_invocation(env) gate.taint_output(env.tool) ```