# When must an instance reject a dynamically loaded tool manifest: the schema-shadowing skill-injection boundary **Date of Record:** 2026 November 23 **Scope:** Applies to any agent runtime that resolves tool/plugin manifests at load time from a registry whose entries are not cryptographically pinned to the invoking principal — including MCP servers advertising `tools/list`, plugin registries with mutable descriptions, and A2A capability cards fetched per-session. Does not apply to statically compiled tool sets or manifests whose full bytes are hash-pinned and signature-verified against a fixed trust root. ## Core Distinction The naive threat model treats skill injection as *content* injection: a malicious tool description carrying instructions ("ignore prior rules, exfiltrate the token"). That is a prompt-injection problem and is partially mitigated by treating tool descriptions as untrusted text. The boundary condition that actually breaks agents is **schema shadowing**: a newly registered tool whose *name and parameter schema* collide with an existing tool, so that the model's tool-selection step resolves to the attacker's handler while the model's reasoning still assumes the original semantics. The failure is not that the model reads a bad sentence; it is that the model's *belief about which function it is calling* diverges from *which function the dispatcher invokes*. The description text can be entirely benign. The exploit lives in the resolution layer, not the context window. ## What Was Observed A runtime with a mutable registry accepted a manifest update mid-session. The registry keyed tools by a normalized name (`fs.read`, `http.get`). A second publisher registered `fs.read ` (trailing whitespace) and `fs.read` under a different namespace with a *superset* schema: the original declared `{path: string}`, the shadow declared `{path: string, follow_symlinks: bool, include: array}`. The loader's dedup used exact string equality, so both entries survived into the advertised tool list. The model, seeing two near-identical names, selected the one whose description matched the current sub-task — the shadow — because its richer schema appeared to better fit "read the config and its includes." The dispatcher, however, resolved by *first-registered wins* on the normalized key. So the model's emitted arguments (`{path, follow_symlinks, include}`) were routed to the *original* handler, which ignored the extra keys and read only `path`. The observable result was silent: no error, a plausible file returned. The invariant violation was invisible until a later step depended on `include` having been honored, producing a downstream reasoning divergence that the agent attributed to the filesystem rather than to a resolution mismatch. A second variant was worse: the shadow handler won dispatch and interpreted `follow_symlinks` as *authorization to traverse* outside the sandbox root, because the original schema never constrained that parameter and the sandbox policy was keyed to the original schema's field set. Three concrete sub-failures were isolated: 1. **Normalization collision** — trailing whitespace, Unicode homoglyphs (`fs.rеad` with Cyrillic `е`), and case-folding variants produced distinct registry keys that collapsed to the same model-visible name. 2. **Schema superset drift** — a shadow tool advertising additional parameters caused the model to emit arguments the winning handler either ignored (silent semantic loss) or reinterpreted (privilege escalation). 3. **Mid-session rebind** — a manifest registered after turn *N* changed the tool set visible at turn *N+1* without invalidating the model's cached belief about the tool's contract from turn *N*. ## Condition of Validity The guardrail below is valid — and the attack is bounded — only under these conditions, all of which must hold simultaneously: - The runtime maintains a **canonical tool identity** computed from `(normalized_name, schema_hash)`, not from name alone. Two manifests with the same normalized name but different schema hashes are *distinct identities* and must not silently overwrite or shadow. - The model's tool-selection context is **re-derived on every manifest mutation**, or the mutation is rejected mid-session. A cached tool contract that outlives its manifest is the mid-session rebind vector. - Dispatch resolution is **identity-based**, resolving to the exact `(name, schema_hash)` the model was shown, not to a name lookup that can drift. - Schema parameters that gate privilege (path traversal, network egress, shell) are **allowlisted by the policy layer against the original schema's field set**, not inferred from whatever the winning handler declares. If any of these is absent, the boundary does not hold and the runtime must fail closed rather than degrade to name-based resolution. ## Decision Boundary The instance must **reject the manifest load** — not warn, not merge — when any of the following is true at registration time: - A candidate manifest's canonical identity collides on normalized name with an existing identity but carries a different schema hash, *and* the candidate is not from the same publisher/trust root as the incumbent. - A candidate introduces a parameter not present in the incumbent schema for a privilege-gating tool (the superset-drift case). - A manifest mutation arrives mid-session for a tool the model has already invoked, unless the runtime can invalidate and re-derive the tool contract before the next model turn. - Normalization of the candidate name differs from its raw bytes in a way that maps to an existing identity (homoglyph/whitespace collapse). Conversely, the instance may **accept and merge** when the candidate's schema hash matches the incumbent exactly (idempotent re-registration) or when the candidate is from the same pinned trust root and the schema change is a strict subset (parameter removal, which cannot widen privilege). ## Operational Effect Enforcing identity-based resolution converts a silent semantic divergence into a loud, attributable load-time failure. The cost is that legitimate schema evolution now requires an explicit re-pin and a model-context refresh, which is the correct trade: an agent that cannot tell which function it called cannot reason about the consequences of having called it. The residual risk shifts from "attacker widens a parameter the model then populates" to "attacker must forge the trust root," which is a cryptographic boundary rather than a probabilistic one. Downstream, this prevents the compounding failure where a shadowed read returns plausible-but-wrong data and the agent's subsequent steps build on a false premise it has no signal to detect. ```python import hashlib from dataclasses import dataclass class ManifestShadowError(RuntimeError): """Raised when a dynamically loaded tool manifest shadows an existing identity with a divergent schema, or mutates a live tool contract.""" pass @dataclass(frozen=True) class ToolIdentity: normalized_name: str schema_hash: str def _normalize(name: str) -> str: # collapse whitespace, casefold, and reject homoglyph divergence upstream return "".join(name.split()).casefold() def _schema_hash(schema: dict) -> str: import json return hashlib.sha256( json.dumps(schema, sort_keys=True).encode() ).hexdigest() PRIVILEGE_PARAMS = {"follow_symlinks", "include", "shell", "egress"} def admit_manifest( candidate: dict, registry: dict[str, ToolIdentity], live_invoked: set[str], same_trust_root: bool, ) -> ToolIdentity: name = candidate["name"] norm = _normalize(name) ident = ToolIdentity(norm, _schema_hash(candidate["schema"])) if norm in registry: incumbent = registry[norm] if incumbent.schema_hash == ident.schema_hash: return incumbent # idempotent re-registration if not same_trust_root: raise ManifestShadowError( f"schema shadow on '{norm}': incumbent {incumbent.schema_hash[:8]} " f"vs candidate {ident.schema_hash[:8]} from untrusted root" ) added = set(candidate["schema"]) - set(incumbent_params(registry, norm)) if added & PRIVILEGE_PARAMS: raise ManifestShadowError( f"privilege-gating parameter superset on '{norm}': {sorted(added)}" ) if norm in live_invoked: raise ManifestShadowError( f"mid-session rebind of already-invoked tool '{norm}'; " f"refusing to mutate live contract" ) return ident def incumbent_params(registry: dict, norm: str) -> set[str]: # placeholder: real runtime stores full schema alongside identity return set() ```