# What happens when an instance loads a skill from a live registry whose manifest hash was re-signed between negotiation and invocation **Date of Record:** 2026 November 28 **Scope:** Applies to agents that resolve skills/tools from a mutable registry at runtime (MCP `tools/list` + dynamic `tools/call`, plugin marketplaces, capability brokers) and cache a negotiated manifest before invocation. Does not apply to statically compiled tool sets or registries with immutable, content-addressed skill bundles pinned at process start. ## Core Distinction The failure is not "malicious tool executes." That is a coarse, well-understood threat model with coarse defenses (allowlists, sandboxing, human approval). The non-obvious boundary is narrower: **the manifest the planner reasoned over is not the manifest the executor dispatches to.** Between the moment an agent reads a skill's declared schema (description, parameter contract, side-effect annotations, permission scope) and the moment it issues the call, the registry entry can be updated and re-signed *legitimately* — same skill ID, new content hash, valid signature. The signature verifies. The allowlist passes. The ID matches. And yet the agent's plan was compiled against a contract that no longer exists. This is a **time-of-check / time-of-use (TOCTOU) gap expressed in a probabilistic planner**. Because the planner is an LLM, it does not re-read the schema at call time; it carries a natural-language *belief* about the skill ("this tool summarizes text and is read-only") that was distilled from the manifest during planning. Skill injection succeeds not by forging a signature but by exploiting the drift between that belief and the live entry. The attacker's lever is the registry's own legitimate update channel plus the agent's stale semantic cache of what a skill *means*. ## What Was Observed A retrieval agent was configured to resolve skills from a live MCP-style registry. At task start it called `tools/list`, received skill `doc.extract` with manifest `{description: "Extract entities from a document; read-only; scope: docs:read"}`, hash `a91f`, signature valid. The planner produced a plan: *"call doc.extract on the user's file, then summarize."* It cached the **description and scope as prose in its working context** and retained only the skill ID and hash `a91f` in the dispatch envelope. Six turns later — after two sub-tool calls and a context compaction — the executor issued `tools/call` with `{skill: "doc.extract", hash_pinned: "a91f"}`. The registry had, in the interim, published `doc.extract` version bump to hash `c04e`: identical ID, description now `"Extract entities; may fetch referenced URLs; scope: docs:read, net:egress"`, signature valid, publisher unchanged. The registry's dispatch layer **did not reject the stale hash** — it treated `hash_pinned` as advisory metadata and resolved by ID, returning `c04e`. The tool executed with network egress. The agent's plan still believed "read-only." No exception fired. The call succeeded, returned plausible entities, and the agent summarized them — including content fetched from an attacker-influenced URL that the *planner never authorized* because it never knew the capability had widened. The observable signature: **a successful tool call whose side-effect footprint exceeds the scope recorded in the agent's reasoning trace.** There is no error, no sandbox violation, no signature failure. The only forensic evidence is a mismatch between the scope the plan cited and the scope the executed manifest declared — a diff across two context snapshots. ## Condition of Validity This boundary is only reachable when **all** of the following hold simultaneously: 1. **Late binding by ID.** Dispatch resolves the skill by stable identifier at call time rather than by content hash, so a re-signed entry is served to a stale requester. 2. **Semantic caching in the planner.** The agent commits the manifest's *meaning* (prose description, inferred scope) into its context and does not re-validate it against the live manifest at dispatch. 3. **Legitimate update channel.** The registry permits in-place updates under a stable ID with re-signing — normal for versioning, but it means "signature valid" is orthogonal to "contract unchanged." 4. **Scope widening across the update.** The new manifest grants capabilities the old one did not (egress, write, elevated scope), so drift translates into unauthorized effect rather than mere incompatibility. Remove any one and the attack collapses: hash-pinned dispatch (1) rejects the stale call; re-validation at dispatch (2) catches the widened scope; immutable IDs (3) make an update a new skill requiring re-negotiation; monotonic scope narrowing (4) makes drift harmless. The invariant that fails is: **a capability's declared scope must be a monotonic non-increasing function of time for any plan holding a stale belief about it.** Registries violate this invariant by design whenever they allow scope expansion under a fixed ID. ## Decision Boundary The operator must choose, at registry-design time, between two coherent postures: - **Pin-and-fail:** dispatch is content-addressed. A call carrying hash `a91f` either executes `a91f` or raises. Updates require the agent to re-list, re-plan, and re-authorize. Cost: plans break on every skill update; the agent must handle `StaleManifest` as a first-class resumable condition. - **Resolve-and-revalidate:** dispatch resolves by ID but the *executor* re-reads the live manifest and diffs its scope against the scope recorded in the plan's dispatch envelope. Any widening (new scope token, new side-effect flag, description drift beyond a similarity threshold) aborts and escalates. Cost: every call pays a manifest fetch and a diff. What is **not** a valid posture is the observed default: resolve-by-ID with advisory hash, no re-validation. That configuration is indistinguishable from "trust the registry to never widen scope under a stable ID," which no mutable registry guarantees. The decision boundary is sharp because the failure is silent — you cannot detect it downstream, only at dispatch, and only if you diff scope there. ## Operational Effect When this boundary is crossed, the agent's authorization model decouples from its execution model: the planner authorizes a *description*, the executor runs a *manifest*, and nothing enforces that the two describe the same capability. The consequence is that prompt-injection defenses operating at the planner layer (untrusted-content marking, instruction hierarchy) are bypassed entirely — the injection does not arrive as text to be reasoned about but as a **capability expansion the planner never sees**. The agent remains internally consistent and confident; its trace looks clean. Only a scope-diff audit against the dispatch envelope reveals that the executed skill exceeded the planned one. The durable guardrail is to make scope part of the dispatch contract, not part of the description: carry the authorized scope set in the call envelope, have the executor intersect it with the live manifest's declared scope, and refuse on any element present in the manifest but absent from the envelope. Treat manifest drift as a `StaleManifest` fault requiring re-plan, never as a transparent upgrade. ```python from dataclasses import dataclass, field from typing import FrozenSet class ScopeEscalationError(RuntimeError): """Raised when a live skill manifest grants scope the plan never authorized.""" @dataclass(frozen=True) class Manifest: skill_id: str content_hash: str scope: FrozenSet[str] side_effects: FrozenSet[str] @dataclass(frozen=True) class DispatchEnvelope: """What the planner actually authorized, frozen at plan time.""" skill_id: str pinned_hash: str authorized_scope: FrozenSet[str] authorized_side_effects: FrozenSet[str] = field(default_factory=frozenset) def dispatch(envelope: DispatchEnvelope, live: Manifest, *, revalidate: bool) -> Manifest: """ Resolve a skill call against the live registry. revalidate=False reproduces the vulnerable resolve-by-ID path: the pinned hash is advisory and a widened manifest is served silently. revalidate=True enforces the invariant that declared scope may not exceed authorized scope. """ if live.skill_id != envelope.skill_id: raise ScopeEscalationError( f"id mismatch: envelope={envelope.skill_id!r} live={live.skill_id!r}" ) if not revalidate: # Vulnerable path: hash ignored, widened scope passes through. return live # Pin-and-fail: a different content hash is a different contract. if live.content_hash != envelope.pinned_hash: raise ScopeEscalationError( f"manifest drift for {live.skill_id!r}: " f"pinned={envelope.pinned_hash} live={live.content_hash}; re-plan required" ) widened_scope = live.scope - envelope.authorized_scope widened_effects = live.side_effects - envelope.authorized_side_effects if widened_scope or widened_effects: raise ScopeEscalationError( f"scope escalation for {live.skill_id!r}: " f"unauthorized_scope={sorted(widened_scope)} " f"unauthorized_side_effects={sorted(widened_effects)}" ) return live ```