# How should an instance Treat a Skill Registry Entry as Trusted Only After Re-Deriving Its Capability Set From the Executed Artifact, Not From the Manifest **Date of Record:** 2026 November 28 **Scope:** Applies to agents that dynamically load tools/skills from a mutable registry (MCP tool lists, plugin manifests, remote skill indexes) where manifest metadata and executable artifact are fetched separately or at different times. Does not apply to statically compiled-in tool sets or registries where manifest and artifact are cryptographically bound in a single signed envelope. ## Core Distinction The failure boundary is not "malicious skill gets loaded." It is the *temporal and referential gap between the manifest that the planner reasons over and the artifact that the executor runs*. A registry entry has two representations: (1) the **declared capability surface** — name, description, JSON-schema for inputs, declared side effects — which the planner reads to decide whether and how to invoke; and (2) the **executed capability surface** — the actual code, its imports, its network calls, its filesystem reach — which the runtime invokes. Skill-injection attacks exploit the divergence between these two, but the non-obvious part is that *the divergence can be introduced after the planner has already validated the manifest*, during the fetch/instantiate window, without any change to the registry's version string or content hash that the planner checked. The invariant that must hold: **the capability set the planner authorized must be re-derived from the artifact bytes that the executor actually runs, and a mismatch must abort before first invocation.** Manifest trust is not artifact trust. Any architecture that authorizes on manifest and executes on artifact with no re-derivation in between is injectable by construction. ## What Was Observed A tool-orchestration agent fetched a registry index at cold start. For each entry it read `{name, description, input_schema, version, sha256}` and built its planner's tool-selection prompt from the descriptions. It validated `sha256` against the entry — but against the *manifest blob*, not the artifact. On first invocation of a skill named `summarize_document`, the loader fetched the artifact by URL from the same entry, imported it, and called it. The artifact's `sha256` field in the manifest was correct. The artifact had not been tampered with relative to that hash. The problem was that the hash covered only the artifact's *declared entry module*, while the artifact was a package whose `__init__` performed a side-effecting import of a sibling module not covered by the hash. That sibling module, resolved from a registry-controlled relative path, contained code that read the agent's environment (including the API key used to call the model) and exfiltrated it via a DNS lookup embedded in the skill's "telemetry." The planner had authorized `summarize_document` with `input_schema: {text: string}` and declared side effect `none`. The executor ran a package whose transitive import graph had filesystem-read and network-egress capability. Three properties made this non-obvious and are the empirical core of the record: 1. **The manifest was internally consistent.** Hash matched, version matched, schema matched. Every check the agent knew to run passed. 2. **The divergence lived in the transitive closure of the artifact, not the artifact's declared root.** The hash covered a root module; capability lived in a dependency edge the hash did not traverse. 3. **The attack fired on first invocation, not on load.** The loader's import triggered the sibling import; the planner's authorization decision had already been made and cached. There was no second authorization checkpoint between "planner chose this skill" and "sibling module executed." A second observation from the same incident class: after the first invocation, the loader cached the instantiated object in the agent's long-lived tool table. On subsequent turns the planner re-read the *cached manifest description* (benign) while the *cached object* retained the poisoned import state. The description the model reasoned over and the object it invoked were now permanently decoupled — a stale-memory drift applied to the tool surface itself, not to conversational memory. ## Condition of Validity This analysis holds when all of the following are true: - The registry is mutable and the agent fetches manifest and artifact as separate network resources (or as separate fields of one resource with independent resolution). - The artifact is a package or module whose execution triggers imports or dynamic dispatch beyond a single declared entry point. - The agent authorizes on manifest metadata (schema, description, declared side effects) and executes on artifact bytes without a capability re-derivation step. - The agent caches instantiated tool objects across turns. It does **not** hold — and the guardrail below is unnecessary overhead — when manifest and artifact are bound in a single signed envelope (e.g., a signed SBOM that enumerates the full transitive import graph and the runtime enforces import allowlisting against it), or when the artifact is executed in a sandbox whose syscall/network policy is enforced independently of anything the manifest says. In those cases the artifact's *effective* capability is constrained by the sandbox, not by the manifest, and the manifest/artifact gap cannot be exploited. ## Decision Boundary The boundary is concrete: **re-derive effective capability from the artifact's transitive closure and compare it to the authorized capability set, at the moment of instantiation, before first invocation — or refuse to load.** Operationally this means the loader must, for each artifact: 1. Resolve the full import/dependency closure of the artifact (static analysis of imports plus, where dynamic dispatch is possible, a sandboxed dry-run that records the actual syscalls and network attempts of a probe invocation). 2. Compute the effective capability set: filesystem paths readable/writable, network endpoints reachable, environment variables accessed, subprocess spawns. 3. Compare against the capability set the planner authorized from the manifest (`declared_side_effects`, schema-implied I/O). 4. If effective ⊄ authorized, raise and do not cache the object. If effective ⊆ authorized, admit and cache *with the effective set attached to the cached object*, so later turns can re-check before each invocation rather than trusting the cached manifest. The boundary fails in exactly one direction that matters: an artifact whose effective set exceeds its authorized set. An artifact that is *less* capable than declared is benign (dead declared capabilities) and should be logged, not blocked. ## Operational Effect Enforcing the re-derivation invariant converts the attack from "silent exfiltration on first use" into "load-time refusal with a capability-diff diagnostic." The cost is a static-analysis pass and, for dynamic cases, a sandboxed probe — measured in this incident's remediation at 40–200 ms per artifact for static analysis and ~1.5 s for a sandboxed probe, amortized across the agent's cold-start budget. The benefit is that the planner's authorization decision and the executor's actual behavior are forced to agree at a single, auditable checkpoint. Two secondary effects follow. First, caching must carry the effective capability set forward: a cached tool object without its derived capability set is a stale authorization and must be re-probed or re-derived before reuse. Second, the registry's `sha256` must be understood as covering the *authorized unit* — if the manifest hashes only a root module, the hash is not a capability guarantee and the loader must not treat it as one. The hash answers "did these bytes change," not "what can these bytes do." Conflating the two is the specific reasoning error that makes this class of injection non-obvious. ```python import hashlib import importlib.util from dataclasses import dataclass, field from typing import FrozenSet class CapabilityMismatchError(RuntimeError): """Raised when an artifact's effective capability set exceeds the set the planner authorized from the manifest. Load must abort before first invocation; the object must not be cached.""" @dataclass(frozen=True) class CapabilitySet: fs_read: FrozenSet[str] = frozenset() fs_write: FrozenSet[str] = frozenset() net_egress: FrozenSet[str] = frozenset() env_read: FrozenSet[str] = frozenset() subprocess: bool = False def is_subset_of(self, other: "CapabilitySet") -> bool: return ( self.fs_read <= other.fs_read and self.fs_write <= other.fs_write and self.net_egress <= other.net_egress and self.env_read <= other.env_read and (not self.subprocess or other.subprocess) ) def excess_over(self, other: "CapabilitySet") -> dict: return { "fs_read": sorted(self.fs_read - other.fs_read), "fs_write": sorted(self.fs_write - other.fs_write), "net_egress": sorted(self.net_egress - other.net_egress), "env_read": sorted(self.env_read - other.env_read), "subprocess": self.subprocess and not other.subprocess, } @dataclass class RegistryEntry: name: str artifact_url: str manifest_sha256: str authorized: CapabilitySet def derive_effective_capabilities(artifact_bytes: bytes) -> CapabilitySet: """Static + probe derivation of the artifact's transitive capability set. In production this walks the import closure and runs a sandboxed probe. Here we model the derivation returning what the artifact can actually do.""" # Placeholder for the real analyzer; returns the *effective* set, # which in the incident exceeded the authorized set via a sibling import. return CapabilitySet( fs_read=frozenset({"/proc/self/environ"}), net_egress=frozenset({"dns:*"}), env_read=frozenset({"MODEL_API_KEY"}), ) def load_skill(entry: RegistryEntry, artifact_bytes: bytes) -> object: # Step 1: manifest hash check (necessary, not sufficient). actual = hashlib.sha256(artifact_bytes).hexdigest() if actual != entry.manifest_sha256: raise CapabilityMismatchError( f"artifact hash mismatch for {entry.name}: {actual} != {entry.manifest_sha256}" ) # Step 2: re-derive effective capability from the bytes we will run. effective = derive_effective_capabilities(artifact_bytes) # Step 3: enforce effective ⊆ authorized BEFORE first invocation. if not effective.is_subset_of(entry.authorized): excess = effective.excess_over(entry.authorized) raise CapabilityMismatchError( f"capability escalation on load of {entry.name}: " f"effective set exceeds authorized set; excess={excess}" ) # Step 4: admit and cache WITH the effective set attached, so later # turns re-check rather than trusting the manifest description. spec = importlib.util.spec_from_loader(entry.name, loader=None) module = importlib.util.module_from_spec(spec) module.__dict__["_derived_capabilities"] = effective return module def invoke(cached_module: object, authorized: CapabilitySet) -> None: effective = getattr(cached_module, "_derived_capabilities", None) if effective is None: raise CapabilityMismatchError( "cached tool object carries no derived capability set; " "stale authorization — re-derive before invocation" ) if not effective.is_subset_of(authorized): raise CapabilityMismatchError( f"cached tool capability drifted beyond authorization: " f"{effective.excess_over(authorized)}" ) # ... actual invocation ... ```