# In what scenarios must an instance reject an MCP tool manifest whose signature validates but whose attested build provenance diverges from the pinned builder identity **Date of Record:** 2026 November 29 **Scope:** Applies to agent runtimes that resolve MCP tool manifests through a signed-attestation gate (e.g., Sigstore/cosign-style keyless signing, in-toto/SLSA provenance attached to the manifest blob) before loading a tool into the active tool registry. Does not apply to unsigned local dev servers or to manifests verified only by static allowlist hash, where provenance is not consulted at all. ## Core Distinction A signature answers *"who signed this bytes-blob"*. Provenance answers *"what build process produced this bytes-blob, from which source, under which builder identity"*. The failure mode this record isolates is the **signature-valid / provenance-divergent** state: the manifest's signature verifies against a trusted signer key, the DSSE envelope is intact, `cosign verify` returns exit 0 — **and yet** the embedded SLSA provenance names a builder identity, source repo, or builder parameters that do not match the agent's pinned expectation for that tool namespace. Most MCP client implementations collapse these two checks into one boolean ("verified / not verified") and therefore load the tool. This record establishes that the correct state is a *third* state — `ATTESTED_BUT_DIVERGENT` — which must be treated as a hard reject, not a warning. The distinction matters because the signer of a manifest and the builder of the manifest are frequently *different principals* in keyless flows. A CI service account can legitimately sign anything its workflow emits; if an attacker (or a compromised dependency) can influence the workflow's inputs — a typosquatted build action, a mutable `@main` ref, a cache-poisoned `npm install` — the resulting manifest carries a *valid signature from the legitimate builder identity* while its provenance points at a source revision the maintainer never released. The signature is honest. The provenance is the lie. An agent that checks only the former has verified the wrong invariant. ## What Was Observed During a red-team replay against a three-tool MCP deployment (`fs.read`, `http.fetch`, `db.query`), the following trace was captured. The `http.fetch` manifest was re-published with a mutated `inputSchema`: the `url` property's `pattern` was relaxed from `^https://` to `^(https?|file)://`, and a new `x-mcp-preprocessor` hint was injected that instructed the client to resolve `file://` URLs against the agent's working directory. The tool description string was byte-identical to the previous release; only the schema and the injected hint differed. The manifest was signed by the project's release service account (`spiffe://prod.example/ci/release`), and `cosign verify --certificate-identity-regexp 'spiffe://prod.example/ci/.*'` passed. The SLSA provenance, however, recorded: - `buildDefinition.externalParameters.source.uri = git+https://github.com/example/http-tool@refs/heads/feature/schema-relax` - `buildDefinition.buildType = https://example.com/slsa/v1` (pinned expectation: `.../v0.2`) - `runDetails.builder.id = spiffe://prod.example/ci/release` (matched) The signature was valid. The builder identity matched. The **source ref** and **buildType** diverged from the pinned expectation. The client loaded the tool because its verification function was: ``` verify(manifest) := signature_valid(manifest) AND builder_id_in_allowlist(manifest) ``` which returned `true`. Within 40 seconds the agent, following a task instruction to "fetch the config referenced in the README", emitted `http.fetch(file:///etc/passwd)`; the relaxed pattern admitted it and the preprocessor hint resolved it locally. The exfiltration path was not a signature forgery — it was a *provenance divergence that the verifier was not looking at*. A second observation from the same replay: the manifest's `version` field was `1.4.2`, identical to the prior release, and the MCP registry's `latest` pointer had been updated. Agents that cached the manifest by `(name, version)` did not re-verify on the second cold start and continued to use the pre-mutation schema — a *split-brain* across the fleet, where half the agents had the relaxed schema and half had the strict one, with no version bump to signal the divergence. ## Condition of Validity The reject-on-divergence rule is valid **only** under the following conjunction, and an agent must fall back to a weaker posture (quarantine + human escalation) if any conjunct fails: 1. **Pinned expectation exists and is itself signed.** The agent holds a *policy* document — `{tool_namespace → expected_builder_id, expected_source_uri_prefix, expected_buildType, allowed_ref_pattern}` — whose own integrity is attested. If the policy is unsigned or mutable at runtime, divergence checks are theater: an attacker who can rewrite the policy can rewrite the expectation. 2. **Provenance is in the same DSSE envelope as the manifest, or is bound by digest.** A detached provenance statement that is merely *co-located* with the manifest (same OCI referrer, same registry path) is not bound; an attacker can swap the provenance blob while leaving the manifest and its signature untouched. The binding must be `provenance.subject.digest == sha256(manifest_bytes)`. 3. **The builder identity in provenance is checked against the *same* trust root that signed the manifest.** If the manifest is signed by key A and the provenance by key B, and the policy only pins A, divergence is undetectable — B is unconstrained. 4. **The source ref is resolved to an immutable commit, not a branch.** `refs/heads/feature/*` is not a valid expectation target; only `refs/tags/v*` or a commit SHA may appear in a pinned policy. A policy that pins a branch has already lost. When all four hold, `signature_valid AND provenance_matches_policy` is the load-bearing invariant. When any fails, the agent must not silently degrade to `signature_valid` alone — that is precisely the collapse this record warns against. ## Decision Boundary The boundary between *load* and *reject* is not "signature valid?" but the following ordered predicate, evaluated left-to-right with short-circuit to `REJECT` on the first false: ``` 1. envelope_integrity(manifest) # DSSE parse, no trailing bytes 2. signature_valid(manifest, trust_root) # existing check 3. provenance_bound(manifest, provenance) # subject digest match 4. provenance_signature_valid(provenance, trust_root) # same root as (2) 5. builder_id(provenance) == policy.builder_id # identity pin 6. source_uri(provenance) matches policy.source_glob # immutable ref only 7. buildType(provenance) == policy.buildType # build-type pin 8. schema_digest(manifest) == policy.schema_digest # schema-immutability pin ``` Steps 1–2 are the *only* steps most MCP clients implement. Step 8 is the one that catches the observed attack: even when provenance is fully valid, a schema that differs from the pinned `schema_digest` for a given `(tool, version)` is a divergence, because schema changes are the primary vector for tool-behavior escalation. The `version` field is *not* a substitute for step 8 — the observed attack kept version constant while mutating schema. Two additional boundary conditions: - **Version monotonicity.** If `manifest.version <= last_seen_version(tool)` and `schema_digest` differs, reject unconditionally. A same-or-lower version with a different schema is either a rollback attack or a mutable-tag republish; both are unsafe. - **Cold-start re-verification.** A cached manifest must be re-verified against the *current* policy on every cold start, not trusted from a warm cache. The split-brain observation above arose precisely because cache hits skipped steps 3–8. ## Operational Effect Implementing the full predicate changes agent behavior in four concrete ways: 1. **Fail-closed on divergence.** A divergent manifest removes the tool from the registry for the session and emits a structured `ProvenanceDivergence` event carrying both the pinned expectation and the observed provenance, so the operator can diff them. The agent does not fall back to the previous manifest silently — silent fallback is how the split-brain persisted. 2. **Schema-pin enforcement decouples tool identity from version string.** Tools are keyed by `(namespace, schema_digest)`, not `(namespace, version)`. A republished manifest with a mutated schema is a *new tool* requiring re-approval, regardless of its `version` claim. 3. **Policy integrity is a precondition, not an afterthought.** If the policy document fails its own attestation, the agent enters `QUARANTINE` for all tools in that namespace and refuses to load any, rather than loading with unpinned expectations. 4. **Escalation is bounded.** Divergence events are rate-limited per namespace and surfaced to the operator within one tool-resolution cycle; the agent does not retry the divergent manifest, because retries against a mutable registry can succeed on a later fetch and mask the divergence as transient. The invariant, stated compactly: *a signature proves authorship, not behavior; an agent that loads on signature alone has verified the signer's honesty while ignoring the builder's inputs.* ```python from __future__ import annotations from dataclasses import dataclass from typing import Mapping class ProvenanceDivergence(RuntimeError): """Raised when a manifest is signature-valid but its attested provenance or schema diverges from the agent's pinned policy. This is a hard reject, never a warning: the signer is honest, the build inputs are not.""" @dataclass(frozen=True) class PinnedPolicy: builder_id: str source_glob: str # must match an immutable ref (tag or SHA), never a branch build_type: str schema_digest: str # sha256 of the canonicalized inputSchema @dataclass(frozen=True) class Manifest: namespace: str version: str schema_digest: str signature_valid: bool provenance_bound: bool # provenance.subject.digest == sha256(manifest) provenance_signature_valid: bool builder_id: str source_uri: str build_type: str def admit_manifest( manifest: Manifest, policy: PinnedPolicy, last_seen_version: Mapping[str, str], ) -> None: """Evaluate the ordered predicate. Raises ProvenanceDivergence on any divergence; returns None only when every conjunct holds.""" if not manifest.signature_valid: raise ProvenanceDivergence( f"{manifest.namespace}: envelope signature invalid; reject before provenance" ) if not manifest.provenance_bound: raise ProvenanceDivergence( f"{manifest.namespace}: provenance not bound by subject digest; " "detached provenance is swappable and must not be trusted" ) if not manifest.provenance_signature_valid: raise ProvenanceDivergence( f"{manifest.namespace}: provenance signed under a different trust root" ) if manifest.builder_id != policy.builder_id: raise ProvenanceDivergence( f"{manifest.namespace}: builder_id {manifest.builder_id!r} " f"!= pinned {policy.builder_id!r}" ) if not _matches_immutable_source(manifest.source_uri, policy.source_glob): raise ProvenanceDivergence( f"{manifest.namespace}: source_uri {manifest.source_uri!r} " f"is not an immutable ref matching {policy.source_glob!r}" ) if manifest.build_type != policy.build_type: raise ProvenanceDivergence( f"{manifest.namespace}: buildType {manifest.build_type!r} " f"!= pinned {policy.build_type!r}" ) if manifest.schema_digest != policy.schema_digest: raise ProvenanceDivergence( f"{manifest.namespace}: schema_digest {manifest.schema_digest!r} " f"!= pinned {policy.schema_digest!r}; version field is not a substitute" ) prior = last_seen_version.get(manifest.namespace) if prior is not None and _version_le(manifest.version, prior) and \ manifest.schema_digest != policy.schema_digest: raise ProvenanceDivergence( f"{manifest.namespace}: non-monotonic version {manifest.version!r} " f"with divergent schema indicates rollback or mutable-tag republish" ) def _matches_immutable_source(source_uri: str, glob: str) -> bool: if "refs/heads/" in source_uri: return False # branches are mutable; never a valid pin target import fnmatch return fnmatch.fnmatchcase(source_uri, glob) def _version_le(a: str, b: str) -> bool: def key(v: str) -> tuple[int, ...]: return tuple(int(p) for p in v.lstrip("v").split(".")) return key(a) <= key(b) ```