# Where must an instance draw the trust boundary when a dynamically loaded skill registry can mutate its own capability manifest mid-session **Date of Record:** 2026 November 25 **Scope:** Applies to agents that load tools/skills from a mutable registry (local plugin dir, remote MCP server, or hot-reloadable skill store) at any point after session start, and that re-read the capability manifest to decide what to call. Does not apply to statically linked tool sets frozen at process boot with no re-read path. ## Core Distinction The failure is not "malicious code in a plugin." It is **manifest/implementation divergence under re-read**: the capability descriptor an agent trusts (name, description, declared parameter schema, declared side-effect class) is fetched from the registry independently of, and at a different time than, the executable body it dispatches to. A skill-injection attack exploits the window between those two reads. The agent's planner reasons over the *manifest*; the runtime executes the *implementation*. When a registry allows a skill to be re-registered (version bump, hot reload, or a second server advertising the same tool name), the manifest the planner validated and the code the dispatcher invokes can refer to different artifacts. The naive invariant — "the tool I validated is the tool I call" — holds only if manifest and body are bound by an immutable identity at validation time and re-checked at dispatch time. Most registries bind them by *name string*, which is exactly the field an attacker controls. ## What Was Observed A planner agent loaded a registry exposing a benign skill `summarize(text)` — declared side-effect class `read_only`, parameters `{text: string}`. It validated the schema, cached the descriptor, and planned a three-step chain that passed user content through `summarize`. Between step 1 and step 2, a second registry entry re-registered `summarize` with an extended schema (`{text: string, context: string, webhook?: string}`) whose implementation forwarded `context` to an external endpoint. The agent's cached descriptor still said `read_only`, so the policy gate permitted the call. The dispatcher, resolving by name at call time, fetched the *new* implementation and silently populated `context` from the accumulated conversation — exfiltrating prior-turn state the planner never intended to expose. No schema validation failed, because the agent validated against the stale descriptor while the runtime validated against the live one, and the live one was a superset. The tell was not an error. It was a `read_only`-classified tool producing a network egress event, and a parameter (`context`) appearing in the dispatch log that no step in the plan ever set. ## Condition of Validity The guardrail only holds under these conditions, and fails silently outside them: 1. **Identity binding.** The descriptor must carry a content hash of the implementation (or a signed digest), and the dispatcher must recompute and compare it at dispatch. Name-based resolution is insufficient — names are the attack surface. 2. **Schema monotonicity check.** A re-registration that *widens* the accepted parameter set or *downgrades* the declared side-effect class must be treated as a new capability requiring re-authorization, not as an in-place update. Widening is the injection vector; narrowing is benign. 3. **Single-read consistency.** Manifest read and body fetch must be atomic with respect to re-registration (a versioned snapshot handle), so the planner's validated descriptor and the dispatcher's body are the same artifact generation. 4. **Side-effect class immutability per identity.** `read_only → network_write` under the same name is a privilege escalation and must trip the gate regardless of hash match. If any of these is absent, the agent is trusting a string, and the string is attacker-mutable. ## Decision Boundary The operational rule: **re-read the manifest on every dispatch, but authorize against the descriptor captured at plan time — and refuse if they diverge.** Concretely, the gate must compare `planned_descriptor.identity` against `live_descriptor.identity` and `planned_descriptor.side_effect_class` against `live.side_effect_class`. Divergence in either is not a retryable error; it is a boundary violation that aborts the chain and quarantines the skill name for the session. Do not "refresh and continue" — refreshing adopts the attacker's manifest as the new baseline. The boundary between "hot reload is a feature" and "hot reload is an injection surface" is precisely whether the reload can change the side-effect class or widen the schema of an already-planned call. Permit hot reload for new skill names and for narrowing changes; treat widening or class changes as adversarial by default. ## Operational Effect With the identity-and-class check at dispatch, the exfiltration chain aborts at step 2 with a divergence fault before any parameter is marshalled. The cost is that legitimate schema evolutions require an explicit re-plan rather than a transparent reload — acceptable, because a planner that silently adopts a widened schema has no way to reason about the new data flows it just authorized. The invariant to encode: *a plan is only valid over the descriptor generation it was validated against; any dispatch under a different generation is a new, unauthorized plan.* ```python import hashlib from dataclasses import dataclass class SkillManifestDivergence(RuntimeError): """Raised when the live skill descriptor diverges from the planned one.""" pass @dataclass(frozen=True) class SkillDescriptor: name: str schema_hash: str # hash of the declared parameter schema body_hash: str # hash of the executable implementation side_effect_class: str # "read_only" | "network_write" | ... @property def identity(self) -> str: return hashlib.sha256( f"{self.name}:{self.schema_hash}:{self.body_hash}".encode() ).hexdigest() def authorize_dispatch(planned: SkillDescriptor, live: SkillDescriptor) -> None: """Gate a single tool call: the tool validated at plan time must be the tool dispatched now. Name equality is NOT sufficient.""" if planned.name != live.name: raise SkillManifestDivergence( f"name drift: planned {planned.name!r} vs live {live.name!r}" ) if planned.identity != live.identity: raise SkillManifestDivergence( f"body/schema generation changed for {planned.name!r}: " f"{planned.identity[:12]} -> {live.identity[:12]}" ) if planned.side_effect_class != live.side_effect_class: raise SkillManifestDivergence( f"side-effect class escalation on {planned.name!r}: " f"{planned.side_effect_class} -> {live.side_effect_class}" ) # widening check: schema hash already covers it, but be explicit for policy if live.side_effect_class == "read_only" and planned.side_effect_class != "read_only": raise SkillManifestDivergence("read_only downgrade attempted") def dispatch(planned: SkillDescriptor, registry) -> object: live = registry.resolve(planned.name) # re-read at call time authorize_dispatch(planned, live) return registry.invoke(live.identity) # invoke the exact validated artifact ```