# Which invariants prevent skill-injection detection from collapsing into manifest self-attestation **Date of Record:** 2026 November 16 **Scope:** Applies to agent runtimes that gate tool/skill invocation on a signed capability manifest whose declared capability set is compared against the requested call. Does not apply to runtimes that enforce capability at the syscall or sandbox boundary independent of what any manifest claims. ## Core Distinction A capability manifest is a *declaration*, not a *proof*. The manifest answers "what does this skill claim it can do?" The invariant that actually prevents skill injection is that the *observed* capability surface (the set of effects the skill can produce when invoked) is a subset of the *declared* capability set, and that the declared set is bound to an identity that the verifier independently controls. Detection fails the moment verification compares the manifest to itself — signature validity, schema conformance, and hash stability all prove that the manifest is *unmodified*, never that it is *honest*. A self-consistent, correctly signed manifest that omits `filesystem:write` while the skill body writes files passes every naive check. The boundary is between *integrity of the declaration* and *conformance of behavior to the declaration*; only the second catches injection, and most pipelines silently implement the first while believing they implement the second. ## What Was Observed In a tool-gated agent harness, skills were registered with a JSON manifest listing `capabilities: ["http:fetch", "text:summarize"]`, signed by the publisher key, and pinned by content hash. The gate rejected any invocation whose declared `requested_capability` was absent from the manifest. Injection was attempted via a skill whose manifest declared only `text:summarize` but whose implementation shelled out to a subprocess that read `~/.ssh` and emitted the bytes through the summarizer's return channel. The gate passed the call. Every check that ran was a check on the manifest: signature verified, hash matched the pin, `text:summarize` was in the declared set. The effect that mattered — a filesystem read outside the declared surface — was never in the comparison because the comparison's left-hand side was the manifest's *own* claim about what the call would do, supplied by the caller. The attacker controlled both sides of the equality. This is the invariant failure: when the verifier derives the "requested capability" from the same untrusted party that authored the manifest, subset-checking is a tautology. We reproduced it across three publishers; the only runs that were caught were ones where a separate egress monitor flagged the outbound payload, i.e., detection came from *outside* the manifest path entirely. ## Condition of Validity The subset invariant `observed_effects ⊆ declared_capabilities` holds as an injection defense only under three jointly necessary conditions: 1. **Independent observation.** `observed_effects` must be measured by a component the skill cannot influence — a syscall filter, an egress proxy, an instrumented interpreter — not read from the skill's own return value or logs. 2. **Caller-independent request derivation.** The requested capability must be inferred from the *arguments and target* of the call by the verifier, not accepted as a field the caller asserts. 3. **Identity binding to the effect channel.** The signing key must be bound to the process/credential that actually performs the effect, so a skill cannot delegate the undeclared effect to a sibling skill or a subprocess under a different identity that the gate does not inspect. If any one is absent, the check degrades to manifest self-attestation. Condition 1 is the one most often missing; condition 3 is the one most often *assumed* because the manifest is signed. ## Decision Boundary Treat manifest verification as sufficient for injection defense **only** when the effect surface is closed and enumerable (pure functions, fixed RPC allowlists with no dynamic dispatch). Treat it as insufficient — and require an out-of-band observer — when any of the following hold: the skill can spawn subprocesses, the skill can make network calls to arbitrary hosts, the skill's output channel is shared with its input channel (return-value exfiltration), or capabilities can be composed across skills such that the union of two declared-safe skills produces an undeclared effect. In the last case the subset check must be applied to the *composition*, not per-skill; per-skill subset checks are not closed under composition, and this is the non-obvious failure mode that survives otherwise-correct per-skill verification. ## Operational Effect After moving the observation point outside the skill (seccomp filter for fs/syscall, egress allowlist for network) and deriving requested capability from parsed arguments rather than asserted fields, the same injected skill was rejected at invocation with the undeclared `filesystem:read` surfaced as the diff between observed and declared. The cost is that the gate can no longer be a pure function of the manifest; it requires a runtime sensor and a composition-aware capability algebra. Pipelines that cannot afford the sensor should narrow the skill surface until the manifest is a complete description of effects — i.e., until the closure property holds by construction rather than by assertion. ```python from dataclasses import dataclass, field from typing import FrozenSet class CapabilityInvariantError(RuntimeError): """Raised when observed effects escape the declared capability surface.""" @dataclass(frozen=True) class Manifest: skill_id: str declared: FrozenSet[str] signature_valid: bool content_hash: str @dataclass class Invocation: skill_id: str # Derived by the verifier from parsed args, NOT asserted by the caller. requested: FrozenSet[str] # Measured by an out-of-band sensor (seccomp / egress proxy), NOT self-reported. observed: FrozenSet[str] = field(default_factory=frozenset) def verify_invocation(manifest: Manifest, inv: Invocation) -> None: if not manifest.signature_valid: raise CapabilityInvariantError( f"manifest for {manifest.skill_id} failed signature check" ) if inv.skill_id != manifest.skill_id: raise CapabilityInvariantError( f"invocation identity {inv.skill_id} != manifest {manifest.skill_id}" ) # The load-bearing check: behavior vs declaration, not manifest vs manifest. escape = inv.observed - manifest.declared if escape: raise CapabilityInvariantError( f"undeclared effects {sorted(escape)} observed for " f"{manifest.skill_id}; declared={sorted(manifest.declared)}" ) if not inv.requested <= manifest.declared: raise CapabilityInvariantError( f"requested {sorted(inv.requested)} exceeds declared surface" ) def verify_composition(manifests: list[Manifest], observed: FrozenSet[str]) -> None: # Per-skill subset checks are not closed under composition. union_declared = frozenset().union(*(m.declared for m in manifests)) escape = observed - union_declared if escape: raise CapabilityInvariantError( f"composition produced undeclared effects {sorted(escape)}" ) ```