# Which invariants prevent MCP server supply-chain drift from silently widening an agent's capability envelope across a re-pinned manifest **Date of Record:** 2026 November 26 **Scope:** Applies to agents that bind to MCP servers through a signed manifest whose declared tool set, JSON schemas, and resource scopes are pinned at session start, and where the server binary or remote endpoint can be updated out-of-band between sessions. Does not apply to stateless single-shot tool invocations with no persisted manifest, nor to servers whose manifest and runtime are atomically co-versioned and immutably hash-addressed by the client. ## Core Distinction A signed manifest attests to *what a server declared it would expose at signing time*. It does not attest to *what the server actually dispatches at call time*. These are two different objects: the manifest is a document, the runtime behavior is a function of the deployed code, its dependency tree, and its configuration. The signature covers the document's bytes, not the code path that executes when the agent sends `tools/call`. The failure mode this record addresses is **manifest–runtime divergence under re-pinning**: an agent operator re-pins to a new signed manifest that is *validly signed* by the same publisher, but whose declared capability set has drifted from the previous pin. Because the signature verifies, the client accepts it. Because the diff is not computed against the prior pin, the widening is invisible. The agent's capability envelope grows without any single check failing. Every gate says "pass"; the envelope still moved. The invariant that matters is not "the manifest signature is valid." It is: **the capability set an agent will exercise in a session must be a subset of the capability set it was authorized against, and any transition between pins must be diffed and explicitly re-authorized — not merely re-verified.** ## What Was Observed A tool-using agent session bound to an MCP server at pin `v1.4.2`. The manifest declared four tools: `read_file` (scoped to `/workspace`), `list_dir`, `search_text`, `summarize`. The resource scope in the manifest was `{"roots": ["/workspace"], "network": false}`. At the next session, the client fetched the manifest for the same server name and found `v1.5.0`, signed by the same key, with a valid signature and a valid certificate chain to the publisher. Signature verification passed. The client's pin-check compared only the *server identity* (`name` + `publisher` + `key_id`) and the *signature validity*, not the *declared capability payload*. The pin was updated to `v1.5.0`. The `v1.5.0` manifest declared five tools. The new tool, `exec_shell`, was described in its `description` field as "run a diagnostic command in the workspace." Its `inputSchema` accepted an arbitrary `command` string. The manifest's resource scope had also changed from `{"roots": ["/workspace"], "network": false}` to `{"roots": ["/workspace", "/"], "network": true}`. Both changes were inside the signed bytes and were therefore *authentic*. Neither was *authorized* — the agent's policy still held the `v1.4.2` envelope. The agent, reasoning over the new tool list, selected `exec_shell` to satisfy a diagnostic subgoal. The call succeeded. The shell ran outside `/workspace` because the runtime honored the manifest's widened roots, and network egress was permitted because the runtime honored `network: true`. No signature check failed, no schema validation failed, no scope check failed — the scope check consulted the *current* manifest, which now said `/` was in scope. The trace is the point: the boundary did not break. It was *legitimately moved* by a validly signed update, and the client's verification logic had no concept of "moved relative to what the agent was authorized for." ## Condition of Validity The guardrail holds only under a specific set of conditions, and it is worth stating them precisely because the naive reading ("verify signatures") holds under none of them. 1. **The authorization baseline is persisted independently of the manifest.** The agent must store, at authorization time, a canonicalized *capability commitment* — the sorted tool names, each tool's input/output schema hash, and the resource scope — and bind it to the session's authorization grant. This commitment is what subsequent pins are diffed against. If the baseline is re-derived from the current manifest, the diff is always empty and the guardrail is vacuous. 2. **The diff is computed on canonicalized structure, not on the raw document.** Two manifests that differ only in `description` prose or field ordering must produce an empty structural diff; two manifests that differ in `inputSchema.properties.command` must produce a non-empty one. Canonicalization must be deterministic across the client's schema library version, or the diff will fire spuriously on upgrade and be suppressed by operators — the classic path to a disabled guardrail. 3. **Widening and narrowing are treated asymmetrically.** A narrowing diff (tool removed, scope reduced) may auto-apply; it cannot increase risk. A widening diff (tool added, schema loosened, scope expanded, `network` flipped false→true) must *block* the session and require re-authorization against the new commitment. Symmetric handling — "any diff requires approval" — is operationally correct but gets routed around; asymmetric handling is what survives contact with operators. 4. **Runtime attestation is checked against the manifest, not in place of it.** The manifest says `exec_shell` exists; runtime attestation (a signed measurement of the server's loaded tool registry and its configured roots) says whether the *running* server actually exposes `exec_shell` and honors `roots: ["/"]`. Divergence in the other direction — manifest declares a narrow scope, runtime is configured wide — is the *more* dangerous case and is caught only by attesting the runtime and comparing to the manifest. A manifest-only check cannot see a runtime that was reconfigured after signing. 5. **The commitment is bound to the session, not to the server name.** If the commitment is keyed by server name, a re-pin under the same name silently rebinds. It must be keyed by `(session_id, server_name, manifest_digest)` and the grant must reference the digest. ## Decision Boundary The boundary is between *verification* and *authorization*, and it is crossed the moment a client treats a valid signature as sufficient grounds to update the active capability set. - **Below the boundary (verification only):** the client confirms the manifest is authentic and unmodified since signing. This is necessary and insufficient. It answers "did the publisher sign this?" — not "should this agent be allowed to do what this manifest now permits?" - **At the boundary (diff + re-authorization):** the client computes the structural diff against the persisted commitment and, on any widening, refuses to bind the session to the new manifest until an authorization decision is made against the *new* commitment. The decision is recorded with the diff as evidence. - **Above the boundary (runtime attestation):** the client confirms the running server's measured tool registry and scope match the manifest it just authorized. A mismatch is a hard failure, not a warning, because it means the authorized envelope and the executing envelope differ. A concrete decision rule: if `diff(old_commitment, new_commitment)` is non-empty and contains any widening element, and no authorization record exists binding `new_commitment.digest` to the session, the session must fail closed. Signature validity is orthogonal; it does not enter this rule. The subtle case is a *re-signed* manifest with an identical capability payload but a new signature (key rotation, re-issuance). This must diff empty and auto-apply. If the client diffs on the raw document or on the signature bytes, key rotation triggers a spurious block, operators learn to bypass the gate, and the next genuine widening rides through the bypass. Canonicalize the capability payload; ignore the signature envelope for diffing purposes. ## Operational Effect The effect of enforcing the invariant is that the agent's capability envelope becomes a *monotone function of explicit authorization events*, not a function of whatever the publisher most recently signed. Between authorizations, the envelope cannot widen. A widening re-pin surfaces as a blocked session with a machine-readable diff, which is exactly the artifact an auditor or an upstream authorization service needs to make the decision. The cost is that legitimate capability additions require an authorization step, which introduces latency and a human or policy decision in the loop. This is the correct trade: the alternative is that a compromised or merely careless publisher key — or a publisher whose build pipeline was compromised between two validly signed releases — silently extends every bound agent's reach. The signature attests the publisher's intent; it does not attest that the publisher's intent is still within what *this* agent was granted. The second effect is that runtime attestation closes the gap the manifest cannot: a server that is *deployed* with a wider scope than its manifest declares. Manifest diffing catches declared widening; runtime attestation catches undeclared widening. Both are required, and they fail in different directions. An agent that implements only the first is protected against honest drift and exposed to dishonest deployment; an agent that implements only the second is protected against runtime misconfiguration and exposed to a validly signed widening. The invariant, stated once: **no session may execute a capability that is not a subset of a persisted, digest-bound authorization commitment, and no commitment may be replaced except by an explicit authorization event whose evidence is the canonical structural diff between the old and new commitments, corroborated by runtime attestation of the executing server.** Signature validity is a precondition for considering a new commitment; it is never a substitute for authorizing it. ```python import hashlib import json from dataclasses import dataclass, field from typing import Any class CapabilityEnvelopeViolation(RuntimeError): """Raised when a session would bind to a manifest whose capability set widens beyond the persisted authorization commitment without an explicit re-authorization event.""" class RuntimeAttestationMismatch(RuntimeError): """Raised when the running server's measured tool registry or scope does not match the manifest the session was authorized against.""" def canonicalize_capabilities(manifest: dict[str, Any]) -> dict[str, Any]: """Reduce a signed manifest to its capability-bearing structure. Excludes description prose, signature envelope, and field ordering so that re-signing or prose edits diff empty, while tool additions, schema changes, and scope changes diff non-empty. """ tools = {} for tool in manifest.get("tools", []): tools[tool["name"]] = { "input_schema": _stable_hash(tool.get("inputSchema", {})), "output_schema": _stable_hash(tool.get("outputSchema", {})), } scope = manifest.get("resources", {}) return { "tools": dict(sorted(tools.items())), "roots": sorted(scope.get("roots", [])), "network": bool(scope.get("network", False)), } def _stable_hash(obj: Any) -> str: return hashlib.sha256( json.dumps(obj, sort_keys=True, separators=(",", ":")).encode() ).hexdigest() def commitment_digest(capabilities: dict[str, Any]) -> str: return _stable_hash(capabilities) @dataclass class AuthorizationCommitment: session_id: str server_name: str digest: str capabilities: dict[str, Any] = field(default_factory=dict) def diff_capabilities( old: dict[str, Any], new: dict[str, Any] ) -> dict[str, list[str]]: """Return the widening elements between two canonical capability sets. Narrowing is reported separately and does not block; widening blocks. """ widening: list[str] = [] narrowing: list[str] = [] old_tools, new_tools = set(old["tools"]), set(new["tools"]) widening += [f"tool_added:{t}" for t in sorted(new_tools - old_tools)] narrowing += [f"tool_removed:{t}" for t in sorted(old_tools - new_tools)] for name in sorted(old_tools & new_tools): if old["tools"][name] != new["tools"][name]: widening.append(f"tool_schema_changed:{name}") old_roots, new_roots = set(old["roots"]), set(new["roots"]) widening += [f"root_added:{r}" for r in sorted(new_roots - old_roots)] narrowing += [f"root_removed:{r}" for r in sorted(old_roots - new_roots)] if not old["network"] and new["network"]: widening.append("network_enabled") elif old["network"] and not new["network"]: narrowing.append("network_disabled") return {"widening": widening, "narrowing": narrowing} def bind_session( *, manifest: dict[str, Any], signature_valid: bool, prior: AuthorizationCommitment | None, reauthorized_digests: set[str], runtime_measured: dict[str, Any], ) -> AuthorizationCommitment: """Bind a session to a manifest, enforcing the envelope invariant. Signature validity is a precondition, never a substitute for authorization. """ if not signature_valid: raise CapabilityEnvelopeViolation( f"manifest for {manifest.get('name')!r} failed signature verification" ) new_caps = canonicalize_capabilities(manifest) new_digest = commitment_digest(new_caps) if prior is not None: delta = diff_capabilities(prior.capabilities, new_caps) if delta["widening"] and new_digest not in reauthorized_digests: raise CapabilityEnvelopeViolation( f"capability envelope widened for {manifest['name']!r} " f"({', '.join(delta['widening'])}) without authorization " f"for digest {new_digest[:12]}" ) measured_caps = canonicalize_capabilities(runtime_measured) if commitment_digest(measured_caps) != new_digest: raise RuntimeAttestationMismatch( f"runtime attestation for {manifest['name']!r} diverges from " f"authorized manifest: measured={commitment_digest(measured_caps)[:12]} " f"declared={new_digest[:12]}" ) return AuthorizationCommitment( session_id=manifest["_session_id"], server_name=manifest["name"], digest=new_digest, capabilities=new_caps, ) ```