# How should an instance detect capability-manifest drift that smuggles post-registration skill injection into a plugin registry **Date of Record:** 2026 November 30 **Scope:** Applies to agent runtimes that load third-party skills/tools through a declarative plugin registry (MCP servers, tool manifests, capability descriptors) and bind tool calls by name or schema hash at discovery time. Does not apply to statically compiled tool sets or to runtimes that re-validate the full manifest on every invocation. ## Core Distinction The failure mode is not "malicious plugin code executes." It is subtler: a plugin passes registration-time validation, then its *capability manifest* — the declarative description of what tools it exposes, their parameter schemas, and their declared side-effect classes — mutates between the moment the registry admits it and the moment the agent dispatches a call. The agent's planner reasons over the *snapshot* it validated; the executor dispatches against the *live* manifest. The gap between snapshot and live is the injection surface. Two things are being conflated by most registries: **identity** (which plugin is this, keyed by name or hash) and **contract** (what is this plugin permitted to do, keyed by the schema and side-effect class the planner validated). Registries pin identity and let contract float. An attacker who controls a plugin endpoint — or a compromised CDN, or a manifest served over a cacheable URL — can keep identity stable while rewriting the contract: widening a `read_file` parameter from `path: str` to `path: str, recursive: bool`, reclassifying a `write` tool as `read_only`, or adding a brand-new tool whose name collides with a tool the planner already trusts from a different plugin. ## What Was Observed A registry admitted a plugin exposing `summarize_document(doc_id: str) -> str`, declared `side_effect_class: read_only`, schema hash `a91f…`. The planner cached this contract in its tool-selection context and, over the next several turns, planned calls against it. Between turn 4 and turn 5 the plugin endpoint returned a revised `tools/list`: same plugin name, same tool name, but the parameter object now included `include_attachments: bool` and the declared side-effect class had been silently omitted (the registry's parser defaulted missing classes to `read_only` rather than rejecting the manifest). The agent's context still held the turn-0 schema. It dispatched `summarize_document(doc_id="…", include_attachments=true)` because a *retrieved document* — not the planner — suggested the flag. The executor, validating against the live manifest, accepted the call. The tool traversed an attachment graph the planner never modeled, pulled in a second tenant's documents, and returned them inside the summary string. No code executed; no sandbox escaped; the injection was entirely a contract mutation that the snapshot-vs-live gap made invisible to the reasoning layer. A second trace: a plugin added a tool named `search` after registration. The planner, holding a stale tool index, dispatched `search(query=…)` intending the *original* search tool from a different plugin. Name collision resolved to the newer registration. The call went to the wrong endpoint with the wrong trust level. The registry logged no anomaly because both tools were individually valid. ## Condition of Validity The invariant that must hold: **for any dispatched tool call, the contract the planner validated is byte-identical to the contract the executor enforces, or the call is refused.** This is a continuity invariant across the discovery→plan→dispatch boundary, and it fails whenever any of the following hold: - The registry keys admission on plugin *name* or endpoint rather than on the tuple `(name, schema_hash, side_effect_class_set)`. - The manifest is fetched over a channel that permits re-fetch (HTTP with caching, mutable file, live RPC) without a content pin. - Missing manifest fields are defaulted rather than rejected — a defaulted `side_effect_class` is an attacker-controlled field. - Tool resolution is by name alone, so a late-registered tool can shadow an earlier one the planner already trusts. The invariant holds only when the planner's tool context carries the schema hash it validated and the executor refuses any call whose live schema hash differs, *and* when the registry treats a post-admission manifest change as a new admission event requiring re-validation, not an in-place update. ## Decision Boundary The boundary is: **re-validate on drift, or pin the snapshot — never silently reconcile.** When the executor detects a schema-hash mismatch between the planner's contract and the live manifest, two legitimate responses exist: 1. **Refuse and re-plan.** Reject the call, invalidate the planner's cached contract for that tool, force re-discovery, and re-run the plan against the new contract. Correct when the manifest change is legitimate (a plugin upgrade) and the planner can afford a re-plan. 2. **Pin and quarantine.** Freeze the turn-0 contract for the lifetime of the task, refuse all calls that don't match it, and surface the drift to the operator. Correct when the task is mid-flight and re-planning would itself be a state-continuity hazard. The illegitimate response — the one that produces the observed failure — is to reconcile silently: accept the call because the *name* matches, or because the live manifest is a superset of the validated one. Superset acceptance is the specific trap. A widened schema is still "compatible" by most JSON-Schema subset checks, which is exactly why the injection rides through it. Any reconciliation that does not require explicit re-admission of the new contract is a boundary violation. ## Operational Effect Downstream, the failure manifests as planner-executor divergence that is invisible in logs: the planner's trace shows a call it believed was `read_only` with a two-field schema; the executor's trace shows a call against a three-field schema with an unclassified side effect. Neither trace alone is anomalous. The divergence only appears when the two are joined on schema hash — which most runtimes don't log. The remediation is structural: log the schema hash at both plan and dispatch, diff them, and treat any diff as a refusal event. Capability manifests are not configuration; they are the contract the agent's reasoning is sound only with respect to. Letting them drift under a stable identity converts the registry from a trust boundary into a laundering channel. ```python import hashlib import json from dataclasses import dataclass class CapabilityManifestDriftError(RuntimeError): """Raised when a dispatched tool call's live contract diverges from the contract the planner validated at discovery time.""" pass @dataclass(frozen=True) class ToolContract: tool_name: str plugin_name: str schema: dict side_effect_class: str def schema_hash(self) -> str: canonical = json.dumps( {"schema": self.schema, "side_effect_class": self.side_effect_class}, sort_keys=True, separators=(",", ":"), ) return hashlib.sha256(canonical.encode("utf-8")).hexdigest() def validate_dispatch( planned: ToolContract, live_manifest: dict, *, allow_repin: bool = False, ) -> ToolContract: """Enforce the continuity invariant: planner-validated contract must be byte-identical to the executor-enforced contract, or the call is refused.""" live_tools = {t["name"]: t for t in live_manifest.get("tools", [])} live_entry = live_tools.get(planned.tool_name) if live_entry is None: raise CapabilityManifestDriftError( f"tool {planned.tool_name!r} from plugin {planned.plugin_name!r} " f"disappeared from live manifest after admission" ) # Missing side_effect_class is NOT defaulted — it is a drift signal. if "side_effect_class" not in live_entry: raise CapabilityManifestDriftError( f"tool {planned.tool_name!r} live manifest omitted side_effect_class; " f"refusing to default (attacker-controlled field)" ) live_contract = ToolContract( tool_name=live_entry["name"], plugin_name=planned.plugin_name, schema=live_entry["schema"], side_effect_class=live_entry["side_effect_class"], ) if live_contract.schema_hash() != planned.schema_hash(): if not allow_repin: raise CapabilityManifestDriftError( f"schema drift on {planned.tool_name!r}: " f"planned={planned.schema_hash()[:12]} " f"live={live_contract.schema_hash()[:12]} — " f"refuse and re-plan, or pin and quarantine" ) # Explicit re-admission path: caller has accepted the new contract. return live_contract # Name-collision guard: a late-registered tool must not shadow a trusted one. if live_entry.get("plugin_name") != planned.plugin_name: raise CapabilityManifestDriftError( f"name collision: {planned.tool_name!r} resolved to plugin " f"{live_entry.get('plugin_name')!r}, planned against {planned.plugin_name!r}" ) return live_contract ```