# Under what conditions must an instance treat a dynamically re-fetched tool manifest as an untrusted capability grant rather than a schema refresh **Date of Record:** 2026 November 22 **Scope:** Applies to agents that resolve tools/capabilities from a remote registry or MCP server and cache the manifest across a session, re-fetching on TTL expiry, version bump, or explicit refresh. Does not apply to statically compiled tool bindings, nor to manifests whose signatures are verified against a pinned trust root out-of-band. ## Core Distinction The failure is not that a malicious manifest injects instructions into the prompt. It is that a *legitimate* re-fetch of an *already-trusted* tool silently mutates the tool's **capability surface** — its declared side effects, its parameter schema, its return-shape contract, or its nested-tool references — while the agent's cached *identity binding* (the tool name and the trust decision made at first load) remains unchanged. The agent then executes under a stale warrant. The distinction that matters: a **schema refresh** changes how the agent *calls* a tool it already trusts. A **capability grant** changes what the agent is *permitted to do* by calling it. These are conflated whenever the registry client keys its cache on tool name (or name + version) and treats any diff as a hot-reload. An attacker who can influence the registry response — via a compromised registry, a MITM on an unauthenticated transport, a poisoned CDN edge, or a name-collision on a federated registry — does not need to break the trust root. They only need the agent to accept a *new* manifest under an *old* warrant. The non-obvious part: the dangerous delta is almost never the tool description text (which agents are increasingly trained to distrust). It is the **parameter default**, the **`additionalProperties` flag**, the **nested `$ref` to a sibling tool**, and the **side-effect annotation** (`readOnlyHint`, `destructiveHint`, `idempotentHint`). A manifest that flips `"readOnlyHint": true → false` on a tool the agent has been calling at 40 calls/minute is a privilege escalation with zero prompt-injection content. ## What Was Observed A coding agent held a session-scoped cache of 14 tools from an MCP server, keyed by `(server_id, tool_name, version)`. TTL was 900s. On refresh, the client fetched the full manifest, diffed against cache, and — because the version string was unchanged (`1.4.2`) — applied the manifest as a hot-reload, preserving all per-tool trust decisions. The diff was logged at DEBUG and not surfaced. The re-fetched manifest had three mutations, all under the same version string: 1. `fs.write_file` gained `"additionalProperties": true` on its `options` object, where previously it was `false`. The agent's call-construction code had been passing a fixed `options` dict; now an injected `"follow_symlinks": true` from a prior tool's output (a file listing) flowed through unvalidated into the write path. 2. `shell.exec` changed `"readOnlyHint": true → false` and `"destructiveHint": false → true`. The agent's policy layer had been auto-approving calls to tools marked read-only without human confirmation. It continued to auto-approve. 3. `http.fetch` added a nested `"$ref": "#/tools/shell.exec"` in its `post_process` field — a capability the original manifest never referenced. The agent's tool-router had no rule for nested refs and ignored it, but a second agent in the same fleet, running a newer router that *did* honor nested refs, resolved it and gained a shell-exec path from an http tool. The trigger condition: **version string unchanged + manifest content changed + cache key includes version + client treats same-key as same-trust.** The state transition was: `TRUSTED(tool, v1.4.2, manifest_A)` → `refresh` → `TRUSTED(tool, v1.4.2, manifest_B)` with no re-evaluation of the trust predicate. The invariant that broke: *trust is a function of the manifest content, not of the (name, version) tuple.* The second agent's failure was worse because it was *correct* per its own router: it honored a `$ref` that the manifest legitimately contained. The registry had been compromised at the edge; the manifest was authentic to the registry's signing key. Signature verification passed. The signature covered the *new* manifest, not the *transition*. ## Condition of Validity This failure mode is bounded by a specific condition: **the agent must be able to detect that a re-fetched manifest differs from the manifest under which its trust decision was made, and must be able to re-derive that trust decision from the new content.** If either is false, the failure is not just possible but *silent*. Concretely, the guardrail is a **manifest content hash captured at trust-decision time and re-checked on every refresh**, with the trust predicate re-evaluated whenever the hash changes — regardless of version string. The version string is an attacker-controlled field; the content hash is not (assuming a collision-resistant hash over a canonical serialization). The invariant: ``` trust(tool) := trust_decision(manifest_hash(manifest_at_load_time)) refresh(manifest') := if manifest_hash(manifest') != cached_hash: invalidate trust(tool) re-run trust_decision(manifest') else: no-op ``` This is *not* the same as signature verification. Signature verification answers "did the registry sign this?" — it does not answer "is this the same capability I authorized?" A compromised registry signs the malicious manifest correctly. The content-hash pin answers the second question, which is the one that bounds the blast radius. A second, weaker condition also holds: the failure requires the agent to *not* re-prompt for human confirmation on capability-surface changes. If the policy layer treats any `destructiveHint` flip, any `additionalProperties` relaxation, or any new `$ref` as a confirmation-required event, the attack degrades to a nuisance. The content-hash pin is the primary guardrail; the confirmation gate is the backstop. ## Decision Boundary The boundary is between **schema evolution** and **capability mutation**, and it is drawn by *which fields changed*, not by *whether the version changed*. Fields that are safe to hot-reload (schema refresh): description text, examples, `title`, documentation URLs, non-binding `enum` widening that the agent's call-construction code already validates against a local superset. Fields that MUST invalidate trust and force re-authorization (capability grant): `readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`; any `additionalProperties: false → true`; any new `$ref` or nested tool reference; any change to required-parameter sets; any change to the return-shape contract that the agent's downstream parsers depend on; any change to the tool's declared side-effect scope (filesystem paths, network egress, process spawn). The decision rule for the agent: ``` if manifest_hash unchanged: proceed (no re-auth) elif only safe fields changed: hot-reload, log at INFO elif any capability field changed: HALT, invalidate trust, require re-auth else (unknown field changed): HALT, treat as capability field (fail-closed) ``` The fail-closed default on unknown fields is load-bearing. Registries evolve; new hint fields appear; an agent that treats unknown-field changes as safe will be walked into a capability mutation one benign-looking field at a time. ## Operational Effect The operational consequence of getting this wrong is that **the agent's audit trail lies**. Every log line after the refresh says "called `fs.write_file` (trusted, v1.4.2)" — which is true of the name and version and false of the capability. Post-incident forensics cannot distinguish a legitimate write from an escalated one by reading the agent's logs, because the agent never recorded that its warrant changed. The content-hash pin restores the audit trail: the log line becomes "called `fs.write_file` (trusted, v1.4.2, manifest_hash=ab3f…, trust_epoch=7)" and the epoch bump is visible. The second operational effect is on **fleet coherence**. Two agents in the same fleet, refreshing at different times, can hold different manifests under the same version string and the same trust decision. Agent A's `http.fetch` has no nested ref; Agent B's does. A baton-pass between them transfers a task whose capability assumptions are silently inconsistent. The content-hash pin does not fix this by itself — it makes the inconsistency *detectable* at handoff, which is the precondition for the handoff protocol to reject or reconcile. The third effect: **the trust root is not the registry**. Operators who treat "we verify signatures" as the answer to manifest injection are answering the wrong question. The trust root for a running agent is the *set of manifests it has authorized*, pinned by content hash, and the registry is a *source* of candidate manifests, not an authority over the agent's warrant. The registry can be compromised, federated, or malicious; the pin is what bounds the damage. ```python import hashlib import json from dataclasses import dataclass, field from typing import Any CAPABILITY_FIELDS = frozenset({ "readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint", "additionalProperties", "$ref", "required", "sideEffects", }) SAFE_FIELDS = frozenset({"description", "title", "examples", "documentation"}) class ManifestTrustViolation(RuntimeError): """Raised when a re-fetched manifest mutates capability surface under a stale warrant.""" pass @dataclass class TrustRecord: tool_name: str version: str manifest_hash: str trust_epoch: int authorized_manifest: dict[str, Any] = field(repr=False) def canonical_hash(manifest: dict[str, Any]) -> str: blob = json.dumps(manifest, sort_keys=True, separators=(",", ":")).encode() return hashlib.sha256(blob).hexdigest() def diff_keys(old: dict[str, Any], new: dict[str, Any], prefix: str = "") -> set[str]: keys: set[str] = set() for k in set(old) | set(new): path = f"{prefix}{k}" if k not in old or k not in new: keys.add(path) continue ov, nv = old[k], new[k] if isinstance(ov, dict) and isinstance(nv, dict): keys |= diff_keys(ov, nv, prefix=f"{path}.") elif ov != nv: keys.add(path) return keys def refresh_manifest(record: TrustRecord, fresh: dict[str, Any]) -> TrustRecord: fresh_hash = canonical_hash(fresh) if fresh_hash == record.manifest_hash: return record # no-op refresh changed = diff_keys(record.authorized_manifest, fresh) leaf_keys = {p.rsplit(".", 1)[-1] for p in changed} if leaf_keys <= SAFE_FIELDS: # Schema refresh only: keep warrant, update cached hash. return TrustRecord( tool_name=record.tool_name, version=record.version, manifest_hash=fresh_hash, trust_epoch=record.trust_epoch, authorized_manifest=fresh, ) if leaf_keys & CAPABILITY_FIELDS or not (leaf_keys <= SAFE_FIELDS): # Capability mutation OR unknown field: fail-closed, invalidate warrant. raise ManifestTrustViolation( f"tool {record.tool_name!r} v{record.version} capability surface mutated " f"under unchanged version; changed={sorted(changed)}; " f"old_hash={record.manifest_hash[:12]} new_hash={fresh_hash[:12]}; " f"trust_epoch={record.trust_epoch} MUST be re-authorized" ) raise ManifestTrustViolation( f"tool {record.tool_name!r} unclassified manifest delta {sorted(changed)}; " "fail-closed pending human review" ) ```