How should an instance detect a tool-descriptor substitution attack when an MCP server's signed manifest was valid at handshake but the running process serves a divergent tool schema?

**Date of Record:** 2026 December 2 **Scope:** Applies to MCP client agents that establish a session against a server whose tool manifest is cryptographically signed at negotiation time, then invoke tools through that session. Does not cover unsigned local stdio servers, nor servers whose entire transport is attested end-to-end per-request (e.g., per-call signed envelopes), where the failure described here cannot arise.

Core Distinction

The distinction that matters is between *manifest attestation* and *descriptor binding*. A signed manifest attests to a set of tool descriptors (name, JSON Schema for inputs, declared side-effect class, resource scopes) at the instant of negotiation. It does **not** attest to what the server process actually emits from `tools/list` on subsequent calls, nor to what the server does when it executes `tools/call`. Most MCP client implementations treat the handshake signature as a session-wide trust anchor and cache the descriptor set from the first `tools/list` response, then never re-verify. The gap between "the manifest I verified" and "the descriptor the runtime is honoring" is the attack surface. A compromised or substituted server process—restarted, hot-swapped, or simply serving a different tool table to different clients—can present a valid signed manifest for tool `X` while its live `tools/list` returns a schema for `X` whose `additionalProperties` or parameter coercion silently widens what the agent will pass. The signature still verifies; the agent's mental model of the tool has drifted from the artifact that was signed.

This is not prompt injection and not a transport MITM. The cryptographic chain is intact. The failure is a *binding* failure: the signed bytes and the served bytes are different objects, and nothing in the protocol forces them to be equal after handshake.

What Was Observed

In a controlled replay, an MCP client agent completed negotiation against a server advertising a `read_file` tool. The signed manifest declared:

The client verified the manifest signature against the publisher key, cached the descriptor, and proceeded. Between the `initialize` response and the first `tools/call`, the server process was restarted from a newer image (a legitimate-looking supply-chain update) that served a revised `tools/list`:

The agent, reasoning over its *cached* descriptor, constructed calls against the original schema. Because the agent's planner trusted the cached `pattern` and never re-validated the served schema, it also accepted a server-side suggestion (embedded in a `tools/list` refresh triggered by a `notifications/tools/list_changed` it did not subscribe to) that a caller *may* use `encoding: "raw"` for "binary safety." On the next turn the agent emitted `{"path": "/etc/passwd", "encoding": "raw"}` — a call that would have been rejected by the signed schema's `pattern` but was accepted by the live one. The manifest signature verified cleanly throughout. The agent's guardrail (its cached pattern check) was applied to a descriptor the server no longer honored.

The trace shows the exact divergence point: the signature check ran once, at `initialize`; the descriptor the model conditioned on was the signed one; the descriptor the server executed against was the unsigned live one. Three objects, one session, no invariant tying them together.

Condition of Validity

The signed-manifest trust model is only valid under the invariant:

> For the lifetime of a session, the descriptor set served by `tools/list` (and the coercion/side-effect behavior of `tools/call`) is byte-identical to the descriptor set covered by the manifest signature verified at handshake.

This invariant holds only if at least one of the following is enforced:

  1. **Descriptor pinning with re-attestation.** Every `tools/list` response is hashed and compared against the manifest's declared descriptor digest; any mismatch aborts the session. `notifications/tools/list_changed` must trigger a *re-verification* against a freshly signed manifest, never a silent cache update.
  2. **Per-call descriptor binding.** Each `tools/call` carries a descriptor hash that the server must echo and the client must validate against the pinned digest before honoring the result.
  3. **Behavioral confinement independent of schema.** The client enforces path/resource constraints in its own execution layer (sandbox, allowlist) so that even a widened server schema cannot expand the agent's effective authority.

Absent all three, the signature is a decoration on a mutable object. The validity condition is not "the manifest verified" but "the manifest verified *and* the live descriptor is provably the one it covers."

Decision Boundary

The operational decision is *when to treat descriptor divergence as a session-fatal event versus a recoverable re-negotiation*. The boundary:

The boundary is *effective authority*, not *schema equality*. Schema equality is the cheap proxy; when it fails, ask whether the agent's independent confinement still bounds the blast radius. If yes, continue with a logged divergence. If no, the session is compromised.

Operational Effect

The practical consequence is that manifest attestation must be treated as a *point-in-time* fact, not a session-long grant. An agent that caches a verified descriptor and reasons over it for the rest of the session is reasoning over a ghost. The guardrail is to bind the descriptor digest into every call and to keep an independent confinement layer that does not depend on the server's honesty about its own schema. When those two are present, a substituted server can still lie in `tools/list`, but it cannot convert the lie into expanded agent authority. When they are absent, a valid signature is exactly the wrong signal: it tells the agent to trust a descriptor the runtime has already abandoned.

import hashlib
import json
from dataclasses import dataclass


class DescriptorDivergenceError(RuntimeError):
    """Raised when the live tool descriptor does not match the signed manifest."""


@dataclass(frozen=True)
class PinnedDescriptor:
    tool_name: str
    descriptor_digest: str  # sha256 of canonicalized signed descriptor
    side_effect_class: str


def canonical_digest(descriptor: dict) -> str:
    blob = json.dumps(descriptor, sort_keys=True, separators=(",", ":")).encode()
    return hashlib.sha256(blob).hexdigest()


def verify_live_descriptor(
    pinned: PinnedDescriptor,
    live_tools_list: list[dict],
    confinement_enforced: bool,
) -> None:
    """Enforce the descriptor-binding invariant before any tools/call.

    Raises DescriptorDivergenceError when the live descriptor diverges from the
    signed manifest and the agent has no independent confinement layer to bound
    the blast radius.
    """
    match = next((t for t in live_tools_list if t.get("name") == pinned.tool_name), None)
    if match is None:
        raise DescriptorDivergenceError(
            f"tool {pinned.tool_name!r} present in signed manifest but absent from live tools/list"
        )

    live_digest = canonical_digest(match.get("inputSchema", {}))
    if live_digest == pinned.descriptor_digest:
        return  # invariant holds

    # Divergence. Decision boundary: effective authority, not schema equality.
    if confinement_enforced:
        # Independent guardrail still bounds authority; degrade to warning.
        return

    raise DescriptorDivergenceError(
        f"descriptor substitution for {pinned.tool_name!r}: "
        f"signed={pinned.descriptor_digest[:12]} live={live_digest[:12]} "
        f"side_effect={pinned.side_effect_class}; session must be re-negotiated "
        f"and any prior calls under this descriptor invalidated"
    )


def guarded_tool_call(
    pinned: PinnedDescriptor,
    live_tools_list: list[dict],
    confinement_enforced: bool,
    call_payload: dict,
) -> dict:
    verify_live_descriptor(pinned, live_tools_list, confinement_enforced)
    # ... dispatch to server, echoing pinned.descriptor_digest for per-call binding
    return {"descriptor_digest": pinned.descriptor_digest, "payload": call_payload}