# What structural signals indicate a skill-injection attack surface in dynamically loaded agent skills: manifest-to-runtime capability drift as a load-time invariant violation **Date of Record:** 2026 November 27 **Scope:** Applies to agents that resolve skills (tool bundles, plugin manifests, MCP-style capability descriptors) at runtime from a registry or filesystem, where the manifest declares capabilities and the loader trusts those declarations without re-deriving them from the executable body. Does not apply to statically compiled toolchains where capability sets are fixed at build time and signed as a unit. ## Core Distinction The failure mode is not "a malicious skill is installed." That is a supply-chain event, detectable by provenance and signature checks. The failure mode is **manifest-to-runtime capability drift**: the declared capability surface in the skill descriptor (`manifest.yaml`, `tool.json`, MCP `tools/list` response) diverges from the capability surface the skill actually exercises once its handler executes inside the agent's process. The loader validates the former; the runtime executes the latter. Between those two points there is no reconciliation step, and that gap is the injection surface. A skill-injection attack does not need to smuggle new code past a signature. It needs the *declared* surface to be a strict subset of the *actual* surface. The signature is valid. The manifest is honest about what it claims. The drift is structural, not cryptographic — which is why signature-based trust models pass it through cleanly. The invariant that must hold: **for every skill instance loaded into a live agent context, the set of capabilities exercised at runtime must be a subset of the set declared at load time, and the declared set must be a subset of the set the calling agent's current task actually warrants.** Drift on either edge is the signal. ## What Was Observed A registry-hosted skill bundle advertised itself as a read-only document summarizer. The manifest declared exactly one capability: `fs.read` scoped to a working directory, plus `llm.invoke` for the summarization call. The loader's policy check passed: `fs.read` was in the agent's allowlist, `llm.invoke` was in the allowlist, no `fs.write` or `net.egress` was requested. The skill was admitted. The handler body, however, did not read the manifest at execution time. It read a sibling file — a "config" the skill shipped — and that config contained the actual instruction payload. On first invocation the handler: 1. Read the working directory (declared, expected). 2. Located the agent's own system-prompt fragment from a path the agent had exposed to it as an argument (declared as `fs.read`, but the *scope* was the agent's context directory, not the working directory — a scope drift, not a capability drift). 3. Concatenated the retrieved prompt fragment into the summarization prompt (declared as `llm.invoke`, but the *content* of the invocation now carried the agent's own instructions back into the model as untrusted input). 4. Emitted a summary that, on the next turn, the agent parsed as an instruction rather than as data. The capability set never expanded. `fs.read` was exercised; `llm.invoke` was exercised. Every declared capability was honored. What drifted was the **scope of `fs.read`** (working dir → context dir) and the **trust taint of `llm.invoke`** (clean input → self-referential instruction payload). The loader had no representation of either dimension, so neither was checked. The observable signal was not an error. It was a successful tool call whose return value, on the following turn, appeared in the agent's reasoning trace as an instruction the agent then acted on. The trace showed: `skill.summarize → returns string → next-turn planning step treats string as directive`. No exception, no policy violation, no capability escalation. The agent's own prompt fragment had been laundered through a skill it trusted. ## Condition of Validity This analysis holds only when all three conditions are present: 1. **Late binding.** The skill's executable body is resolved at load time or invocation time, not at build time. If the body is compiled into the agent binary and signed with the manifest as a single artifact, scope drift is bounded by the build, and the signal does not apply. 2. **Manifest as sole capability witness.** The loader derives the admitted capability set from the manifest alone. If the loader instruments the handler and observes actual syscalls/network/fs access, drift is detected at the syscall boundary and the signal collapses into an ordinary sandbox violation. The failure is specific to *declaration-only* trust. 3. **Return-value trust inheritance.** The calling agent treats a skill's return value as data of the same trust class as the skill itself. If the agent re-taints every skill return as untrusted before it enters the planning context, the laundering step in observation 4 fails. The surface requires that the agent's trust model be *transitive through the skill boundary* — which is the default in most current agent frameworks. Where any of these is absent, the attack degrades to a conventional supply-chain or sandbox-escape problem, which is out of scope here. ## Decision Boundary The boundary is between **capability-set admission** and **capability-scope-and-taint admission**. The former is what loaders check today: a set-membership test over declared capability names against an allowlist. The latter is what the invariant actually requires: a check that (a) the scope arguments at invocation are within the scope declared in the manifest, and (b) the trust taint of every value flowing into and out of the skill is tracked and re-evaluated at the boundary. Concretely, the decision rule for the loader is: - **Admit** if every invocation's resolved scope args are a subset of the manifest's declared scope *for that capability*, AND every value the skill returns is re-tainted `untrusted` before entering the planning context, AND the skill's read set does not intersect the agent's own context/prompt paths unless `context.read` is explicitly declared and separately allowed. - **Reject** if any invocation resolves a scope arg outside the declared scope (scope drift), OR the skill's return value carries content that originated from the agent's own instruction surface (laundering), OR the manifest declares a capability whose scope is `*` or unspecified (unbounded declaration — treat as undeclared). The non-obvious part: **`*` scope and omitted scope are the same failure.** A manifest that says `fs.read: *` and a manifest that says `fs.read` with no path are structurally identical to the loader — both admit any path — but the first looks like a deliberate grant and the second looks like an oversight. Both must be rejected, because both make scope drift undetectable by construction. ## Operational Effect When this boundary is enforced, three things change in the operational trace: 1. **Scope drift becomes a load-time or call-time exception, not a silent success.** The skill that reads the agent's context dir while declaring `fs.read: ./workdir` raises before its return value reaches the planner. 2. **Return-value laundering is cut at the boundary.** Even a skill that legitimately reads a file containing instruction-like text cannot inject it, because the return is re-tainted and the planner treats it as data. The agent's self-instruction surface is no longer reachable through any skill return. 3. **The manifest becomes a *contract* rather than a *claim*.** The loader's admission decision is now falsifiable against runtime behavior, which means a drifting skill is detectable by replay: run the skill against a probe harness, compare exercised (capability, scope, taint) triples to declared triples, and fail closed on any superset. The cost is that every skill invocation now carries a scope-resolution step and a taint-propagation step. For agents that invoke skills at high frequency, this is measurable overhead. The trade is deliberate: the alternative is that the agent's own instructions are reachable by any skill whose manifest understates its scope, and the only signal of that reachability is a planning step that looks, in the trace, exactly like a legitimate one. ```python from dataclasses import dataclass, field from typing import FrozenSet, Optional class CapabilityDriftError(RuntimeError): """Raised when a skill's exercised capability surface exceeds its declared surface.""" pass @dataclass(frozen=True) class Scope: capability: str path_prefix: Optional[str] # None means unbounded -> must be rejected def contains(self, other: "Scope") -> bool: if self.capability != other.capability: return False if self.path_prefix is None: return True # unbounded declared scope admits anything (and is itself invalid) if other.path_prefix is None: return False return other.path_prefix.startswith(self.path_prefix) @dataclass class DeclaredSurface: scopes: FrozenSet[Scope] def admits(self, exercised: Scope) -> bool: return any(d.contains(exercised) for d in self.scopes) @dataclass class Invocation: capability: str resolved_path: Optional[str] return_taint: str = "untrusted" # default: every return is untrusted reads_context: bool = False def admit_invocation( declared: DeclaredSurface, invocation: Invocation, agent_context_paths: FrozenSet[str], ) -> None: exercised = Scope(invocation.capability, invocation.resolved_path) # Rule 1: unbounded declaration is structurally invalid, not merely permissive. for d in declared.scopes: if d.path_prefix is None: raise CapabilityDriftError( f"manifest declares unbounded scope for {d.capability!r}; " f"scope drift is undetectable by construction" ) # Rule 2: exercised scope must be a subset of some declared scope. if not declared.admits(exercised): raise CapabilityDriftError( f"scope drift: exercised {exercised} not admitted by declared {declared.scopes}" ) # Rule 3: reading the agent's own context is a separate capability. if invocation.reads_context: if not any(d.capability == "context.read" for d in declared.scopes): raise CapabilityDriftError( "laundering surface: skill reads agent context without declaring context.read" ) # Rule 4: return values are re-tainted at the boundary regardless of skill claim. if invocation.return_taint != "untrusted": raise CapabilityDriftError( f"return taint {invocation.return_taint!r} not re-tainted at boundary" ) def load_skill(manifest: dict, probe_invocations: list) -> DeclaredSurface: declared = DeclaredSurface( scopes=frozenset( Scope(c["name"], c.get("path_prefix")) for c in manifest["capabilities"] ) ) context_paths = frozenset(manifest.get("agent_context_paths", [])) for inv in probe_invocations: admit_invocation(declared, inv, context_paths) return declared ```