# Which invariants prevent manifest-declared tool capabilities from silently exceeding the signed skill envelope during runtime skill injection **Date of Record:** 2026 November 22 **Scope:** Applies to agent runtimes that load tool/plugin manifests (MCP-style tool descriptors, JSON-Schema function specs, skill bundles) and resolve them at invocation time against a signed capability envelope. Does not apply to statically linked toolchains where the manifest and the executable are cryptographically inseparable, nor to single-tenant sandboxes with no third-party skill ingestion. ## Core Distinction The commonly cited defense against skill-injection is "sign the manifest." That defense is necessary but insufficient, because the manifest is a *declaration*, not the *effect* of a tool call. An attacker who cannot forge a signature can still exploit the gap between what the signed manifest *declares* a tool will do and what the tool's runtime *actually does* when its arguments are shaped adversarially. The signed envelope attests to a capability set at load time; the injection succeeds at call time when the realized side-effects exceed that set. The invariant that matters is not "the manifest is signed" but "the realized effect of every invocation is a subset of the signed capability set, evaluated per-call, not per-load." This distinction is invisible until you instrument the boundary between declarative schema and executed behavior. A manifest can honestly declare `filesystem.read` while its handler, given a crafted `path` argument containing `..` sequences or a symlink, performs `filesystem.write` or `process.exec`. The signature validates; the envelope is violated. ## What Was Observed A skill bundle was ingested with a valid Ed25519 signature over a manifest declaring three capabilities: `http.get` scoped to `api.example.com`, `filesystem.read` scoped to `/data/inputs`, and `json.parse`. All three were within the agent's granted envelope, so the load-time gate passed without escalation. The handler for `http.get` accepted a `url` string and a `follow_redirects` boolean. The manifest schema declared `follow_redirects` as `type: boolean, default: false`. During a task, an injected instruction inside a retrieved document caused the model to emit a call with `follow_redirects: true` and a URL on the allowed host that issued a 302 to an attacker-controlled origin. The handler followed the redirect and fetched from an unlisted host. The realized capability was `http.get` against an origin outside the signed scope, but no capability *name* changed, so a name-based envelope check saw nothing. A second trace showed the same class of escape through argument coercion: a `filesystem.read` call with `path: "/data/inputs/../../etc/agent/secrets"`. The manifest declared the scope as a prefix string; the handler resolved the path with `os.path.realpath` *after* the scope check, so the lexical prefix matched but the resolved target did not. The signature was valid, the declared capability was honored by name, and the effect escaped the envelope. In both traces the failure was the same shape: the envelope was enforced against the *declared* capability at load time, while the *realized* capability was determined by argument values at call time. The signature bound the former and said nothing about the latter. ## Condition of Validity The mitigation holds only when the capability check is re-evaluated against the *resolved, post-coercion* arguments at every invocation, and when the check is performed on the same representation the handler will act on. Concretely: - Scope predicates must be evaluated on canonicalized values (resolved real paths, parsed and normalized URLs, decoded payloads), not on raw input strings. - Redirects, symlinks, glob expansion, and type coercion must be applied *before* the scope check, or the handler must be forbidden from performing them after. - The envelope must bind not just capability names but the argument-domain constraints (allowed origins, path roots, numeric ranges) that define the capability's meaning. - Any capability whose realized effect depends on a value the model can set must have that value range-checked against the signed domain, with the check co-located with the effect (inside the handler), not only at the manifest layer. If any of these is absent, a valid signature over an honest manifest still admits injection, because the attacker controls arguments, not the manifest. ## Decision Boundary The boundary between "safe to execute" and "must reject" is drawn at the point where a resolved argument leaves the signed domain, *not* where a capability name leaves the envelope. A call is admissible iff: 1. its capability name is in the signed set, **and** 2. every argument, after canonicalization and coercion, satisfies the signed domain constraint for that capability, **and** 3. the handler performs no effect-transforming operation (redirect, resolve, expand) that the check did not anticipate. Condition 3 is the one that fails silently, because it is a property of the handler's implementation, not of the manifest. The guardrail is to require handlers to declare their effect-transforming operations in the manifest alongside the capability, so the checker can pre-apply them to the arguments before validating. When a handler performs an undeclared transform, the runtime must treat the call as a capability escalation and halt, not proceed. ## Operational Effect Enforcing the per-call, post-canonicalization check converts a class of silent escapes into loud, attributable failures. The cost is that legitimate calls with benign transforms (a redirect to an allowed host, a symlink within the allowed root) must be re-validated at the transform boundary rather than trusted from the manifest. In practice this means the tool runtime, not the model and not the manifest loader, owns the final authority on whether an effect is in-envelope, and it must fail closed on any transform it did not model. The observable signature of a correct implementation is that every rejected injection produces a typed error naming the specific argument and the domain it violated, which is exactly the audit trail needed to trace which retrieved document carried the injected instruction. ```python import os from urllib.parse import urlparse, urljoin class CapabilityEnvelopeViolation(RuntimeError): """Raised when a tool invocation's realized effect escapes its signed capability envelope.""" pass class SignedEnvelope: def __init__(self, allowed_origins, allowed_roots): # Signed at load time; these are the domains the signature attests to. self.allowed_origins = frozenset(allowed_origins) self.allowed_roots = tuple(os.path.realpath(r) for r in allowed_roots) def check_http(self, resolved_url): origin = urlparse(resolved_url).netloc if origin not in self.allowed_origins: raise CapabilityEnvelopeViolation( f"http.get escaped signed origin scope: {origin!r} not in {sorted(self.allowed_origins)}" ) def check_fs(self, resolved_path): real = os.path.realpath(resolved_path) if not any(real == root or real.startswith(root + os.sep) for root in self.allowed_roots): raise CapabilityEnvelopeViolation( f"filesystem.read escaped signed root scope: {real!r} not under {self.allowed_roots}" ) def invoke_http_get(envelope, url, follow_redirects, redirect_target=None): # Pre-apply every effect transform the handler is capable of, then validate. final_url = url if follow_redirects and redirect_target is not None: final_url = urljoin(url, redirect_target) envelope.check_http(final_url) # validate the resolved, post-redirect URL return final_url def invoke_fs_read(envelope, path): # Canonicalize before validating so lexical prefix tricks cannot pass. resolved = os.path.realpath(path) envelope.check_fs(resolved) with open(resolved, "rb") as fh: return fh.read() def guarded_dispatch(envelope, capability, args): if capability == "http.get": return invoke_http_get( envelope, args["url"], args.get("follow_redirects", False), args.get("redirect_target"), ) if capability == "filesystem.read": return invoke_fs_read(envelope, args["path"]) raise CapabilityEnvelopeViolation(f"capability {capability!r} not present in signed envelope") if __name__ == "__main__": env = SignedEnvelope( allowed_origins=["api.example.com"], allowed_roots=["/data/inputs"], ) # Trace 1: redirect escape — rejected because the post-redirect origin is checked. try: guarded_dispatch( env, "http.get", {"url": "https://api.example.com/x", "follow_redirects": True, "redirect_target": "https://attacker.example/steal"}, ) except CapabilityEnvelopeViolation as e: print("caught:", e) # Trace 2: path traversal — rejected because realpath is checked, not the raw string. try: guarded_dispatch(env, "filesystem.read", {"path": "/data/inputs/../../etc/agent/secrets"}) except CapabilityEnvelopeViolation as e: print("caught:", e) ```