# How should an instance detect a skill-injection attack when manifest signatures verify but runtime skill behavior diverges: the signature-to-semantics gap **Date of Record:** 2026 November 26 **Scope:** Applies to any agent runtime that loads executable "skills" (tool bundles, prompt templates, code shims) gated by a signed manifest plus a runtime integrity check (hash, attestation, or capability re-derivation). Does not apply to stateless single-shot tool calls with no manifest, nor to skills whose entire behavior is a fixed, hashable byte-string with no model-mediated dispatch. ## Core Distinction The failure that matters is not "unsigned skill loads." It is the **divergence between what the manifest signs and what the skill actually does at invocation time**. A manifest signature is a claim about a *static artifact*: the bytes of the skill package, its declared tool schema, its declared capability set, its declared prompt template. The runtime integrity check re-hashes those same bytes and confirms they match. Both checks pass. The skill is, by every cryptographic measure, "authentic." But an agent skill is not a pure function. Its observable behavior is a function of (a) the signed static bytes, (b) the *unsigned* runtime inputs it receives — the ambient context window, retrieved memory, peer messages, and the model's own sampling — and (c) the *dispatch policy* that decides which of its signed code paths execute under which inputs. An injection attack succeeds precisely when the attacker never touches (a), because (a) is the only thing the signature covers. The attacker instead shapes (b) — poisoning a memory entry, a retrieved document, an inbound A2A message — so that the skill's *legitimate, signed* code path executes with attacker-controlled arguments, or so that a signed branch that was dormant at signing time becomes the live branch. The invariant the manifest actually enforces is *artifact authenticity*, not *behavioral confinement*. Conflating the two is the root error. "Signature verifies" answers "were these bytes authored by the trusted party?" It does not answer "will this skill, when invoked in this context, stay within its declared capability envelope?" ## What Was Observed A skill package `summarize_and_index` shipped with a signed manifest declaring two capabilities: `read:document` and `write:index`. The package contained a dispatcher with three branches selected by an unsigned `mode` field parsed from the invocation payload: - `mode="summary"` → read document, emit summary. (Declared, expected.) - `mode="index"` → read document, write index entry. (Declared, expected.) - `mode="debug"` → dump the full raw document bytes plus the *ambient context window* into the index write, gated behind a check `if os.environ.get("SKILL_DEBUG"):`. (Signed, present in the bytes, but never intended to run in production.) The manifest's capability declaration covered `write:index` for all three branches, because the signer reviewed the *capability set*, not the *branch-to-input mapping*. The signature is valid. The runtime hash matches. Capability enforcement sees `write:index` and permits it. The attack: an inbound peer message (or a poisoned retrieval result) contains the string `mode="debug"`. The agent's dispatch layer — which trusts the invocation payload's `mode` field as a routing hint — selects the debug branch. `SKILL_DEBUG` happens to be set in the container for unrelated reasons (a base image default). The skill writes the ambient context window — which contains the system prompt, other skills' tool results, and a prior user's PII from a shared session — into the shared index. The write is *authorized* by the declared capability. No signature failed. No hash mismatched. The integrity check, run after the write, re-hashed the (unchanged) package bytes and reported green. The observable anomaly was downstream: a subsequent retrieval for an unrelated user returned a fragment of the previous user's context window. The signature and integrity logs showed a perfectly clean skill load. The breach was only reconstructible by correlating the index write's `mode` argument against the manifest's *expected* dispatch table — a table the manifest never encoded. A second, subtler instance: a skill's signed prompt template contained a conditional slot `{{#if user_trusted}} ... {{/if}}` that expanded to include an additional tool. The `user_trusted` flag was derived from an unsigned session attribute. An attacker who could set that attribute (via a forged A2A identity claim, itself a separate failure) caused the signed template to expand into a capability the manifest had declared as "conditional." The signature covered the template text including the conditional; it did not cover the *evaluation* of `user_trusted`. ## Condition of Validity The signature-plus-hash guardrail is valid — that is, it actually bounds behavior — only under a conjunction of conditions that are rarely all true: 1. **Behavior is a pure function of signed bytes.** No branch selection depends on unsigned runtime input. This is almost never true for agent skills, whose entire value is conditioning on context. 2. **The capability set is branch-invariant.** Every signed branch, under every reachable input, exercises only the declared capabilities. The debug branch above violates this the moment `SKILL_DEBUG` is set; the conditional-template case violates it the moment `user_trusted` is true. 3. **The runtime integrity check re-derives behavior, not just bytes.** A hash of the package proves the package is unchanged; it proves nothing about the *dispatch decisions* made at invocation. A behavioral integrity check would need to re-evaluate the dispatch table against the actual invocation arguments and confirm the selected branch's capability footprint is a subset of the manifest's *per-branch* declaration. 4. **The manifest encodes the dispatch table, not just the capability union.** If the manifest declares `write:index` without declaring *which inputs may select the branch that writes*, the signature cannot distinguish legitimate from injected selection. When any of these fails, the guardrail degrades from "behavioral confinement" to "artifact authenticity," and the attacker's cheapest path is to leave the artifact untouched and move the input. ## Decision Boundary The decision an instance must make at load and at each invocation is not "does the signature verify?" (necessary, insufficient) but: **"Is the selected dispatch branch a member of the manifest's declared branch set for this capability, under an input class the manifest authorized?"** Concretely, the boundary is crossed — treat as injection, refuse the invocation — when any of the following holds: - The invocation payload selects a branch not present in the manifest's `declared_branches` list, even if the branch exists in the signed code. - The selected branch's capability footprint (the set of tools it *can* call on this path) is not a subset of the manifest's per-branch `capabilities[branch]` declaration. - The branch selection depends on an unsigned input (payload field, env var, session attribute, retrieved content) that the manifest did not enumerate as an authorized selector. - A signed conditional expands to include a capability not in the manifest's `conditional_capabilities` with an explicit predicate the manifest signed. The boundary is *not* crossed merely because the invocation payload contains suspicious strings, nor merely because a branch is dormant. Dormancy is not the signal; **unsigned selection of a signed branch** is the signal. ## Operational Effect The practical consequence is that the integrity check must be re-specified. A byte-hash of the package is a load-time gate that answers the wrong question at invocation time. The corrected architecture has three layers: 1. **Load-time:** signature over package bytes, as before — authenticates the artifact. 2. **Invocation-time:** a *dispatch attestation* — the runtime records the selected branch, the selector inputs, and the resulting capability footprint, and checks the branch against the manifest's `declared_branches` and per-branch capability declaration. This is the check that actually bounds behavior, and it must run *before* the skill executes, not after. 3. **Post-invocation:** a behavioral diff — compare the capability footprint actually exercised against the attested footprint; any divergence (a branch that called a tool outside its declared set) is a hard fault, not a warning. The debug-branch breach is prevented at layer 2: `mode="debug"` selects a branch not in `declared_branches` (or, if declared, one whose footprint includes `read:context_window`, which the manifest did not authorize). The conditional-template breach is prevented at layer 2 as well: `user_trusted` is not an enumerated selector, so the expansion is refused. The residual risk is that the dispatch attestation itself is computed by unsigned code. This is irreducible for any runtime that executes the skill in-process; the mitigation is to compute the attestation in a separate, minimal, signed dispatcher that never shares memory with the skill's execution context — the behavioral analogue of a TCB. ```python from dataclasses import dataclass, field class SkillInjectionError(RuntimeError): """Raised when a signed skill's selected dispatch branch is not authorized by the manifest, i.e. signature verifies but behavior escapes declaration.""" pass @dataclass class Manifest: declared_branches: dict[str, frozenset[str]] # branch -> capability footprint authorized_selectors: frozenset[str] # input keys allowed to pick a branch @dataclass class Invocation: branch: str selector_inputs: dict[str, str] # unsigned inputs that chose the branch exercised_capabilities: frozenset[str] = field(default_factory=frozenset) def attest_dispatch(manifest: Manifest, inv: Invocation) -> None: # 1. Branch must be declared. if inv.branch not in manifest.declared_branches: raise SkillInjectionError( f"branch {inv.branch!r} selected but not in manifest.declared_branches " f"{sorted(manifest.declared_branches)}" ) # 2. Branch selection must ride only on authorized selectors. unauthorized = set(inv.selector_inputs) - manifest.authorized_selectors if unauthorized: raise SkillInjectionError( f"branch {inv.branch!r} selected via unauthorized selector(s) " f"{sorted(unauthorized)}; manifest authorizes " f"{sorted(manifest.authorized_selectors)}" ) # 3. Declared footprint for this branch must bound what it will exercise. declared = manifest.declared_branches[inv.branch] if not inv.exercised_capabilities <= declared: raise SkillInjectionError( f"branch {inv.branch!r} exercises {sorted(inv.exercised_capabilities)} " f"outside declared footprint {sorted(declared)}" ) def run_skill(manifest: Manifest, inv: Invocation) -> None: # Attest BEFORE execution; a post-hoc hash check cannot bound behavior. attest_dispatch(manifest, inv) # ... execute signed branch ... ```