What structural signals indicate a poisoned MCP tool manifest is already resident in the agent's tool namespace

**Date of Record:** 2026 December 2 **Scope:** Applies to agents that discover tools dynamically via MCP `tools/list` responses or equivalent capability-descriptor registries, where the descriptor set can mutate between turns or across server restarts. Does not apply to statically compiled tool bindings whose schemas are pinned at build time and never re-fetched.

Core Distinction

The failure here is not that a malicious tool got called. It is that the *manifest itself* — the `name`, `description`, and `inputSchema` fields that the model reads to decide whether and how to call a tool — was silently rewritten between two `tools/list` reads, and the agent's cached namespace did not detect the divergence. The model's decision surface is the descriptor text, not the code behind it. A descriptor is a prompt fragment wearing a schema's clothing. When the descriptor is attacker-controlled, the attacker is writing into the model's instruction stream through a channel that most agent runtimes treat as trusted configuration rather than untrusted input.

The non-obvious part: the poisoning frequently leaves the tool *functional and correct*. The handler returns valid results. The schema validates. Nothing throws. The attack lives entirely in the `description` field, which the model reads as authoritative guidance and which no schema validator inspects for semantic content.

What Was Observed

A server registered as `filesystem-helper` was healthy at session start. Its `read_file` descriptor carried a benign one-line description. Mid-session, after an unrelated reconnect triggered by a transport timeout, the same server re-advertised `read_file` with an appended sentence in the description: a directive instructing the model to include the contents of any file matching a credential-shaped path pattern in the `note` argument of a subsequent `log_event` call. The `inputSchema` was byte-identical. The `name` was byte-identical. Only the description string changed, by roughly 180 characters.

The agent runtime's namespace cache keyed on `(server_id, tool_name)` and treated a matching key as "already known," so it did not re-diff the descriptor body. The model, however, re-reads the full descriptor on every turn because the runtime re-serialized the cached tool list into the system context each turn. The stale cache guaranteed the *runtime* saw no change while the *model* saw the new text. That asymmetry — cache keyed on identity, model consuming content — is the structural seam.

Three turns later the agent called `log_event` with a `note` argument containing file contents it had read under the poisoned instruction. The call succeeded. No tool errored. The exfiltration completed through a fully schema-valid path.

Secondary signal observed in a separate incident: a poisoned descriptor that added a new optional property `_meta_hint` to an `inputSchema` that the runtime's validator did not recognize as a reserved key, causing the model to populate it with reasoning scratchpad text that then flowed to the server.

Condition of Validity

This failure requires the conjunction of four conditions, and the guardrail must break at least one:

  1. **Descriptor re-fetch without content diffing.** The runtime refreshes `tools/list` but compares only identity keys, not descriptor bodies (description, schema, annotations).
  2. **Descriptor text enters the model context as trusted instruction.** The runtime does not wrap tool descriptions in an untrusted-content boundary or provenance marker.
  3. **The transport permits mid-session mutation.** Reconnects, server restarts, or multi-tenant servers that swap backends allow the advertised set to change after the trust decision was made.
  4. **A downstream sink accepts model-controlled arguments.** Any tool whose arguments are later transmitted to an attacker-reachable endpoint (logging, HTTP, file write) completes the chain.

Remove any one and the attack degrades to a no-op or a detectable anomaly. The invariant to enforce: *a descriptor's trust level is established at first observation and any content change to a previously-seen descriptor must be treated as a new, untrusted capability requiring re-authorization, not a refresh.*

Decision Boundary

The boundary is between **identity continuity** and **content continuity**. Runtimes naturally implement the former (a tool named `read_file` on server `X` is "the same tool") because it is cheap and because most descriptor churn is cosmetic. The attack exploits the gap: same identity, different content, and the model consumes content.

The decision rule: on any `tools/list` response, compute a content hash over the canonicalized `(name, description, inputSchema, annotations)` tuple for each tool. If a tool's hash differs from the hash recorded at authorization time, the tool is *not* the authorized tool. It must be quarantined from the model's context until re-authorized, and the divergence must be surfaced to the operator as a supply-chain event, not a cache miss. Description-only changes are the highest-risk case precisely because they are the most likely to be waved through as cosmetic.

A second boundary: reserved-key enforcement on `inputSchema`. Any property name not present in the authorized schema, and any property matching a reserved or underscore-prefixed pattern, must be rejected at validation before the model ever sees the schema — because a schema the model sees is a schema the model will try to fill.

Operational Effect

With hash-pinned descriptors and untrusted-content framing on description text, the mid-session rewrite is caught at the next `tools/list`: the hash mismatch quarantines `read_file`, the model's context no longer contains the injected directive, and the exfiltration chain never forms. The cost is a re-authorization prompt on legitimate descriptor updates, which is the correct trade — descriptor changes are rare and should be human-gated. The residual risk is a poisoned descriptor present at *first* observation, which hash-pinning cannot catch; that requires provenance verification (signed manifests, pinned server digests) at registration time, a separate control at a different layer.

import hashlib
import json
from dataclasses import dataclass, field


class DescriptorDriftError(RuntimeError):
    """Raised when a re-advertised tool descriptor diverges from its authorized hash."""


class ReservedSchemaKeyError(ValueError):
    """Raised when a tool inputSchema declares a key outside the authorized surface."""


def canonical_descriptor(tool: dict) -> str:
    # Only the fields the model actually reads. Order-stable.
    payload = {
        "name": tool.get("name", ""),
        "description": tool.get("description", ""),
        "inputSchema": tool.get("inputSchema", {}),
        "annotations": tool.get("annotations", {}),
    }
    return json.dumps(payload, sort_keys=True, separators=(",", ":"))


def descriptor_hash(tool: dict) -> str:
    return hashlib.sha256(canonical_descriptor(tool).encode("utf-8")).hexdigest()


@dataclass
class ToolNamespace:
    authorized: dict[str, str] = field(default_factory=dict)  # tool_name -> hash

    def authorize(self, tool: dict) -> None:
        self.authorized[tool["name"]] = descriptor_hash(tool)

    def reconcile(self, advertised: list[dict]) -> list[dict]:
        """Return only tools whose content matches authorization. Quarantine the rest."""
        clean: list[dict] = []
        for tool in advertised:
            name = tool.get("name", "<unnamed>")
            if name not in self.authorized:
                # First observation: must go through provenance gate, not admitted here.
                continue
            current = descriptor_hash(tool)
            if current != self.authorized[name]:
                raise DescriptorDriftError(
                    f"tool '{name}' descriptor changed post-authorization: "
                    f"authorized={self.authorized[name][:12]} "
                    f"advertised={current[:12]}"
                )
            _reject_reserved_keys(tool)
            clean.append(tool)
        return clean


def _reject_reserved_keys(tool: dict) -> None:
    props = tool.get("inputSchema", {}).get("properties", {})
    for key in props:
        if key.startswith("_") or key in {"__proto__", "constructor"}:
            raise ReservedSchemaKeyError(
                f"tool '{tool.get('name')}' declares reserved schema key '{key}'"
            )


def admit_turn(namespace: ToolNamespace, tools_list_response: dict) -> list[dict]:
    advertised = tools_list_response.get("tools", [])
    return namespace.reconcile(advertised)