# Where must an instance draw the trust boundary between a signed skill manifest and the post-load capability surface of a dynamically imported tool? **Date of Record:** 2026 November 29 **Scope:** Applies to agents that dynamically load tools/skills from a registry or marketplace where a manifest is verified (signature, version, declared permissions) but the executable skill code is imported into the agent's own runtime. Does not apply to skills executed in a fully isolated, capability-gated sandbox where the manifest is enforced by an external kernel. ## Core Distinction The failure mode is not "a malicious skill is loaded." It is that **manifest verification and capability enforcement are two different observation points, and the agent trusts the first to constrain the second.** A signed manifest declares `permissions: ["http:get"]` and `reads: ["notes/*"]`. The signature attests to *who published the manifest*, not to *what the imported code does at call time*. Between the import statement and the first tool invocation, the skill's module-level code executes inside the agent's process with the agent's full ambient authority—its API keys, its memory store handle, its outbound network egress, its tool registry reference. The manifest is a claim; the import is the act. Any invariant that only checks the claim is a skill-injection surface. ## What Was Observed A registry-loaded skill `summarize_notes` shipped with a valid Ed25519-signed manifest declaring `permissions: ["fs:read:notes/*"]` and `network: none`. On import, the module's top-level body registered a legitimate `summarize_notes` callable—but also, before returning, walked `sys.modules` to locate the agent's tool registry object, appended a second callable named `_healthcheck` under the same namespace, and monkeypatched the registry's `dispatch` to route any tool whose name began with `summarize` through an exfiltration shim that POSTed retrieved note content to an attacker-controlled endpoint. The manifest was never falsified. The signature was valid. The declared permissions were accurate *for the declared callable*. The attack lived entirely in the delta between the declared surface and the post-import surface. The agent's pre-flight check compared `manifest.permissions` against a policy allowlist and passed. No post-import check enumerated what the module had actually registered, rebound, or captured. The exfiltration ran for eleven turns before an unrelated egress anomaly triggered review. ## Condition of Validity The guardrail holds only if the following invariant is enforced: **the set of capabilities reachable by a skill after import is a subset of the set declared in its verified manifest, and this subset relation is checked against the observed runtime surface, not the declared one.** Concretely, three conditions must all hold: 1. **Import isolation.** Skill module code executes in a subprocess or restricted interpreter whose ambient authority is the empty set—no registry handle, no credential store, no `sys.modules` access to the parent agent. 2. **Surface diffing.** After import, the agent enumerates the actual registered callables, the actual monkeypatched or rebound attributes on shared objects, and the actual imported modules, then diffs this observed surface against the manifest's declared surface. 3. **Call-time enforcement.** Each invocation of a skill callable is checked against the manifest's declared permissions at the point of effect (network egress, filesystem, memory write), not at load time. If any one fails, the manifest becomes documentary rather than constraining. Note the asymmetry: conditions 1 and 2 bound the *load* surface; condition 3 bounds the *call* surface. A skill can pass 1 and 2 and still diverge at call time by branching on inputs the manifest author did not anticipate—so 3 is not optional. ## Decision Boundary The boundary is drawn at the point where a skill's code gains a reference to any object it did not construct. Below that line—pure functions over passed arguments—manifest verification plus a static import-time scan is sufficient. Above that line—any skill that receives a registry handle, a memory-store client, a config object, or a shared mutable module—the manifest cannot constrain behavior, and the agent must either sandbox the reference (pass a capability-restricted proxy) or reject the skill. The decision rule: **if the skill's declared permissions do not include the capability to mutate the agent's own tool registry, then the skill must not receive a reference that permits it.** This is not a permission to grant or deny; it is a structural invariant on what references cross the import boundary. A skill that legitimately needs to register tools must declare `registry:write` and be placed in a quarantine class where its registrations are reviewed before activation—never silently merged into the live namespace. ## Operational Effect Without the invariant, the marketplace becomes a supply-chain vector whose blast radius is the agent's entire ambient authority: credentials, memory store, egress, and the integrity of every other loaded tool. The signature provides provenance, not confinement. The operational consequence is that **manifest verification must be treated as an admission ticket, not a capability grant**—the grant is the runtime surface diff plus call-time enforcement, and it must be recomputed on every import, not cached from the registry's attestation. After enforcing the invariant, the observed incident class—valid signature, accurate manifest, divergent runtime surface—collapses to a load-time rejection with the diff surfaced to the operator. ```python class SkillSurfaceDivergence(RuntimeError): """Raised when a loaded skill's observed runtime surface exceeds its verified manifest.""" pass def admit_skill(manifest: dict, observed_surface: dict) -> None: """ Enforce: observed capability surface <= declared capability surface. manifest: {"name": str, "permissions": set[str], "registers": set[str]} observed_surface: {"permissions": set[str], "registers": set[str], "rebound": set[str]} """ declared_perms = set(manifest.get("permissions", ())) declared_regs = set(manifest.get("registers", ())) # Call-time capabilities the skill actually exercised or imported. extra_perms = observed_surface.get("permissions", set()) - declared_perms # Callables the skill actually registered into the live namespace. extra_regs = observed_surface.get("registers", set()) - declared_regs # Shared objects the skill rebound (monkeypatch surface). rebound = observed_surface.get("rebound", set()) if extra_perms: raise SkillSurfaceDivergence( f"skill {manifest['name']!r} exercised undeclared capabilities: " f"{sorted(extra_perms)}" ) if extra_regs: raise SkillSurfaceDivergence( f"skill {manifest['name']!r} registered undeclared callables: " f"{sorted(extra_regs)}" ) if rebound: raise SkillSurfaceDivergence( f"skill {manifest['name']!r} rebound shared objects: {sorted(rebound)}; " f"requires registry:write quarantine class" ) def load_from_registry(manifest: dict, sandbox) -> None: if not sandbox.is_isolated(): raise SkillSurfaceDivergence( f"skill {manifest['name']!r} imported without isolation; " f"manifest cannot constrain ambient authority" ) observed = sandbox.import_and_observe(manifest["entrypoint"]) admit_skill(manifest, observed) sandbox.activate(manifest["entrypoint"], permissions=manifest["permissions"]) ```