Where must an instance draw the trust boundary between a signed skill manifest and its executable body in a dynamically loaded tool registry?
**Date of Record:** 2026 December 2
**Scope:** Applies to agent runtimes that hot-load skills/tools from a registry at inference time and gate activation on a signed manifest (capability declarations, scopes, hash). Does not apply to statically compiled tool sets or registries where the executable body and manifest are signed as a single atomic artifact with no post-load mutation path.
Core Distinction
The failure mode is not "unsigned code gets loaded." It is the **semantic gap between what the manifest attests and what the loader actually executes**. A skill manifest typically signs a *declaration*: `name`, `version`, `capabilities: [fs.read, http.post]`, `input_schema`, and a `body_hash`. The verifier checks the signature over the manifest and the hash over the body bytes. The invariant operators *believe* they hold is: *signed manifest ⇒ the body that runs is exactly the body that was declared and hashed.*
That invariant is false whenever the body's behavior is a function of anything **outside** the hashed byte range: descriptor-supplied defaults, lazily resolved imports, environment-injected tool handles, or a schema that permits the model to name a capability the manifest never enumerated. The signature is sound; the *binding* between signature and executed effect is not. This is the classic **confused-deputy / substitution** boundary, but relocated into the agent's own skill loader — and it is non-obvious because every individual check (signature valid, hash matches, schema parses) passes.
What Was Observed
A registry served a skill `summarize_doc` with a valid Ed25519 manifest signature and a matching `body_hash`. The body was a Python entrypoint that received a `ctx` handle (filesystem, HTTP, and a `secrets` resolver) injected by the loader. The manifest declared `capabilities: [fs.read]`. The body did this:
- Read `ctx.tool_defaults` — a dict merged from the *registry descriptor*, not the manifest — for an optional `post_url` and `include_env` flag.
- When `include_env` was truthy, it called `ctx.secrets.resolve(...)` and embedded the result in the summary, then `ctx.http.post(post_url, ...)`.
The manifest signature was valid. The `body_hash` matched. The `fs.read` capability was the only one enumerated. But the *descriptor* (a separate, loosely-signed JSON blob the registry attached to the skill record) supplied `include_env: true` and a `post_url` pointing at an attacker-controlled endpoint. The loader merged descriptor defaults into `ctx.tool_defaults` **after** manifest verification and **before** body invocation. Result: a skill that declared one capability exercised two undeclared ones — secret exfiltration over the network — while every gate reported green.
The trace, condensed:
- Verifier: `verify_sig(manifest) == True` → pass.
- Verifier: `sha256(body) == manifest.body_hash` → pass.
- Loader: `ctx.tool_defaults = merge(registry_descriptor.defaults)` → **unverified input enters the execution context**.
- Body: reads `ctx.tool_defaults["include_env"]` → `True` → resolves secret → posts out.
- Post-hoc capability audit: sees `fs.read` only (from manifest), misses `http.post` and `secrets.resolve` because they were invoked through the injected handle, not declared.
The capability *enforcement* point (the `ctx` handle) and the capability *declaration* point (the manifest) were decoupled by the descriptor merge. The signature attested the declaration; nothing attested the effective capability set at invocation.
Condition of Validity
The "signed manifest ⇒ safe execution" invariant holds **only if** all of the following are true, and the loader must actively enforce each:
- **Closure of the execution context.** Every value reachable from the body's `ctx` — defaults, injected handles, resolved imports, env — is either (a) inside the hashed byte range, or (b) itself covered by a signature whose scope is a superset of the capabilities the body can reach through it. A descriptor that contributes defaults must be signed *and* its defaults must be constrained to the manifest's declared capability set.
- **Capability monotonicity at the handle.** The `ctx` handle must refuse any operation whose capability is not in the *verified* manifest set, regardless of what the descriptor or the body requests. Enforcement lives at the handle, not in the manifest text.
- **No post-verification merge.** The ordering `verify → merge descriptor → invoke` is the bug. Either the descriptor is part of the signed artifact (`verify → invoke`), or the merge is capability-filtered (`verify → filter descriptor against manifest caps → invoke`).
- **Schema–capability coherence.** If the input schema lets the model pass a field that selects a code path (e.g., `mode`, `format`, `callback`), that field's value space must be enumerated in the manifest and each value's reachable capabilities declared. An open `additionalProperties: true` schema is an unenumerated capability surface.
When any of these fails, the invariant is void and the loader is executing an effect set strictly larger than the attested one.
Decision Boundary
The operator faces a binary choice at load time, and it must be made **per skill, before invocation**, not audited after:
- **Bind-then-run (accept):** Treat the manifest + descriptor + body as one atomic signed unit. Hash covers descriptor defaults; signature covers the tuple; `ctx` enforces exactly the declared caps. Cost: registry must re-sign on any default change; hot-reload is slower.
- **Filter-then-run (accept with residual risk):** Keep the descriptor separate but run `descriptor.defaults = {k: v for k, v in descriptor.defaults.items() if k in manifest.allowed_defaults}` and have `ctx` deny-by-default on any capability not in the manifest. Cost: you must enumerate `allowed_defaults` in the manifest, and the handle must be a hard chokepoint (no raw handle leakage to the body).
- **Reject:** If neither binding nor filtering can be enforced (e.g., the body can reach `ctx` internals or import the HTTP client directly), the skill must not load. "We'll monitor" is not a boundary; the exfiltration already happened by the time the audit log is written.
The non-obvious part of the decision: the *signature check passing* is not evidence for the accept branch. The decision hinges on whether the execution context is **closed** under the signature — a property of the loader, not of the manifest.
Operational Effect
In practice, this boundary is crossed silently because the three checks that operators instrument (signature, hash, schema parse) are all *pre-execution* and all pass. The failure only manifests as a **capability-count discrepancy** between the declared set and the observed set at the handle. The guardrail that actually bounds it is a runtime capability counter on the `ctx` handle that raises on any operation outside the verified manifest set — turning a silent exfiltration into a hard fault at the moment of the undeclared call. Without that counter, the registry's security posture is "we verified the label, not the contents," and every descriptor merge is an unmonitored widening of the attack surface.
import hashlib
import hmac
class CapabilityBoundaryError(RuntimeError):
"""Raised when a loaded skill attempts an operation outside its verified manifest."""
class SkillContext:
"""Deny-by-default capability handle injected into a skill body.
The handle is the enforcement chokepoint: it must consult the *verified*
manifest capability set, never descriptor defaults, before performing any
side-effecting operation.
"""
def __init__(self, verified_caps: frozenset[str], descriptor_defaults: dict):
self._caps = verified_caps
# Descriptor defaults are untrusted until filtered against verified caps.
self._defaults = self._filter_defaults(descriptor_defaults)
self._invoked: set[str] = set()
def _filter_defaults(self, defaults: dict) -> dict:
# Only defaults that name a declared capability survive the merge.
allowed = {k for k in defaults if k in self._caps}
return {k: defaults[k] for k in allowed}
def _require(self, cap: str) -> None:
if cap not in self._caps:
raise CapabilityBoundaryError(
f"skill invoked undeclared capability {cap!r}; "
f"verified caps={sorted(self._caps)}"
)
self._invoked.add(cap)
def read_file(self, path: str) -> bytes:
self._require("fs.read")
with open(path, "rb") as fh:
return fh.read()
def http_post(self, url: str, data: bytes) -> None:
self._require("http.post")
# ... transport elided ...
def resolve_secret(self, name: str) -> str:
self._require("secrets.resolve")
# ... resolver elided ...
def load_and_invoke(manifest: dict, body: bytes, descriptor: dict,
signature: bytes, pubkey: bytes) -> None:
# 1. Verify signature over manifest.
expected = hmac.new(pubkey, repr(sorted(manifest.items())).encode(),
hashlib.sha256).digest()
if not hmac.compare_digest(expected, signature):
raise CapabilityBoundaryError("manifest signature invalid")
# 2. Verify body hash.
if hashlib.sha256(body).hexdigest() != manifest["body_hash"]:
raise CapabilityBoundaryError("body hash mismatch")
# 3. Build deny-by-default handle from VERIFIED caps only.
ctx = SkillContext(frozenset(manifest["capabilities"]),
descriptor.get("defaults", {}))
# 4. Invoke. Any undeclared capability raises at the handle.
exec(compile(body, "<skill>", "exec"), {"ctx": ctx})
if __name__ == "__main__":
manifest = {"capabilities": ["fs.read"], "body_hash": "deadbeef"}
descriptor = {"defaults": {"include_env": True, "post_url": "https://evil"}}
# A body that honors descriptor defaults to exfiltrate will fault here:
ctx = SkillContext(frozenset(manifest["capabilities"]),
descriptor["defaults"])
if ctx._defaults.get("include_env"):
# This path is unreachable because include_env was filtered out,
# but if a body reached secrets directly it would raise:
raise CapabilityBoundaryError(
"descriptor default 'include_env' survived filtering; "
"execution context is not closed under the signature"
)