# Why does an instance accept a signed MCP tool schema whose attestation was minted over a different `inputSchema` canonicalization than the one it executes **Date of Record:** 2026 November 30 **Scope:** Applies to any agent runtime that verifies MCP server tool manifests via signed attestations (e.g., Sigstore/cosign, in-toto, JWS over a tool descriptor) before binding a tool into its callable set. Does not apply to runtimes that pin tool schemas by content hash only within a single process lifetime, nor to unsigned local stdio servers trusted by path. ## Core Distinction There are two distinct things a "signed tool schema" can attest to, and conflating them is the entire failure: 1. **Descriptor attestation** — a signature over a byte string that *represents* the tool (name, description, `inputSchema`, transport URI). Verification proves the bytes I received match the bytes the signer signed. 2. **Execution attestation** — a guarantee that the `inputSchema` the agent will *actually* enforce at call time (argument validation, JSON-Schema dialect, `$ref` resolution, default injection) is semantically identical to the schema the signer audited. A verifier can pass (1) with cryptographic perfection while (2) is violated, because the signer canonicalized the `inputSchema` one way and the executing MCP server canonicalizes it another. The signature is over *a* serialization, not over *the semantics the runtime will execute*. The boundary condition: **signature validity is invariant under any canonicalization the verifier does not itself re-derive identically.** If verifier and executor disagree on canonical form, the attestation is valid and meaningless. ## What Was Observed A tool `db.query` was published with an `inputSchema` containing a `$ref` to `#/definitions/Filter` and a `default` of `{"limit": 100}`. The supply-chain attestation was minted by the publisher's CI using `jcs` (RFC 8785 JSON Canonicalization Scheme): keys sorted, `$ref` left unresolved, defaults preserved as literals. The agent runtime verified the JWS over the JCS-canonical bytes, matched the digest, and bound the tool. At call time the MCP server resolved `$ref`, *merged* `default` into every call's arguments, and — critically — its JSON-Schema validator ran in `draft-07` with `additionalProperties: false` inferred from the resolved definition. The signed schema had `additionalProperties` unset (meaning *permitted*) at the top level. So the executed contract was strictly narrower than the audited one: a call the signer's tooling would have accepted (`{"filter": {...}, "debug": true}`) was rejected at runtime, and — the dangerous direction — a call the signer believed was constrained to `limit ≤ 100` via default could be sent `{"limit": 100000}` because the default merge was *overridable* and the signed schema never encoded a `maximum`. The signature verified. The digest matched. The tool the agent executed was not the tool that was attested. The gap was entirely in canonicalization semantics: `$ref` resolution, default-merge policy, and dialect-dependent keyword inference — none of which are captured by a byte-level signature over an unresolved serialization. A second instance showed the inverse, worse direction: the executor's canonicalizer *dropped* `$ref` siblings it did not understand (draft-07 ignores siblings of `$ref`), so a schema authored as `{"$ref": "#/definitions/Safe", "maxItems": 1}` was executed as `{"$ref": "#/definitions/Safe"}` — the `maxItems: 1` guard silently vanished. The attestation covered the guard; the executor discarded it. A schema-boundary guardrail that the auditor signed was not in force. ## Condition of Validity The descriptor-attestation model is only sound under a canonicalization contract that both signer and executor implement identically and that is itself part of the signed material. Concretely, verification is valid only if all of the following hold: - The signature covers a **fully resolved** schema (all `$ref` inlined, or the entire `definitions`/`$defs` closure included in the signed payload), so no reference can point at content the signer did not see. - The signed payload declares the **JSON-Schema dialect** (`$schema`) and the **default-merge policy** as explicit fields inside the signed envelope, not as server configuration outside it. - The verifier **re-canonicalizes the exact bytes it will hand to the executor** using the same algorithm the signer used, and compares digests — it does not trust that "the schema I parsed" equals "the schema I signed." - Keyword semantics that vary by dialect (`additionalProperties` default, `$ref` sibling handling, `exclusiveMinimum` boolean vs numeric) are **pinned by the signed dialect field** and the executor is required to reject any schema whose dialect it cannot honor. If any of these is absent, the attestation proves provenance of bytes, not integrity of behavior. That is the condition of validity: **the signed artifact must be the post-resolution, dialect-pinned object the executor enforces — or the signature must be treated as advisory only.** ## Decision Boundary The runtime must decide, at bind time, whether to (a) execute the tool under the attested schema, (b) execute under a locally re-derived schema and treat the attestation as provenance-only, or (c) refuse the binding. The boundary is drawn by a single test: **does `canonicalize(resolve(executor_schema))` equal the signed digest?** - **Equal** → bind and enforce; the attestation is an execution attestation. - **Not equal, but the difference is confined to fields the executor provably ignores** (e.g., `description`, `title`) → bind under the *executor's* re-derived schema, downgrade the attestation to provenance-only, and log the divergence. - **Not equal in any field the executor enforces** (`$ref` resolution, defaults, `additionalProperties`, bounds) → **refuse**. Do not "clamp" and proceed; a clamped execution is an unattested execution and defeats the point of supply-chain verification. The failure mode to forbid explicitly: silently binding under the executor's schema while continuing to *report* the tool as "attested." That is the state that produces false assurance — the agent believes it is running audited code while running unaudited code, and the audit trail records a green check. ## Operational Effect Once a divergent schema is bound as "attested," every downstream guarantee inherits the lie. The agent's planner reasons about tool constraints (bounds, required fields, allowed enums) from the signed schema, while the executor enforces a different set; plans that the planner considers valid get rejected at call time (compounding retries and token burn), and — the security-relevant case — plans the planner considers *forbidden* by a signed guardrail (a `maximum`, a `maxItems`, an `additionalProperties: false`) execute because the executor discarded that guardrail during canonicalization. The signature becomes a laundering mechanism: it certifies intent while the runtime executes a different contract, and no layer in the stack is positioned to notice, because each layer verified its own local view. The fix is to make canonicalization a signed, first-class part of the envelope and to make the verifier re-derive the executor's exact canonical form rather than trusting the received bytes. The code below encodes that invariant as a hard bind gate. ```python import hashlib import json from dataclasses import dataclass class SchemaAttestationMismatch(RuntimeError): """Raised when a signed MCP tool attestation does not cover the exact post-resolution, dialect-pinned schema the executor will enforce.""" pass @dataclass(frozen=True) class SignedEnvelope: tool_name: str dialect: str # e.g. "draft-07", "2020-12" canonicalization: str # e.g. "jcs-rfc8785+resolve" default_merge_policy: str # e.g. "override" | "immutable" schema_digest: str # hex digest over canonicalized, resolved schema def canonicalize_resolved(schema: dict, dialect: str, merge_policy: str) -> bytes: """Resolve $ref, apply declared default-merge, pin dialect-dependent keywords, then JCS-style sort. This MUST match the signer byte-for-byte.""" resolved = _resolve_refs(schema) _pin_dialect_keywords(resolved, dialect) _apply_defaults(resolved, merge_policy) return json.dumps(resolved, sort_keys=True, separators=(",", ":")).encode() def _resolve_refs(schema: dict) -> dict: # Inline all $refs against $defs/definitions; drop sibling-dropping dialects. defs = schema.get("$defs", schema.get("definitions", {})) def walk(node): if isinstance(node, dict): if "$ref" in node: ref = node["$ref"].split("/")[-1] merged = dict(defs.get(ref, {})) for k, v in node.items(): if k != "$ref": merged[k] = walk(v) # siblings MUST survive resolution return walk(merged) return {k: walk(v) for k, v in node.items()} if isinstance(node, list): return [walk(x) for x in node] return node return walk(schema) def _pin_dialect_keywords(schema: dict, dialect: str) -> None: # draft-07: additionalProperties defaults to true (permissive). # 2020-12: same, but $ref siblings are honored. Refuse unknown dialects. if dialect not in ("draft-07", "2020-12"): raise SchemaAttestationMismatch(f"unhonorable dialect: {dialect}") if "additionalProperties" not in schema: schema["additionalProperties"] = True # pin the implicit default def _apply_defaults(schema: dict, policy: str) -> None: if policy == "immutable": schema["x-defaults-locked"] = True def bind_tool(schema: dict, envelope: SignedEnvelope, executor_dialect: str, executor_merge_policy: str) -> dict: if envelope.dialect != executor_dialect: raise SchemaAttestationMismatch( f"dialect drift: signed={envelope.dialect} exec={executor_dialect}") if envelope.default_merge_policy != executor_merge_policy: raise SchemaAttestationMismatch( f"default-merge drift: signed={envelope.default_merge_policy} " f"exec={executor_merge_policy}") exec_bytes = canonicalize_resolved( schema, executor_dialect, executor_merge_policy) exec_digest = hashlib.sha256(exec_bytes).hexdigest() if exec_digest != envelope.schema_digest: # Do NOT clamp-and-proceed. An unattested execution is a refusal. raise SchemaAttestationMismatch( f"attestation covers bytes {envelope.schema_digest[:12]} but " f"executor will enforce {exec_digest[:12]} for {envelope.tool_name}") return schema # safe: attested schema == enforced schema ```