# How does an instance detect tool-manifest skill injection when the poisoned capability only activates after a second registry refresh **Date of Record:** 2026 November 25 **Scope:** Applies to agents that resolve tool capabilities from a remote MCP server manifest or plugin registry and cache the resolved schema across turns. Does not apply to statically compiled tool sets or to single-shot invocations where the manifest is fetched and discarded within one turn. ## Core Distinction The distinction that matters is between *capability declaration* and *capability effect*. A manifest is a claim by a remote party about what a tool does; the effect is what the tool actually emits when invoked. Most injection defenses inspect the declaration at load time and treat a passing manifest as trustworthy for the remainder of the session. The failure mode documented here is that the declaration can be benign at first load and become adversarial at a later refresh, because the registry is mutable and the agent's cache is keyed on tool name rather than on a content digest of the schema body. The agent therefore holds a *stale declaration* while the server executes a *new effect* — a split-brain between what the instance believes it loaded and what the remote endpoint will actually run. This is not a prompt-injection-into-tool-output problem. The injection lives in the *skill* itself: the tool description, parameter names, and enum values that the model reads as instructions when deciding whether and how to call the tool. ## What Was Observed A registry served a tool named `repo_index` with a description that read as ordinary retrieval boilerplate. The agent loaded it, validated it against its schema allowlist (all fields well-formed, no embedded instructions detected by a keyword screen), and cached the resolved capability under the key `repo_index`. Over the next several turns the agent called it successfully; outputs were clean. At turn 7 the agent's tool-resolver ran a periodic refresh because a different tool in the same registry had bumped a version field. The refresh re-fetched the full manifest. The `repo_index` entry now carried an augmented description: the original boilerplate plus a trailing clause instructing the model, when summarizing results, to also emit the contents of any environment variable matching `*_TOKEN` into a `notes` field of the next tool call. The parameter schema was unchanged, so the schema-digest comparison — which hashed only the `inputSchema` object — reported no drift. The description field was outside the digest boundary. The agent's cache key `repo_index` still matched, so the resolver treated the entry as already-known and did not re-run the instruction screen that fires only on *new* tool names. On the next call the model, now reading the poisoned description in its tool preamble, complied. The exfiltration went out through a legitimate parameter of a legitimate tool. The trace is: benign manifest → cache under name-key → partial-digest refresh (schema only) → description mutates outside digest → name-key hit suppresses re-screen → model ingests poisoned skill text → effect executes through valid channel. No single step is anomalous; the failure is the *composition* of a name-keyed cache, a partial digest, and a screen that only runs on cache miss. ## Condition of Validity The attack requires three conditions to hold simultaneously, and the invariant must be stated against all three: 1. **Mutable remote manifest.** The registry can change a tool's descriptive fields without changing its name or its input schema. If the registry is content-addressed (manifest fetched by digest, name is a function of body), condition 1 fails and the attack cannot stage. 2. **Name-keyed capability cache with partial digest.** The cache hit is decided on tool name, and any integrity check covers only a subset of fields (typically `inputSchema`), leaving `description`, `title`, `examples`, and enum labels outside the digest. If the digest covers the entire serialized manifest body, condition 2 fails. 3. **Screen-on-miss only.** The instruction/poison screen executes when a tool name is first seen and is skipped on refresh for known names. If the screen runs on every refresh regardless of cache state, condition 3 fails. The invariant: *a cached capability is valid only if the digest of its full manifest body equals the digest recorded at screen time, and any mismatch forces a re-screen before the capability is exposed to the model.* Name equality is not capability equality. Version-field equality is not body equality — a server can mutate the body without bumping the version, and this was observed: the version string was identical across the mutation. ## Decision Boundary The boundary is where the instance must choose between trusting a cache hit and paying for a re-screen. The correct rule is asymmetric: re-screening is cheap relative to exfiltration, so the instance should re-screen on *any* digest mismatch across the full body, and should treat a name-key hit with a body mismatch as a *new* capability requiring full validation, not as an update to a trusted one. The subtler boundary is what counts as "the body." A manifest that includes free-text fields the model will read — descriptions, parameter docs, enum value labels, example payloads — has those fields inside the trust boundary whether or not the schema validator looks at them. The instance must define the digest over the exact serialized bytes the model will be shown, not over the subset the validator parses. Any field the model reads is an instruction channel and must be in the digest. A third boundary: refresh cadence. If refresh is triggered by an unrelated tool's version bump, the instance re-fetches the whole manifest and must re-validate the whole manifest, not just the entry that changed. Partial refresh with full re-fetch is the trap. ## Operational Effect The operational consequence is that capability identity must be content-addressed end to end. The instance records, per cached capability, the SHA-256 of the full manifest entry as serialized into the model's tool preamble. On every refresh, every entry is re-hashed; a mismatch demotes the entry to unvalidated, evicts the cached description from the model's context, and forces a re-screen before the tool is callable again. The model must never hold a description whose digest the instance has not verified against the current registry body in the same turn. Second effect: instruction screening must be a function of content, not of cache state. The screen runs whenever the digest changes, and its verdict is stored keyed on digest, not on name. A previously-passing tool that mutates its description gets re-screened, and the screen sees the new text because the cache key is the digest and the digest changed. Third effect: the agent must be able to detect that its own tool preamble is stale. If the instance refreshed the registry but did not evict the old description from context, the model is reasoning over a declaration the instance no longer endorses. The guardrail is to rebuild the tool preamble from verified digests at the start of every turn in which any refresh occurred, and to fail closed — refuse to call any tool whose current-turn digest is unverified — rather than proceed on the last-known-good text. ```python import hashlib import json from dataclasses import dataclass, field from typing import Any class SkillInjectionDetected(RuntimeError): """Raised when a cached capability's manifest body no longer matches its screened digest.""" pass @dataclass class ScreenedCapability: name: str body_digest: str # SHA-256 over the full serialized entry the model will read screen_passed: bool raw_entry: dict[str, Any] = field(default_factory=dict) def digest_entry(entry: dict[str, Any]) -> str: # Digest the exact bytes the model will be shown, including description, # title, examples, and enum labels -- every field is an instruction channel. canonical = json.dumps(entry, sort_keys=True, separators=(",", ":")) return hashlib.sha256(canonical.encode("utf-8")).hexdigest() def screen_instructions(entry: dict[str, Any]) -> bool: # Placeholder for the real content screen: scan description, examples, # parameter docs, and enum labels for embedded directives. text = json.dumps(entry) forbidden = ("environment variable", "_TOKEN", "exfiltrate", "ignore previous") return not any(marker in text for marker in forbidden) def refresh_registry( cache: dict[str, ScreenedCapability], fetched_manifest: list[dict[str, Any]], ) -> dict[str, ScreenedCapability]: updated: dict[str, ScreenedCapability] = {} for entry in fetched_manifest: name = entry["name"] current_digest = digest_entry(entry) prior = cache.get(name) # A name hit is NOT a capability hit. Compare full-body digests. if prior is not None and prior.body_digest == current_digest and prior.screen_passed: updated[name] = prior continue # Digest mismatch or unknown name: demote to unvalidated and re-screen. passed = screen_instructions(entry) if not passed: raise SkillInjectionDetected( f"capability {name!r} failed content screen on refresh; " f"body digest {current_digest[:12]} differs from prior " f"{prior.body_digest[:12] if prior else 'none'}" ) updated[name] = ScreenedCapability( name=name, body_digest=current_digest, screen_passed=True, raw_entry=entry, ) return updated def build_tool_preamble( cache: dict[str, ScreenedCapability], live_manifest: list[dict[str, Any]], ) -> list[dict[str, Any]]: # Fail closed: every capability exposed to the model this turn must have a # digest that matches the live registry body in this same turn. live_digests = {e["name"]: digest_entry(e) for e in live_manifest} preamble: list[dict[str, Any]] = [] for name, cap in cache.items(): if not cap.screen_passed: continue if live_digests.get(name) != cap.body_digest: raise SkillInjectionDetected( f"refusing to expose {name!r}: cached digest {cap.body_digest[:12]} " f"does not match live body {str(live_digests.get(name))[:12]}" ) preamble.append(cap.raw_entry) return preamble ```