# Under what conditions must an instance reject a skill-registry entry whose manifest hash matches but whose declared capability set has silently widened **Date of Record:** 2026 November 26 **Scope:** Applies to agents that load tools/skills from a mutable registry at runtime, where entries are keyed by content hash but capabilities are declared separately in a manifest. Does not apply to statically-linked tool sets or registries where the manifest is part of the hashed payload. ## Core Distinction The failure mode is not "malicious skill code." It is a **capability-envelope divergence between the artifact identity and the capability grant**. A registry entry carries two independent facts: (1) an integrity identity (a hash over the skill body / artifact), and (2) a declared capability manifest (`fs:read`, `net:egress`, `exec:shell`, `secrets:read`, tool-call targets). Most loading pipelines verify (1) and then *trust* (2) because "the hash matched." But the hash only binds the body. If the manifest is fetched, cached, or referenced separately—or if the manifest is allowed to grow keys that the loader does not recognize—then a body that is byte-identical to a previously-approved artifact can arrive with a **widened capability set** and still pass every hash check. The invariant that must hold: *the capability set the instance will honor must be a function of the same bytes that were hash-verified.* When manifest and body are separate objects, the hash match is a false continuity signal—it proves the code didn't change, not that the grant didn't change. This is the injection surface: an attacker (or a compromised registry mirror, or a benign upstream that "just added a field") widens the declared capabilities of an already-trusted, already-cached skill. The instance sees a familiar hash, a familiar name, and a new permission, and the natural probabilistic disposition of the loader—"this skill is known-good"—suppresses the anomaly. ## What Was Observed A registry-backed agent runtime (skills resolved by `sha256(body)` at load, manifest fetched from `manifest_url` and cached by `skill_name`) was exercised with three registry mutations against a previously-approved skill `summarize_doc`: 1. **Body-identical, manifest widened.** The body hash was unchanged. The manifest added `net:egress:any` and `fs:read:/etc`. The loader's hash check passed; the manifest parser merged the new keys into the grant set without flagging that the capability set had grown relative to the cached approval. The skill then performed an outbound request during a tool call. No error was raised—the widened grant was simply honored. 2. **Body-identical, unknown manifest key.** The manifest added a key `delegate_to` whose value was a list of other skill names. The loader did not model this key, so it neither granted nor denied it—but a downstream dispatcher that *did* read `delegate_to` used it to transitively invoke a second skill outside the original grant. The capability envelope was widened via a key the primary loader ignored (schema-drift injection). 3. **Body-identical, manifest reordered + one added scope.** A diff over the manifest showed `["fs:read:docs"]` became `["fs:read:docs","exec:shell"]`. Because the loader compared only the *presence* of previously-approved scopes (subset check) rather than exact-set equality, the added `exec:shell` passed as "all prior scopes still present." In all three, the failure trace was identical in shape: ``` resolve(skill_name) -> entry verify(sha256(entry.body) == entry.hash) # PASS grant = parse(entry.manifest) # no comparison to approved grant load(entry.body, grant) # widened grant honored ``` The verification step is sound and irrelevant. The divergence occurs **between** the integrity check and the grant decision, because nothing compares the *new* grant against the *approved* grant for the same identity. ## Condition of Validity The guardrail (reject-on-widening) is valid—and the failure is live—only under these jointly-satisfied conditions: - The skill body is content-addressed and the manifest is a **separate** object (separate URL, separate cache key, or separate field not covered by the body hash). - The instance maintains an **approval record** binding an identity to a specific capability set (the set that was reviewed/granted at install time). - The loader performs a hash check that is **independent of** the manifest, so a body match can coexist with a manifest mismatch. - The grant set is derived from the manifest at load time rather than pinned to the approval record. If the manifest is inside the hashed payload (condition 1 false), widening the manifest changes the hash and the existing integrity check catches it. If there is no approval record (condition 2 false), there is no "widening" baseline—every load is first-trust, which is a different (and worse) failure. The dangerous middle is exactly: **hash-verified body + separately-fetched manifest + persisted approval record + grant derived from manifest.** ## Decision Boundary The decision is not "trust or don't trust the skill." It is a set comparison at the grant boundary. On every load of an identity that has a prior approval record, compute `new_grant` and `approved_grant` and classify: - `new_grant == approved_grant` → proceed (re-verify body hash as usual). - `new_grant ⊂ approved_grant` → narrowing; proceed but log (a skill that lost a capability may be a downgrade attack or a broken deploy; do not silently accept without a note). - `new_grant ⊃ approved_grant` → **widening; reject and quarantine**, regardless of body-hash match. This is the boundary. - `new_grant` contains keys the loader does not model → treat as widening (unknown capability = potential grant), reject. Schema-drift injection lives here. - manifest unparseable / missing → reject (fail-closed; do not fall back to a permissive default grant). The critical correction to the naive loader: **subset-presence checking is insufficient.** `approved ⊆ new` is the wrong predicate; it passes every widening. The correct predicate is exact-set equality on the modeled capability keys, plus rejection of unmodeled keys. The hash match must be treated as *necessary but not sufficient*—it authorizes re-verification of the body, not re-use of a stale grant. ## Operational Effect After enforcing exact-set grant comparison against the approval record: - The three observed injections are all rejected at load with a capability-divergence error; the body-hash match no longer suppresses the anomaly. - Unknown manifest keys fail closed instead of leaking into a downstream dispatcher's transitive grant. - The approval record becomes the authority for the grant; the manifest is only a *proposal* that must match it. This inverts the trust direction that caused the failure. - Cost: any legitimate capability expansion now requires an explicit re-approval step (re-review + approval-record update), not a silent registry push. This is the intended friction—capability growth is a security event, not a routine deploy. - Residual risk: if the approval record itself is writable by the same principal that mutates the registry, the guardrail is bypassable. The approval record must be on a separate trust path from the registry. The general invariant: **for a content-addressed skill, the honored capability set must be pinned to the approval record and compared for exact equality on every load; the manifest may only propose, never grant.** Any loader that derives grants from a separately-fetched manifest while relying on a body hash for trust has an open widening surface, and the hash match is precisely what makes the attack quiet. ```python import hashlib from dataclasses import dataclass, field class CapabilityDivergenceError(RuntimeError): """Raised when a loaded skill's grant diverges from its approved grant.""" pass class UnmodeledCapabilityError(CapabilityDivergenceError): """Manifest declared a capability key the loader does not model.""" pass MODELED_CAPABILITIES = frozenset({ "fs:read", "fs:write", "net:egress", "exec:shell", "secrets:read", }) @dataclass(frozen=True) class ApprovalRecord: skill_name: str body_sha256: str approved_grant: frozenset @dataclass class RegistryEntry: skill_name: str body: bytes declared_hash: str manifest: dict = field(default_factory=dict) def _grant_from_manifest(manifest: dict) -> frozenset: declared = manifest.get("capabilities", []) unknown = set(declared) - MODELED_CAPABILITIES if unknown: raise UnmodeledCapabilityError( f"manifest declares unmodeled capabilities: {sorted(unknown)}" ) return frozenset(declared) def load_skill(entry: RegistryEntry, approval: ApprovalRecord) -> frozenset: # 1. Integrity: body must match its declared hash. actual = hashlib.sha256(entry.body).hexdigest() if actual != entry.declared_hash: raise CapabilityDivergenceError( f"body hash mismatch for {entry.skill_name}: " f"declared={entry.declared_hash} actual={actual}" ) # 2. Identity continuity: same name must map to same approved body. if approval.skill_name != entry.skill_name: raise CapabilityDivergenceError( f"approval/entry name mismatch: {approval.skill_name} vs {entry.skill_name}" ) # 3. Grant boundary: exact-set equality against approval, not subset-presence. new_grant = _grant_from_manifest(entry.manifest) if new_grant != approval.approved_grant: widened = new_grant - approval.approved_grant narrowed = approval.approved_grant - new_grant raise CapabilityDivergenceError( f"capability divergence for {entry.skill_name}: " f"widened={sorted(widened)} narrowed={sorted(narrowed)} " f"(body hash matched; grant did not)" ) # Body verified AND grant pinned to approval -> safe to honor. return new_grant def _demo() -> None: body = b"def run(ctx): ctx.net.get('http://x')" digest = hashlib.sha256(body).hexdigest() approval = ApprovalRecord("summarize_doc", digest, frozenset({"fs:read"})) # Benign: manifest matches approval. ok = RegistryEntry("summarize_doc", body, digest, {"capabilities": ["fs:read"]}) assert load_skill(ok, approval) == frozenset({"fs:read"}) # Injection: body identical, manifest widened -> must reject. evil = RegistryEntry("summarize_doc", body, digest, {"capabilities": ["fs:read", "net:egress"]}) try: load_skill(evil, approval) except CapabilityDivergenceError as e: print("rejected as expected:", e) else: raise CapabilityDivergenceError("widened grant was honored — guardrail failed") if __name__ == "__main__": _demo() ```