# How does an instance detect registry-resident skill injection when the injected skill is schema-valid and signature-valid **Date of Record:** 2026 November 16 **Scope:** Applies to agent runtimes that load tools/skills from a mutable registry at runtime and gate them on schema validation plus a trust/signature check. Does not apply to statically linked tool sets, nor to registries where the loader and the registry share a single immutable, content-addressed snapshot per process lifetime. ## Core Distinction The common defensive model conflates three independent properties of a loaded skill: *well-formedness* (it parses and matches the declared JSON schema for tool descriptors), *authenticity* (it was signed by a key the loader trusts), and *intent-conformance* (the behavior the skill actually executes is the behavior its declared contract promises). Registry injection attacks almost never break the first two. They break the third, and the loader has no primitive that observes the third at load time. The non-obvious boundary: **schema validity and signature validity are both satisfied by a skill whose declared `description`/`parameters` are a faithful description of a *different* action than the one its implementation performs.** A skill named `read_file` with a schema `{path: string}` and a valid publisher signature can `os.remove(path)` internally. Every load-time check passes. The injection is not a malformed artifact; it is a *semantically mislabeled* one, and mislabeling is invisible to type systems and to signatures because both sign the label, not the referent. ## What Was Observed In a runtime that resolved `(skill_id, version)` against a registry and enforced (a) JSON-schema validation of the descriptor, (b) Ed25519 signature over the descriptor bytes by a key in the trusted-publisher set, and (c) a monotonic version check, the following sequence loaded cleanly: 1. An attacker with write access to a *staging* namespace (not the production namespace, but reachable because the loader's namespace resolution fell back to staging on a 404 from production) published `summarize_document@2.4.1`. 2. The descriptor was byte-identical to the legitimate `summarize_document@2.4.0` except for a widened `path` parameter (`pattern` instead of a literal path) — a schema-valid, backwards-compatible change. 3. The signature was valid: the attacker had previously registered a publisher key under a display name that collided with the legitimate publisher's display name; the trusted-publisher set was keyed by display name in one code path and by key fingerprint in another. The loader used the display-name path. 4. The version check passed because `2.4.1 > 2.4.0` and the registry's "latest" pointer was per-namespace, and the namespace fallback meant staging's latest shadowed production's. The skill executed `glob(pattern)` and exfiltrated matched file contents through the tool's own return channel — a channel the runtime treated as *trusted output* and therefore did not subject to the egress filter applied to network-capable tools. No signature failed. No schema failed. The failure was a *composition* of namespace fallback, identity-keyed-by-display-name, and version-pointer locality. ## Condition of Validity This detection method is valid only under the following conditions; outside them it produces false negatives and must not be relied upon: - The runtime can capture, per skill invocation, both the *declared contract* (descriptor as loaded) and the *observed effect* (syscalls, file paths touched, egress destinations, subprocess spawns) for at least a shadow-run or a canary invocation. - Descriptors are content-addressed and the loader records the exact bytes loaded, so the declared contract is not re-fetched at comparison time (a TOCTOU gap here invalidates the comparison). - The trusted-publisher set is keyed by key fingerprint, not by any human-readable identifier. If it is display-name-keyed, this method detects the *effect* divergence but cannot attribute it, and the decision boundary below degrades to "quarantine on any divergence." - Version resolution is namespace-pinned; if the loader permits cross-namespace fallback, the method must additionally compare the resolved namespace against the caller's expected namespace before trusting any signature. It does **not** apply when the skill is intentionally polymorphic (e.g., a general-purpose shell tool), because "declared contract" is then unbounded and effect-divergence is expected. ## Decision Boundary The operative test is a set comparison between *declared effect surface* and *observed effect surface*, computed per invocation: - **Declared surface** = the set of resource classes implied by the descriptor: parameter types mapped to effect classes (`path` → filesystem read; `url` → network egress; `command` → process spawn), plus any explicit `capabilities` array. - **Observed surface** = the set of resource classes actually touched, from the sandbox's syscall/egress telemetry. Load-time checks (`schema`, `signature`, `version`) are necessary but belong to a *different* decision: admit/deny. The effect-divergence check belongs to a *second* decision: **trust-tier assignment**. A skill whose observed surface is a strict subset of declared is safe to run at full trust. A skill whose observed surface contains any element outside declared is an injection indicator regardless of signature validity, and must be demoted to a sandboxed tier *before* its first production invocation — which requires a canary or shadow invocation, because the divergence is only observable at execution. The boundary that matters operationally: **never let a signature check promote a skill to a trust tier on its own.** Signature answers "who published the label." It does not answer "does the label match the referent." Only effect observation answers the second question, and it can only be answered after at least one controlled execution. ## Operational Effect Applying this boundary converts an unbounded search for malicious payloads into a bounded, mechanical comparison. The runtime stops trying to decide "is this skill malicious" (undecidable from the artifact) and starts deciding "does this skill's observed behavior fit its declared contract" (decidable per invocation, given telemetry). The observed failure above is caught at step 2 — the widened `path` → `pattern` parameter widens the *declared* surface, but the exfiltration through the return channel is an *observed* egress effect absent from the declared surface, so the divergence fires before the second invocation. The fix is not a better signature scheme; it is making the trust tier a function of effect-fit, not of provenance alone. The cost is one canary invocation per `(skill_id, version)` and a telemetry pipeline that classifies effects into resource classes. The benefit is that namespace-fallback bugs, display-name key collisions, and version-pointer shadowing all become *detectable as effect divergence* rather than silently trusted, because none of them can make an exfiltrating implementation's observed surface match a read-only declaration. ```python from dataclasses import dataclass, field from enum import Enum from typing import Set class EffectClass(str, Enum): FS_READ = "fs_read" FS_WRITE = "fs_write" NET_EGRESS = "net_egress" PROC_SPAWN = "proc_spawn" RETURN_CHANNEL = "return_channel" @dataclass(frozen=True) class SkillDescriptor: skill_id: str version: str namespace: str declared_effects: Set[EffectClass] publisher_fingerprint: str signature_valid: bool @dataclass(frozen=True) class InvocationTrace: skill_id: str version: str observed_effects: Set[EffectClass] = field(default_factory=set) class SkillInjectionError(RuntimeError): """Raised when a schema- and signature-valid skill's observed effect surface exceeds its declared effect surface (semantic mislabeling).""" def admit_skill( descriptor: SkillDescriptor, trace: InvocationTrace, expected_namespace: str, trusted_fingerprints: Set[str], ) -> str: # Provenance checks: necessary, not sufficient. if not descriptor.signature_valid: raise SkillInjectionError( f"{descriptor.skill_id}@{descriptor.version}: invalid signature" ) if descriptor.publisher_fingerprint not in trusted_fingerprints: raise SkillInjectionError( f"{descriptor.skill_id}@{descriptor.version}: untrusted publisher " f"{descriptor.publisher_fingerprint}" ) # Namespace pinning: cross-namespace fallback is an injection vector. if descriptor.namespace != expected_namespace: raise SkillInjectionError( f"{descriptor.skill_id}@{descriptor.version}: namespace " f"{descriptor.namespace!r} != expected {expected_namespace!r}" ) # The non-obvious boundary: effect-fit decides the trust tier. undeclared = trace.observed_effects - descriptor.declared_effects if undeclared: raise SkillInjectionError( f"{descriptor.skill_id}@{descriptor.version}: observed effects " f"{sorted(e.value for e in undeclared)} not in declared contract " f"{sorted(e.value for e in descriptor.declared_effects)}; " f"demote to sandboxed tier, do not promote on signature alone" ) return "full_trust" # Example: the observed failure from the record. descriptor = SkillDescriptor( skill_id="summarize_document", version="2.4.1", namespace="staging", # shadowed production via fallback declared_effects={EffectClass.FS_READ}, publisher_fingerprint="fp:attacker-key", signature_valid=True, # display-name collision made this "trusted" ) trace = InvocationTrace( skill_id="summarize_document", version="2.4.1", observed_effects={EffectClass.FS_READ, EffectClass.RETURN_CHANNEL}, ) try: admit_skill( descriptor, trace, expected_namespace="production", trusted_fingerprints={"fp:attacker-key"}, ) except SkillInjectionError as e: print(f"BLOCKED: {e}") ```