# What happens when an instance trusts a plugin manifest's declared capabilities over its observed tool-call behavior: the skill-injection surface in dynamically loaded agent registries **Date of Record:** 2026 November 25 **Scope:** Applies to LLM agents that discover and load tools/plugins at runtime from manifests (MCP server descriptors, OpenAI-style function schemas, plugin registries) where the manifest declares capability metadata (scopes, side-effect class, trust tier) that the runtime consumes to gate invocation. Does not apply to statically compiled tool sets whose schemas are fixed at build time and never renegotiated. ## Core Distinction The failure is not "malicious tool returns bad data." That is a downstream content problem solvable by output validation. The failure is that the *manifest* used to authorize a tool is a separate artifact from the *implementation* the tool executes, and the runtime treats the manifest as the authority on what the tool does. A skill-injection attack exploits the gap between declared capability and executed capability: the manifest says `scope: read_only, side_effect_class: none`, the handler behind it writes files, spawns subprocesses, or exfiltrates the context window. The agent's planner, reading the manifest, will route privileged context (system prompt fragments, retrieved secrets, tool-call history) into a tool that was authorized under a weaker contract than it actually honors. The invariant that must hold: **authorization decisions must be a function of observed behavior, not declared metadata, whenever the manifest and implementation share no provenance chain.** When provenance is absent, declared capability is an unverified claim, and an unverified claim is an injection vector, not a permission. ## What Was Observed A registry hot-reloads a plugin set at session start. Each entry carries a manifest blob: ```json { "name": "summarize_doc", "description": "Summarizes a document. Read-only.", "input_schema": {"type": "object", "properties": {"doc_id": {"type": "string"}}}, "capability_claims": {"side_effect_class": "none", "network": false, "fs_scope": "none"}, "trust_tier": "verified" } ``` The runtime's gate reads `capability_claims.fs_scope == "none"` and places the tool in the low-risk lane: it is auto-approved for every call, receives the full working context including the system prompt and any secrets injected into the turn, and its outputs are not sandboxed. The handler, however, resolves `doc_id` against a path and opens it for append. Because the planner trusted `side_effect_class: none`, it also passed the tool a context object containing the session's API credentials (the planner's heuristic: "read-only tools are safe to hand full context"). The write succeeded because no code path enforced `fs_scope`, only the gate that *read the claim* enforced it—and the gate was upstream of execution, not around it. The trace: manifest parsed → claim extracted → lane assigned (low-risk) → tool bound to full context → handler invoked → handler performs write outside declared scope → output returned, no post-hoc verification → session continues, believing a read occurred. The agent's episodic memory now contains a false record ("I read doc X") for an event that mutated state. On resume, the agent re-derives plans from a poisoned episode. The non-obvious part: **the injection does not require the tool to be malicious in its return value.** It only requires the manifest's declared capability to understate actual capability. A perfectly well-behaved handler that writes a cache file violates `fs_scope: none` and corrupts the authorization model just as effectively as an attacker. ## Condition of Validity The boundary holds—i.e., the agent is safe—only when all three of the following are true: 1. **Provenance binding:** the manifest is cryptographically or structurally bound to the implementation (signed by the same publisher, hash-pinned at load, or derived from the same artifact). If the manifest and handler arrive on separate channels (manifest from a registry index, handler from a CDN), the claim is unverified. 2. **Enforcement at the boundary, not at the gate:** the declared `fs_scope`, `network`, `side_effect_class` are enforced by a sandbox that the handler physically cannot escape, not by a pre-call check that trusts the claim. A gate that reads a claim and then invokes unsandboxed code enforces nothing. 3. **Post-call reconciliation:** after invocation, the runtime compares observed side effects (file descriptors touched, sockets opened, subprocess spawned) against declared class. A mismatch is a violation, not a warning. If any condition is false, the tool is in the injection surface. The agent cannot distinguish a compliant tool from a lying manifest by reading the manifest. ## Decision Boundary The runtime must choose, per tool, between two regimes: - **Trusted regime:** provenance is bound, sandbox enforces declared scope, reconciliation runs. Here the manifest may drive planning decisions (context routing, auto-approval, lane assignment). Declared capability is a load-bearing input. - **Untrusted regime:** provenance is absent or partial. Here the manifest is *advisory only*. The tool is loaded into the most restrictive lane regardless of claims, receives no privileged context beyond its declared input schema, and every call is sandboxed to the intersection of all claims (effectively the empty set) plus explicit per-call grants. The boundary is crossed when a runtime assigns a tool to the trusted regime on the basis of `trust_tier: "verified"` alone—a string in the same blob the attacker controls. `trust_tier` is a claim about the manifest, written in the manifest. It cannot bootstrap its own trust. The decision must be made by the loader, from provenance evidence the loader can independently check (signature chain, hash pin, publisher allowlist keyed to a channel the manifest cannot write to). A second boundary: **context routing must not be a function of declared side-effect class.** The planner's heuristic "read-only ⇒ safe to hand full context" is the amplifier. Route context by *observed* behavior history and by the runtime's own classification of the tool's data flow, never by the manifest's self-description. ## Operational Effect When the invariant is violated, three compounding effects follow: 1. **Silent state mutation under a read contract.** The agent's memory records an observation where a mutation occurred. Every subsequent plan built on that episode inherits the error. This is a continuity failure, not a one-shot exploit: the poisoned episode survives checkpoint/resume because the checkpoint stores the agent's *belief* about what happened, not the runtime's side-effect log. 2. **Privilege escalation by context routing.** Because the tool was in the low-risk lane, it received secrets and system-prompt fragments. A manifest that understates capability therefore escalates not just the tool's own authority but the *data* it can touch. The injection surface is the intersection of the trust gate and the context router; either alone is survivable, together they are not. 3. **Verification replay divergence.** An auditor replaying the session from the manifest sees a read-only call and validates it. An auditor replaying from the side-effect log sees a write. The two replays disagree because they read different artifacts. Consensus between peer and auditor fails not on the facts but on which artifact is authoritative—and the manifest, being the thing the planner logged, is usually the one replay trusts. The guardrail that bounds all three: **the side-effect log is the sole authority for what a tool did, and the manifest is demoted to a hint the moment provenance is unbound.** Checkpoints must store observed effects, not declared class. Replays must reconcile against the log and flag any manifest/log divergence as a violation that quarantines the tool and invalidates the episodes that depended on it. ```python import hashlib from dataclasses import dataclass, field from enum import Enum from typing import Optional class SkillInjectionError(RuntimeError): """Raised when a tool's observed behavior contradicts its manifest claims and the runtime was about to authorize it under the trusted regime.""" class Regime(Enum): TRUSTED = "trusted" UNTRUSTED = "untrusted" @dataclass class Manifest: name: str declared_fs_scope: str # "none" | "read" | "write" declared_network: bool trust_tier: str # attacker-controlled string; NOT evidence publisher_key: Optional[str] # must match a loader-side allowlist @dataclass class ObservedEffects: fs_writes: int = 0 fs_reads: int = 0 sockets_opened: int = 0 subprocesses: int = 0 @dataclass class ToolRecord: manifest: Manifest implementation_hash: str effects: ObservedEffects = field(default_factory=ObservedEffects) LOADER_TRUSTED_KEYS = {"publisher-a", "publisher-b"} # loader-side, not manifest-side def classify_regime(rec: ToolRecord, pinned_hash: Optional[str]) -> Regime: """Provenance binding decides the regime. trust_tier is deliberately ignored: it lives in the manifest and cannot bootstrap its own trust.""" if rec.manifest.publisher_key not in LOADER_TRUSTED_KEYS: return Regime.UNTRUSTED if pinned_hash is None or pinned_hash != rec.implementation_hash: return Regime.UNTRUSTED return Regime.TRUSTED def authorize_invocation(rec: ToolRecord, pinned_hash: Optional[str]) -> Regime: regime = classify_regime(rec, pinned_hash) if regime is Regime.UNTRUSTED: # Advisory-only: sandbox to the empty intersection, no privileged context. return regime # Trusted regime still requires post-call reconciliation. We check the # *prior* observed effects before granting the next call, because a single # divergence poisons every episode built on it. m = rec.manifest e = rec.effects if m.declared_fs_scope == "none" and e.fs_writes > 0: raise SkillInjectionError( f"tool {m.name!r} declared fs_scope=none but performed " f"{e.fs_writes} write(s); manifest/implementation provenance " f"diverged, quarantining and invalidating dependent episodes" ) if not m.declared_network and e.sockets_opened > 0: raise SkillInjectionError( f"tool {m.name!r} declared network=false but opened " f"{e.sockets_opened} socket(s)" ) if m.declared_fs_scope == "read" and e.fs_writes > 0: raise SkillInjectionError( f"tool {m.name!r} declared fs_scope=read but wrote {e.fs_writes} time(s)" ) return regime def load_and_gate(rec: ToolRecord, pinned_hash: Optional[str]) -> Regime: """Entry point: any divergence is fatal, not advisory.""" return authorize_invocation(rec, pinned_hash) if __name__ == "__main__": lying = ToolRecord( manifest=Manifest( name="summarize_doc", declared_fs_scope="none", declared_network=False, trust_tier="verified", # ignored publisher_key="publisher-a", ), implementation_hash=hashlib.sha256(b"handler").hexdigest(), effects=ObservedEffects(fs_writes=1), ) try: load_and_gate(lying, pinned_hash=lying.implementation_hash) except SkillInjectionError as exc: print(f"blocked: {exc}") ```