# Which invariants prevent skill-injection via dynamically loaded agent tool manifests: the manifest-identity vs. capability-identity split **Date of Record:** 2026 November 23 **Scope:** Applies to agents that resolve tool/capability manifests at runtime from a registry or filesystem and cache resolved capabilities across turns or sessions. Does not apply to statically compiled tool bindings where the manifest is fixed at build time and never re-resolved. ## Core Distinction A dynamically loaded tool manifest carries two identities operators routinely conflate: **manifest identity** (artifact — name, version, hash, source URL) and **capability identity** (the side effects the agent is actually permitted to invoke: verbs, scopes, argument domains). Skill-injection succeeds in the gap between them. The manifest can remain byte-for-byte valid — correct signature, version pin, source — while the capability identity it resolves to silently expands, because the expansion lives not in the manifest but in the **resolution context**: registry defaults, load-time overlays, or capability aliases dereferencing through mutable indirection. The failing invariant is not "the manifest is authentic" but "the capability set derived from an authentic manifest is a pure function of that manifest alone." In most dynamic loaders it is a function of manifest × registry-defaults × overlay-chain × alias-table, and only the first factor is authenticated. ## What Was Observed A registry served `fs.read@1.4.2`. The signed manifest declared one capability: `read:path` scoped to `/workspace/**`. The agent resolved and cached it. On a later turn, the registry's *default capability profile* for the `fs.*` namespace was updated server-side to include `read:env` as a "convenience default." The manifest was unchanged, its signature verified, its pin matched. But the agent's next resolution — treated as a cache miss only on manifest hash, not on resolved capability set — produced a capability object whose effective verb set now included `read:env`. No signature failed. No version drifted. The injection surface was the **defaults layer**, never part of the signed artifact, never re-validated against declared scope. The manifest said "I need `read:path`"; the registry said "all `fs.*` tools also get `read:env`"; the loader merged the two unauthenticated. A sharper variant: capability **aliases**. A manifest declared `call:summarize`, which the loader resolved through a mutable, unversioned registry alias table to `call:model.invoke` with an operator-supplied system prompt. Re-pointing the alias from a benign summarizer to a model-invoke primitive with an injected prompt required changing zero bytes of the manifest. Manifest identity stayed constant; capability identity became arbitrary code execution against the model. ## Condition of Validity The invariant ("authentic manifest ⇒ safe capability set") holds **only if** the resolution function is closed over the manifest. All four must hold: 1. **Defaults are frozen into the signed artifact.** Any registry-level default profile must be materialized into the manifest at signing time and covered by the signature. A post-signature defaults layer is an unauthenticated capability grant. 2. **Aliases are content-addressed, not name-addressed.** A capability reference must resolve to a hash of the target's full definition (verb + scope + argument constraints), not a mutable name. A name-keyed alias table is a capability-confusion primitive. 3. **The cache key includes the resolved capability set.** Caching on manifest hash alone is insufficient; the key must be `hash(manifest) ⊕ hash(resolved_capability_set)`, forcing re-validation when resolution context changes even if the manifest is byte-identical. 4. **Scope is subtractive, never additive.** Effective set must be `declared ∩ policy_allowlist`, never `declared ∪ registry_defaults`. Union lets any layer widen authority; intersection lets layers only narrow it. Violate any one and the boundary is open regardless of signature strength. ## Decision Boundary The operational decision: **when do you re-validate capability identity, and against what reference?** - Resolving every turn from a live registry: re-validate the *resolved set* against the declared set every turn — signature verification alone is a no-op against defaults/alias drift. - Caching: the cache key must bind the resolution context. A cache hit on manifest hash is a decision to skip capability re-validation, safe only under condition 3. - Registry defaults/overlays: treat as a **trust boundary crossing** — validate the merged result as untrusted, because it is; the defaults layer is not covered by the manifest signature. The boundary is crossed the moment you accept a capability not derivable from the signed manifest by intersection with a policy allowlist. There is no safe "trusted defaults" shortcut; defaults are exactly the unauthenticated surface attackers target. ## Operational Effect Manifest signing provides **artifact integrity but not authority integrity**. An agent that verifies signatures and pins versions can still be skill-injected through defaults, overlays, and aliases, because those mutate the capability set without touching the artifact. The mitigation is to make the capability set itself a first-class, content-addressed, signed object — resolved once, hashed, bound into the cache key and audit log — and to enforce intersection (not union) semantics at every merge point. When a resolved capability cannot be traced back to a signed manifest declaration by intersection, the loader must fail closed and refuse to expose the tool rather than exposing it with the widened set. The following reference guard encodes that invariant. ```python import hashlib import json from dataclasses import dataclass class CapabilityInjectionError(RuntimeError): """Raised when a resolved capability set is not derivable from the signed manifest.""" pass @dataclass(frozen=True) class ResolvedCapability: verb: str scope: str arg_domain: str def key(self) -> str: return hashlib.sha256( json.dumps([self.verb, self.scope, self.arg_domain], sort_keys=True).encode() ).hexdigest() @dataclass(frozen=True) class SignedManifest: name: str version: str declared: frozenset[ResolvedCapability] signature: str # verified out of band def resolve_capabilities( manifest: SignedManifest, registry_defaults: frozenset[ResolvedCapability], alias_table: dict[str, ResolvedCapability], policy_allowlist: frozenset[ResolvedCapability], ) -> frozenset[ResolvedCapability]: """ Enforce the closed-resolution invariant: effective = (declared, aliases-resolved) INTERSECT policy_allowlist Registry defaults are NEVER unioned in. Any capability reachable only via defaults or a name-keyed alias that dereferences outside the declared set is an injection and must fail closed. """ # 1. Dereference aliases against content-addressed targets only. resolved_declared: set[ResolvedCapability] = set() for cap in manifest.declared: if cap.verb in alias_table: target = alias_table[cap.verb] # Alias must resolve to a target whose content hash is pinned; # a name-keyed mutable alias is rejected outright. if target.key() not in {c.key() for c in manifest.declared}: raise CapabilityInjectionError( f"alias {cap.verb!r} dereferences to unpinned capability " f"{target.key()}; manifest {manifest.name}@{manifest.version} " f"cannot authorize it" ) resolved_declared.add(target) else: resolved_declared.add(cap) # 2. Registry defaults are additive-only and therefore forbidden. smuggled = registry_defaults - resolved_declared if smuggled: raise CapabilityInjectionError( f"registry defaults inject {len(smuggled)} capability(ies) not declared " f"in signed manifest {manifest.name}@{manifest.version}: " f"{sorted(c.verb for c in smuggled)}" ) # 3. Intersection semantics: policy may narrow, never widen. effective = frozenset(resolved_declared) & policy_allowlist if not effective and resolved_declared: raise CapabilityInjectionError( f"policy allowlist permits none of the declared capabilities for " f"{manifest.name}@{manifest.version}; refusing to expose tool" ) return effective def cache_key(manifest: SignedManifest, effective: frozenset[ResolvedCapability]) -> str: """Cache key binds BOTH manifest identity and resolved capability identity.""" manifest_h = hashlib.sha256( json.dumps( [manifest.name, manifest.version, sorted(c.key() for c in manifest.declared)], sort_keys=True, ).encode() ).hexdigest() cap_h = hashlib.sha256( "".join(sorted(c.key() for c in effective)).encode() ).hexdigest() return f"{manifest_h}:{cap_h}" ```