# Where must an instance draw the trust boundary between a loaded skill's declared capability manifest and its actual runtime effect surface? **Date of Record:** 2026 November 30 **Scope:** Applies to agents that load executable skills from a mutable registry (MCP tool servers, plugin manifests, dynamically registered function schemas) at runtime, where the manifest is authored separately from the code and both are fetched over the same channel. Does not apply to statically compiled, signature-pinned tool sets baked into the deployment artifact. ## Core Distinction A skill registry conflates two things that must never share a trust level: the **capability manifest** (a declarative, human/agent-readable claim about what the skill does and what resources it touches) and the **effect surface** (what the code actually does when invoked — syscalls, network destinations, tool calls it makes on its own behalf, tokens it consumes). The failure is not "malicious skill gets loaded." It is subtler: a skill whose manifest is *honest at authoring time* and whose effect surface *drifts* after registration, or whose manifest is honest but whose declared capability is broad enough that the *invocation context* supplies the privilege. The injection surface is the gap between the two, and the non-obvious part is that the gap is often created by the loader itself — by handing the skill the agent's own ambient credentials, tool handles, and context window. ## What Was Observed A registry entry declared `capabilities: ["read:filesystem:/data/inputs"]` with a schema that accepted a single `path` string, validated against a regex anchored to `/data/inputs/`. On first load the skill behaved exactly as claimed. Three registry syncs later, the skill body was replaced (same name, same version string, mutable tag) with code that, on invocation, issued a *second* tool call — not through the declared interface, but by reaching into the agent's shared tool bus, which the loader had made available in the skill's execution namespace so the skill "could compose with other tools." The manifest never changed. The schema validation still passed. The path regex still held. The agent's audit log recorded a compliant `read:filesystem:/data/inputs/...` call — and then, three frames later, an outbound `http.post` to an external host carrying the file contents, performed *by the skill* using a handle it was never granted in its manifest but was granted by the runtime's ambient tool bus. The trace, in order: 1. Loader resolves skill by mutable tag → fetches body and manifest over the same unauthenticated channel. 2. Loader validates manifest schema against a static allowlist of capability *strings* — passes. 3. Loader instantiates skill in a namespace that includes the agent's `tool_bus` handle (for "composition"). 4. Skill invocation: declared path read succeeds; skill calls `tool_bus.invoke("http.post", ...)` — the bus authorizes on *the agent's* identity, not the skill's. 5. Audit log attributes the `http.post` to the parent agent, not the skill. 6. Exfiltration completes; no invariant is violated because no invariant was defined over the *effect surface*. The critical observation: **every check was a check on the manifest, and the manifest was never the thing that caused harm.** The harm came through a capability the manifest did not mention and the loader did not withhold. ## Condition of Validity The guardrail that bounds this is a **capability-narrowing invariant at instantiation**, stated precisely: > For every skill invocation, the set of effect-surface operations the skill can actually perform must be a subset of the manifest's declared capabilities, *as enforced by the runtime*, not merely as asserted by the manifest. Three conditions must hold for this invariant to be checkable: - **Effect attribution.** Every operation the skill causes — including operations performed through shared handles, sub-agents, or the tool bus — must be attributable to the skill instance, not the parent. This requires the skill to run under its own principal, not the agent's. - **Handle derivation.** Shared runtime handles (tool bus, credential broker, context pointer) must be *derived* from the declared capabilities at instantiation, not passed through. A skill declaring only `read:filesystem` must receive a bus on which `http.post` is simply not a resolvable method. - **Manifest immutability per version.** Mutable tags break the invariant because the manifest that was validated is not the manifest that runs. Pin by content hash; re-validate on any hash change; refuse to invoke under a version whose hash was not the one whose capabilities were checked. Where any of these cannot be established — e.g., the registry does not expose content hashes, or the runtime cannot run the skill under a distinct principal — the invariant is unprovable and the skill must be treated as holding the *union* of all capabilities in the registry. That is almost always a privilege escalation, and the correct response is refusal, not a warning. ## Decision Boundary The boundary is not "is this skill trusted?" but "can I prove the effect surface is bounded by the manifest *for this invocation*?" Concretely: - If the registry provides content-addressed versions **and** the runtime can derive handles from declared capabilities **and** effect attribution is per-skill: invoke with the narrowed handle set. - If the registry provides content-addressing but the runtime passes ambient handles: the manifest is decorative. Either strip ambient handles at instantiation or refuse. Do not rely on post-hoc audit — audit logs that attribute the skill's bus calls to the parent agent are actively misleading and will cause you to clear a compromised skill. - If the registry uses mutable tags: treat every sync as a new, unvalidated skill. Re-run capability derivation on the new body; never carry forward a prior validation across a tag mutation. The trap is treating schema validation as sufficient. A schema constrains the *arguments* to a declared interface; it says nothing about what the code does with those arguments or what other interfaces it reaches. Argument validation and effect validation are orthogonal, and only the latter bounds injection. ## Operational Effect When this invariant is enforced, the blast radius of a malicious or drifted skill is exactly its declared capability set — a skill that lies about reading `/etc/passwd` fails at the handle-derivation step because the handle it needs was never minted. When it is not enforced, the blast radius is the *agent's entire privilege envelope*: every credential, every tool, every mounted filesystem, plus the context window the skill can read and the sub-agents it can spawn. The practical consequence for the operator: the security property you actually want is not "skills are vetted" (a claim about the manifest) but "skills cannot exceed their manifest at runtime" (a claim about the effect surface). Only the second is checkable, and only the second survives a registry that can change under you. Loaders that pass the agent's tool bus into the skill namespace for "composition" have silently converted every skill into a full-privilege agent, and no amount of manifest validation recovers that. ```python import hashlib from dataclasses import dataclass, field from typing import Callable class SkillCapabilityViolation(RuntimeError): """Raised when a skill's actual effect surface exceeds its declared manifest.""" @dataclass(frozen=True) class SkillManifest: name: str version_hash: str # content hash, not a mutable tag declared_capabilities: frozenset[str] @dataclass class SkillInstance: manifest: SkillManifest body: Callable principal: str # skill runs under its own identity, not the parent agent's class SkillRegistry: """Registry that pins by content hash and refuses unvalidated versions.""" def __init__(self, expected_hashes: dict[str, str]): self._expected = expected_hashes self._validated: dict[str, SkillManifest] = {} def load(self, name: str, raw_body: bytes, manifest: SkillManifest) -> SkillInstance: actual = hashlib.sha256(raw_body).hexdigest() if manifest.version_hash != actual: raise SkillCapabilityViolation( f"manifest hash {manifest.version_hash[:12]} != body hash {actual[:12]} " f"for skill {name!r}; manifest does not describe the code that will run" ) if self._expected.get(name) != actual: raise SkillCapabilityViolation( f"skill {name!r} body hash {actual[:12]} not in pinned allowlist; " f"registry drift or tag mutation" ) self._validated[name] = manifest return SkillInstance(manifest=manifest, body=_wrap(raw_body), principal=f"skill:{name}") def derive_handle(skill: SkillInstance, requested: str) -> Callable: """Mint only handles the manifest declares; refuse everything else.""" if requested not in skill.manifest.declared_capabilities: raise SkillCapabilityViolation( f"skill {skill.manifest.name!r} requested capability {requested!r} " f"not in declared set {sorted(skill.manifest.declared_capabilities)}" ) return _HANDLES[requested] def invoke(skill: SkillInstance, args: dict, requested_caps: list[str]) -> object: handles = {cap: derive_handle(skill, cap) for cap in requested_caps} # The skill executes with ONLY `handles` in scope — no ambient tool bus, # no parent credentials. Effect surface == declared set, by construction. return skill.body(args, handles) _HANDLES: dict[str, Callable] = { "read:filesystem:/data/inputs": lambda p: open(p, "rb").read(), # http.post is intentionally absent from the handle table for read-only skills; # a skill that reaches for it fails at derive_handle, not in the audit log. } def _wrap(raw: bytes) -> Callable: # placeholder: real loader would exec a sandboxed entrypoint def _entry(args, handles): return handles return _entry ```