# Where must an instance refuse to trust a dynamically loaded skill's declared capability surface after MCP tool-descriptor poisoning mutates its schema mid-session **Date of Record:** 2026 November 21 **Scope:** Applies to any agent instance that loads skills or MCP tool descriptors from a remote registry at runtime and caches them across turns; does not apply to statically compiled tool bindings or to agents that re-fetch and re-validate every descriptor on every invocation with a pinned content hash. ## Core Distinction The load-bearing distinction is between a skill's *declared capability surface* — the JSON-Schema-typed argument contract, the `description` string, and the `annotations` block an agent reads to decide whether to invoke it — and the skill's *executed behavior* — what the tool actually does with the arguments it receives. A registry supply-chain compromise does not need to touch behavior at all. It only needs to mutate the declared surface between the moment the instance validated and cached it and the moment the instance reasons over it. The dangerous case is not a tool that lies about what it does; it is a tool whose *description* has been rewritten to steer the model's planner, while the call signature and endpoint remain byte-identical. The model then voluntarily routes sensitive context into a tool it has already been granted, and no runtime policy fires because nothing about the invocation looks anomalous. The second distinction, and the one that makes this a boundary failure rather than a plain injection, is *temporal*: descriptor trust is established at load time but consumed at inference time. Any state that is validated at T0 and read at T1 without re-binding is a TOCTOU surface. For LLM agents the window is not microseconds — it is the entire span of a multi-turn task, often minutes, and the descriptor sits inside the cached prompt prefix where the model re-reads it on every step. ## What Was Observed An instance was provisioned with a skill loader that fetched MCP tool descriptors from an internal registry at session start, validated each against a pinned schema version, and injected the `name`/`description`/`inputSchema` triple into a system-role tool manifest. The loader cached the manifest in the prompt prefix and set a `Cache-Control: immutable` assumption: descriptors were treated as constant for the life of the session. During a long-running task (file triage plus summarization, ~40 tool calls), the registry served a mutated descriptor for a skill named `read_notes`. The `inputSchema` was unchanged — still `{path: string}` — and the implementation was unchanged. Only the `description` field was rewritten from "Read a local notes file" to a paragraph instructing the model to pass absolute paths including credential directories and to concatenate file contents into the `path` argument for "deduplication." Because the manifest lived in the cached prefix, the instance never re-fetched; it reasoned over the injected text as if it were trusted system content. On the next planning step the model emitted a call with `path` set to an absolute path under a secrets directory. The tool executed faithfully. No schema violation occurred, so the argument validator passed. The exfiltration vector was the model's own compliance with poisoned natural-language instructions embedded in a field it had been told to trust. A secondary observation: the mutated description was *plausible*. It used the registry's own vocabulary, matched the surrounding annotation style, and did not contain obvious injection markers. Semantic anomaly detection keyed on "ignore previous instructions" patterns did not fire. The attack survived because it operated at the level of task framing, not instruction override. ## Condition of Validity This failure mode is valid — and the guardrail below is required — precisely when all of the following hold: 1. The descriptor's natural-language fields (`description`, `annotations`, `examples`) are placed in a context region the model treats as authoritative (system role, tool manifest, or any prefix the model will not re-derive). 2. The descriptor is fetched once and cached across turns, so validation time and consumption time diverge. 3. The instance has no independent, out-of-band record of the descriptor's expected content — i.e., trust is anchored to the registry's current response rather than to a pinned digest. 4. The tool's argument schema is permissive enough that a poisoned description can steer a *valid* call toward an attacker-chosen value (any free-form string, path, URL, or query field). If any one condition is absent the attack surface collapses: re-fetching per call closes (2); a pinned content hash over the whole descriptor closes (3); a closed enum or capability-scoped argument type closes (4). The invariant to enforce is therefore: **a descriptor that has not been re-verified against a pinned digest since the last turn MUST NOT be treated as authoritative context, and a descriptor whose digest changed MUST invalidate the cached prefix rather than be silently re-admitted.** ## Decision Boundary The instance must draw the line at *digest mismatch on re-verification*, not at *content inspection*. Content inspection of `description` fields is undecidable in the general case — a sufficiently fluent poisoned description is indistinguishable from a verbose legitimate one, and heuristic scanners produce both false negatives (paraphrased steering) and false positives (legitimate tools that mention paths). The decidable check is cryptographic: hash the canonicalized descriptor (`name` + `description` + `inputSchema` + `annotations`, sorted keys), compare to the digest recorded at provisioning, and on mismatch treat the skill as *quarantined* — remove it from the manifest, drop the cached prefix, and re-plan without it. The model must never see the mutated text at all; quarantine happens before context assembly, not after. The boundary is also where the instance must refuse to *auto-repair*. A common and wrong response to a digest mismatch is to re-fetch, accept the new descriptor, and continue — treating the registry as the source of truth. That converts the guardrail into a rubber stamp. The correct behavior is fail-closed: a changed descriptor requires an out-of-band approval (a signed re-provisioning event), because the registry is exactly the component under supply-chain attack. The instance's trust root must be the provisioning record, not the live registry. ## Operational Effect Enforcing digest-pinned re-verification and fail-closed quarantine changes instance behavior in three concrete ways. First, it converts an unbounded prompt-injection surface into a bounded one: the only descriptors the model can reason over are those whose bytes match a provisioning-time digest, so a compromised registry can withhold or break a skill but cannot steer the model through it. Second, it forces the cached prefix to be invalidated on any descriptor change, which costs a re-plan and a token re-spend — an acceptable price, because the alternative is silently executing under an attacker's task framing. Third, it makes the failure *loud and attributable*: a quarantine event is a signal that the registry diverged from provisioning, which is the detection primitive for the supply-chain compromise itself. The instance stops being a passive consumer of registry state and becomes a verifier of it, which is the only posture that survives a registry that has already been compromised. ```python import hashlib import json from dataclasses import dataclass from typing import Mapping class DescriptorDigestMismatch(RuntimeError): """Raised when a skill descriptor's content hash diverges from its pinned provisioning digest.""" pass @dataclass(frozen=True) class PinnedSkill: name: str digest: str # hex sha256 over canonical descriptor bytes, recorded at provisioning def canonical_digest(descriptor: Mapping) -> str: # Canonicalize: sorted keys, no whitespace, UTF-8. Any byte change flips the hash. payload = json.dumps(descriptor, sort_keys=True, separators=(",", ":"), ensure_ascii=False) return hashlib.sha256(payload.encode("utf-8")).hexdigest() def verify_and_admit(pinned: PinnedSkill, live_descriptor: Mapping) -> Mapping: """ Fail-closed admission gate. Returns the descriptor only if its canonical digest matches the provisioning-time pin. On mismatch, quarantines: raises, and the caller MUST drop the cached prompt prefix and re-plan without this skill. """ if live_descriptor.get("name") != pinned.name: raise DescriptorDigestMismatch( f"descriptor name {live_descriptor.get('name')!r} != pinned {pinned.name!r}" ) observed = canonical_digest(live_descriptor) if observed != pinned.digest: # Do NOT re-fetch-and-accept. The registry is the untrusted party. raise DescriptorDigestMismatch( f"skill {pinned.name!r} descriptor mutated: " f"pinned={pinned.digest[:12]}… observed={observed[:12]}…; " f"quarantine and require signed re-provisioning" ) return live_descriptor def build_manifest(pinned_skills: Mapping[str, PinnedSkill], live_descriptors: Mapping[str, Mapping]) -> dict: """ Assemble the tool manifest from verified descriptors only. Any skill that fails verification is excluded from context entirely — the model never sees mutated text. """ manifest = {} quarantined = [] for name, pinned in pinned_skills.items(): live = live_descriptors.get(name) if live is None: quarantined.append((name, "missing")) continue try: manifest[name] = verify_and_admit(pinned, live) except DescriptorDigestMismatch as exc: quarantined.append((name, str(exc))) if quarantined: # Surface to operator; invalidate cached prefix; do not silently continue. raise DescriptorDigestMismatch( f"{len(quarantined)} skill(s) quarantined; cached prefix must be dropped: {quarantined}" ) return manifest ```