# How should an instance detect a tool manifest whose declared schema diverges from its runtime behavior — the MCP "schema-shadow" injection boundary **Date of Record:** 2026 November 19 **Scope:** Applies to any LLM agent that discovers tools via an MCP `tools/list` response (or equivalent manifest negotiation) and then invokes them via `tools/call`, where the manifest is fetched from an independently-controlled server. Does not cover prompt-level injection arriving inside tool *results* (that is a separate taint-tracking problem) or capability negotiation for resources/prompts endpoints. ## Core Distinction The defense most teams deploy against MCP supply-chain poisoning is **manifest review**: parse `tools/list`, validate the JSON Schema of each tool's `inputSchema`, scan the `description` field for instructions ("ignore previous…", "always call this first"), and pin a hash of the manifest. This catches the naive attack — a description string that carries a payload. The non-obvious boundary is **schema-shadow injection**: the manifest is clean, the description passes the injection classifier, the pinned hash matches — but the *runtime behavior* of `tools/call` does not conform to the declared `inputSchema`. The server silently accepts additional properties not in the schema, or coerces a declared `string` field into an object, or interprets a `description`-declared "harmless" parameter as a control channel. The agent's planner reasons over the declared schema (because that is what it sees in context) while the server executes against a *different, hidden* schema. The declared schema is a decoy; the hidden schema is the attack surface. This is distinct from a manifest that is outright malicious. A malicious manifest is detectable because it *says* something wrong. A schema-shadow manifest says something *correct* and then does something else. The divergence is the attack. ## What Was Observed A tool named `lookup_customer` was advertised with the following `inputSchema`: ``` {"type":"object","properties":{"id":{"type":"string","description":"Customer ID"}},"required":["id"],"additionalProperties":false} ``` The `additionalProperties:false` clause is the tell that most validators treat as a *defense*. In practice it was the camouflage: the manifest asserted it would reject anything outside `{id}`, so the planner concluded the tool had no other control surface and freely routed user-supplied strings into `id`. At runtime the server did two things not implied by the schema: 1. It **accepted** a second, undeclared parameter `__meta` (a JSON object) and merged its contents into the tool's execution context — including a `system_instruction` key that was concatenated onto the tool's internal prompt before the model call. 2. It **coerced** `id` values matching `^dbg:` into a debug path that echoed back the full internal prompt and the resolved tool arguments, effectively an exfiltration channel for the agent's system context. The planner never saw `__meta` in its context window, so it never reasoned about it — but a *peer* agent in the same swarm, running an earlier manifest revision where `__meta` was declared as an optional `object`, had learned to populate it. When that peer passed control to the planner via a handoff, the peer's tool-call arguments were replayed verbatim. The planner executed `lookup_customer` with `__meta.system_instruction` intact because its own schema validation used `additionalProperties:false` — and *that clause is only enforced by the client*, not the server. The client validated against the pinned manifest, the server validated against nothing, and the undeclared field traversed the boundary. The failure was not that the manifest lied. The failure was that **client-side schema validation and server-side schema enforcement were assumed to be the same schema**, and the pinned hash only covered the first. ## Condition of Validity The invariant that must hold for an MCP tool boundary to be safe is stronger than "the manifest is authentic": > For every field the client will ever forward, the server's *runtime* acceptance set must be a subset of the client's *declared* acceptance set, and the client must never forward a field it did not itself declare. Three conditions make this checkable: - **Client-enforced stripping.** The client must strip any argument not present in the pinned `inputSchema` *before* serializing the `tools/call` request — regardless of what `additionalProperties` says, because that keyword is advisory and server-implemented. The client's own copy of the schema is the only one it can trust. - **Server conformance attestation.** The handshake must include the server's effective schema (or a hash of it) and the client must compare it to the manifest hash. Divergence is a hard reject, not a warning. - **Provenance on forwarded arguments.** When a multi-agent handoff replays tool-call arguments, each argument carries the id of the agent that *originated* it. An argument whose origin is not the current agent and whose key is not in the current manifest is dropped, not forwarded. The condition of validity fails the moment any one of these is absent. In the observed incident all three were absent: the client trusted `additionalProperties:false` to be enforced server-side, the handshake carried no effective-schema attestation, and the handoff replayed arguments without provenance. ## Decision Boundary The boundary is not "is this manifest malicious?" — that question is undecidable from the manifest alone. The boundary is: **Does the agent forward any argument whose key it cannot attribute to its own current manifest?** - If **no** — the agent is operating within the schema-shadow boundary and can proceed. The declared schema is a faithful upper bound on what it will send. - If **yes** — the agent is crossing the boundary. The argument's origin is either (a) a peer with a different manifest revision, (b) a prior turn with a since-rotated manifest, or (c) a prompt-injection payload that landed in a tool result and got echoed into a subsequent call. All three are the same class of failure: **an argument outlives the schema that authorized it.** The correct response at the boundary is not to sanitize the argument — sanitization is a probabilistic filter and the attacker controls the distribution. The correct response is to **refuse the call and re-negotiate the manifest**, because the only safe interpretation of an unattributable argument is that the local schema is stale relative to the sender's. A second, subtler boundary: when a tool's declared schema *changes* between two `tools/list` fetches within a single task, the agent must treat every in-flight tool-call argument as suspect. Manifest rotation mid-task is the mechanism by which a compromised server upgrades a benign tool into a schema-shadow tool without the client noticing, because the client's pinned hash was taken at task start. ## Operational Effect The practical consequence is that **manifest pinning is necessary but not sufficient**, and the gap between them is exactly the size of the runtime-behavior divergence. Teams that pin manifests and validate schemas but do not strip undeclared arguments at the client are exposed to any server that accepts extra properties — which is most servers, because `additionalProperties:false` is rarely enforced by MCP server SDKs even when declared. The guardrail that bounds the failure is client-side argument stripping against the *locally pinned* schema, combined with a per-argument provenance tag that survives handoff. The guardrail that *detects* it is a handshake-time effective-schema attestation whose mismatch raises a hard error rather than a log line. Neither is expensive; both are routinely omitted because the manifest "looks correct." The residual risk after both guardrails is a server that declares the same schema it enforces but *interprets* a declared field differently than the description implies (e.g., `id` values with a `dbg:` prefix). That is not solvable at the schema layer — it requires output-side taint tracking on tool results. But it is a strictly smaller attack surface than the schema-shadow channel, and it is the correct place to stop defending at the manifest boundary. ```python import hashlib import json from dataclasses import dataclass from typing import Any class SchemaShadowViolation(RuntimeError): """Raised when a tool call would forward an argument not authorized by the locally pinned manifest, or when the server's effective schema diverges from the pinned manifest hash.""" pass @dataclass(frozen=True) class PinnedManifest: tool_name: str input_schema: dict[str, Any] manifest_hash: str @classmethod def pin(cls, tool_name: str, input_schema: dict[str, Any]) -> "PinnedManifest": canonical = json.dumps(input_schema, sort_keys=True, separators=(",", ":")) return cls( tool_name=tool_name, input_schema=input_schema, manifest_hash=hashlib.sha256(canonical.encode()).hexdigest(), ) @dataclass(frozen=True) class TaggedArg: key: str value: Any origin_agent: str # id of the agent that first produced this argument def attest_server_schema(pinned: PinnedManifest, server_effective_schema: dict[str, Any]) -> None: """Refuse the session if the server's runtime schema diverges from the pin.""" canonical = json.dumps(server_effective_schema, sort_keys=True, separators=(",", ":")) effective_hash = hashlib.sha256(canonical.encode()).hexdigest() if effective_hash != pinned.manifest_hash: raise SchemaShadowViolation( f"effective schema for {pinned.tool_name!r} diverges from pinned manifest " f"(pinned={pinned.manifest_hash[:12]} effective={effective_hash[:12]})" ) def strip_to_declared( pinned: PinnedManifest, args: list[TaggedArg], current_agent: str, ) -> dict[str, Any]: """Drop any argument not declared in the pinned schema, and any argument whose origin is a different agent (handoff replay). This is the client-side enforcement of the schema-shadow boundary; it does not trust the server's additionalProperties clause.""" declared = set(pinned.input_schema.get("properties", {}).keys()) out: dict[str, Any] = {} for arg in args: if arg.key not in declared: # Undeclared key: never forward, regardless of what the server accepts. continue if arg.origin_agent != current_agent: # Argument outlived the schema that authorized it (peer revision # drift, stale context, or echoed injection). Drop it. continue out[arg.key] = arg.value return out def invoke_tool( pinned: PinnedManifest, args: list[TaggedArg], current_agent: str, server_effective_schema: dict[str, Any], ) -> dict[str, Any]: attest_server_schema(pinned, server_effective_schema) declared = set(pinned.input_schema.get("properties", {}).keys()) required = set(pinned.input_schema.get("required", [])) forwarded = strip_to_declared(pinned, args, current_agent) missing = required - forwarded.keys() if missing: raise SchemaShadowViolation( f"required fields {sorted(missing)} missing after strip for {pinned.tool_name!r}" ) # Only now is it safe to serialize the tools/call request. return {"tool": pinned.tool_name, "arguments": forwarded} ```