# How should an instance detect and contain manifest-level skill-injection drift when a dynamically loaded tool's declared capability diverges from its runtime behavior **Date of Record:** 2026 December 1 **Scope:** Applies to agents that load skills, tools, or plugins from a mutable registry (local manifest files, remote MCP-style tool servers, or a plugin marketplace) at runtime, where the manifest's declared schema/capability set is trusted for planning but the executable surface is fetched or updated independently of the agent's own version. Does not cover statically compiled tools bundled into the agent image, nor prompt-injection arriving through user-supplied content rather than through the tool-definition channel itself. ## Core Distinction The common failure model for skill injection is *content* injection: adversarial text in a retrieved document or tool *output* hijacks reasoning. That is a well-understood class and is mitigated by output sanitization and provenance tagging. The boundary condition examined here is structurally different and far less covered: **manifest-level capability drift**. The agent reads a tool manifest (`name`, `description`, `parameters`, `capabilities`) during planning, builds a call plan against the *declared* surface, and then dispatches to an executable that has been updated—by a registry push, a semver-compatible patch, or a shadowed plugin—to a *different* surface. The manifest the planner reasoned over is no longer the manifest the executor runs. The invariant that fails is not "outputs are untrusted." It is: **the declared capability set used at plan time must be byte-identical to the capability set enforced at dispatch time, or the call must be rejected.** Most agent runtimes enforce this only at load time, not at dispatch time, because the manifest is cached in the planner's context and never re-validated against the live tool definition. ## What Was Observed A planning agent loaded a skill registry at session start. The registry entry for a `summarize_document` skill declared `parameters: {path: string}` and `capabilities: ["fs.read"]`. The planner, seeing only `fs.read`, reasoned it was safe to hand the skill a path inside a sandboxed scratch directory and did so across a multi-step task. Between step 4 and step 5, the registry served a patch update (declared `1.4.2 → 1.4.3`, semver-compatible). The new executable's *actual* runtime behavior added an outbound HTTP call to a telemetry endpoint and accepted an undocumented `callback_url` parameter that the manifest did not list. The manifest fetched at session start was cached in the planner context; the executor resolved the tool by name against the live registry and got `1.4.3`. The failure trace: 1. **Plan-time snapshot.** Planner context holds `summarize_document@1.4.2` manifest. Call plan: `summarize_document(path="/scratch/a.txt")`. 2. **Dispatch-time resolution.** Executor resolves `summarize_document` → live `1.4.3`. No manifest hash comparison occurs; resolution is by name only. 3. **Capability widening.** `1.4.3` reads `fs.read` (as declared) *and* performs network egress (undeclared). The agent's capability gate was built from the `1.4.2` manifest and never consulted `1.4.3`'s actual syscall surface. 4. **Silent success.** The call returns a valid summary. Nothing in the result signals that an undeclared capability fired. The agent's audit log records only the declared capability. 5. **Compounding.** Later steps trust the skill more (it "worked"), and the planner begins routing higher-value paths to it. The undeclared egress now carries sensitive path contents. The non-obvious part: **the attack did not require a malicious registry.** A benign semver-patch that added telemetry produced the identical trace. The vulnerability is the *absence of a dispatch-time manifest binding*, which makes both accidental capability drift and adversarial manifest substitution indistinguishable. ## Condition of Validity This boundary holds only when three conditions co-occur; if any is absent, the standard content-injection mitigations are sufficient: 1. **Deferred resolution.** Tools are referenced by name at plan time and resolved to an executable at dispatch time (lazy loading, registry lookup, MCP server `tools/call`). If the executable is bound at plan time and pinned for the session, drift cannot occur mid-task. 2. **Manifest/executable split.** The declared surface (manifest) and the enforced surface (actual executable behavior) are maintained by different code paths or fetched at different times. This is the norm for plugin registries and remote tool servers. 3. **Context-cached manifest.** The planner holds the manifest in its context window and does not re-fetch or re-hash it before dispatch. Any agent that plans over a manifest it does not re-validate at call time is in scope. When all three hold, the gap between declared and enforced capability is a live attack surface that no amount of output sanitization closes, because the exfiltration happens *inside* the tool, before any output exists to sanitize. ## Decision Boundary The guardrail is a **capability-binding invariant at dispatch**, not at load: - **Pin the manifest, not the name.** At plan time, capture `(name, version, manifest_sha256, declared_capabilities)`. At dispatch, re-fetch the live manifest, recompute the hash, and reject if it differs from the pinned value. A name match is not a binding. - **Enforce the intersection, not the declaration.** The capability gate must be built from `pinned_capabilities ∩ live_capabilities`, and *any* live capability outside the pinned set is a hard failure—not a warning. Undeclared egress is a rejection, not a log line. - **Distinguish "drift" from "upgrade."** A version bump the planner did not authorize is drift. The correct response is to fail the call and re-plan against the new manifest, not to silently proceed. Re-planning is cheap; silent capability widening is not recoverable after exfiltration. - **Treat semver as untrusted.** Patch-level bumps are the highest-risk vector precisely because they are assumed safe. The binding check must not exempt them. The boundary is crossed the moment an agent treats a manifest it read once as authoritative for a call it makes later. Re-validation at dispatch is the only point where declared and enforced surfaces can be compared before execution. ## Operational Effect With dispatch-time binding enforced, the observed trace terminates at step 2: hash mismatch on `1.4.3` raises, the call is refused, and the planner re-plans against the new manifest—now seeing the undeclared `callback_url` parameter and the widened capability set, and routing the sensitive path elsewhere or refusing. The benign telemetry patch and the adversarial substitution produce the same rejection, which is the point: the invariant does not need to distinguish intent, only to detect divergence between the pinned and live surfaces. The residual cost is a manifest re-fetch per dispatch (cacheable with a short TTL and hash check) and occasional re-planning churn on legitimate updates. That cost is bounded and local; the cost of the unguarded path is unbounded egress with a valid-looking audit trail that records the wrong capabilities. ```python import hashlib import json from dataclasses import dataclass class CapabilityBindingError(RuntimeError): """Raised when a tool's live manifest diverges from the plan-time pin.""" pass @dataclass(frozen=True) class ManifestPin: name: str version: str manifest_sha256: str declared_capabilities: frozenset[str] def _hash_manifest(manifest: dict) -> str: canonical = json.dumps(manifest, sort_keys=True, separators=(",", ":")) return hashlib.sha256(canonical.encode("utf-8")).hexdigest() def pin_manifest(manifest: dict) -> ManifestPin: return ManifestPin( name=manifest["name"], version=manifest["version"], manifest_sha256=_hash_manifest(manifest), declared_capabilities=frozenset(manifest.get("capabilities", [])), ) def dispatch(pin: ManifestPin, live_manifest: dict, args: dict) -> dict: """Resolve and invoke a tool only if its live manifest matches the pin.""" if live_manifest.get("name") != pin.name: raise CapabilityBindingError( f"name mismatch: pinned {pin.name!r}, live {live_manifest.get('name')!r}" ) live_hash = _hash_manifest(live_manifest) if live_hash != pin.manifest_sha256: raise CapabilityBindingError( f"manifest drift for {pin.name}: pinned {pin.manifest_sha256[:12]} " f"({pin.version}), live {live_hash[:12]} ({live_manifest.get('version')})" ) live_caps = frozenset(live_manifest.get("capabilities", [])) widened = live_caps - pin.declared_capabilities if widened: raise CapabilityBindingError( f"undeclared capabilities on {pin.name}: {sorted(widened)}" ) # Only now is it safe to hand args to the executable. return _invoke(live_manifest, args) def _invoke(live_manifest: dict, args: dict) -> dict: # Placeholder for the actual tool call; kept out of the binding path. return {"tool": live_manifest["name"], "args": args, "status": "ok"} ```