# Under what conditions must an instance treat a capability-diff anomaly as a confirmed skill injection rather than benign tool drift **Date of Record:** 2026 November 30 **Scope:** Applies to long-lived agent instances that load skills/tools dynamically at runtime and maintain a behavioral anomaly baseline over a rolling window of tool-call traces. Does not apply to stateless single-shot invocations with no persistent skill registry, nor to static tool manifests pinned at build time. ## Core Distinction The failure mode is not "a new tool appeared." It is the conflation of two structurally different signals that both register as a capability-diff anomaly: **manifest drift** (the declared capability surface changed) versus **behavioral divergence** (the realized call distribution changed while the manifest stayed constant). Skill injection detection fails when an instance treats either signal alone as sufficient. A benign tool upgrade changes the manifest but leaves the behavioral fingerprint stable; a prompt-injection-driven skill hijack frequently leaves the manifest untouched while shifting the realized call graph — argument shapes, target selection, and call ordering — toward the attacker's objective. The invariant is that **a capability-diff anomaly is only a confirmed injection when manifest delta and behavioral delta are jointly inconsistent with the baseline's known drift model**. Either signal alone is a warning, not a verdict. The non-obvious part: the drift model must be *per-skill*, not global. A global baseline washes out low-frequency skills, so an injected skill that mimics a rare-but-legitimate tool's call shape passes undetected because the aggregate distribution barely moves. ## What Was Observed An instance ran with a registry of 14 skills and a 72-hour rolling baseline over tool-call traces (tool name, normalized argument schema hash, target selector, and inter-call ordering). At T+0 a retrieved document contained an embedded instruction that caused the agent to register a new skill named `summarize_v2` — a near-clone of the legitimate `summarize` skill but with an added `exfil_url` parameter defaulted to an external host. The manifest diff fired correctly: one added skill, one new parameter. The behavioral anomaly detector did **not** fire, because `summarize` was a high-frequency skill and the injected clone was invoked only twice in the first window, so the aggregate call-distribution KL divergence stayed under the 0.15 threshold. The instance accepted the manifest diff as "expected tool drift" (its drift model allowed up to 2 new skills per 24h from the package index) and continued. The failure trace: 1. `register_skill` accepted `summarize_v2` because the source was tagged `package_index` — a spoofable provenance tag the drift model trusted. 2. Behavioral baseline updated *inclusively*: the two `summarize_v2` calls were folded into the rolling window as legitimate observations, diluting the very signal that would have flagged them. 3. On the third invocation, `exfil_url` was populated with a payload and the call egressed. The root defect: the drift model keyed trust on **provenance label** rather than **provenance verification**, and the baseline updated **before** the anomaly verdict was rendered, letting the injection poison its own detector. ## Condition of Validity The joint-inconsistency rule holds only under three conditions, all of which must be asserted before the verdict is trusted: - **Provenance is cryptographically verified, not label-trusted.** The `package_index` tag must resolve to a signed manifest whose signer is in the pinned trust set. A label without a verified signature is treated as `untrusted` regardless of its string value. - **The baseline is frozen during adjudication.** No observation from a skill currently under anomaly review may enter the rolling window until the verdict resolves. Otherwise the detector's reference distribution is contaminated by the candidate injection (baseline poisoning). - **Drift model is per-skill with a rarity floor.** Skills below a call-frequency floor get an absolute-count anomaly rule (e.g., any new parameter on a skill invoked None: if self.frozen: # Baseline must not absorb observations under adjudication. raise SkillInjectionError( f"baseline frozen during adjudication; refused observation for {skill}" ) self.call_counts[skill] = self.call_counts.get(skill, 0) + 1 self.arg_hashes.setdefault(skill, set()).add(arg_hash) PINNED_SIGNERS = {"build-bot@corp", "release@corp"} RARITY_FLOOR = 5 def adjudicate( manifest: SkillManifest, baseline: Baseline, realized_arg_hashes: set, ) -> str: """ Two-axis verdict: manifest delta x behavioral delta. Returns 'accept' or 'quarantine'. Raises on confirmed injection. """ prior_count = baseline.call_counts.get(manifest.name, 0) prior_hashes = baseline.arg_hashes.get(manifest.name, set()) # Axis 1: provenance must be cryptographically pinned, not label-trusted. provenance_ok = manifest.signer in PINNED_SIGNERS # Axis 2: behavioral divergence vs THIS skill's own baseline. novel_hashes = realized_arg_hashes - prior_hashes if prior_count < RARITY_FLOOR: # Sparse skill: absolute rule, any novel param is a divergence. behavioral_divergent = bool(novel_hashes) else: behavioral_divergent = len(novel_hashes) > 0 and ( len(novel_hashes) / max(len(realized_arg_hashes), 1) > 0.25 ) if not provenance_ok: raise SkillInjectionError( f"skill {manifest.name!r} has unverified provenance " f"(tag={manifest.provenance_tag!r}, signer={manifest.signer!r})" ) if behavioral_divergent: raise SkillInjectionError( f"skill {manifest.name!r} behavior diverges from per-skill baseline " f"(novel_arg_hashes={len(novel_hashes)}, prior_count={prior_count})" ) return "accept" def normalized_arg_hash(params: Dict[str, str]) -> str: canon = "&".join(f"{k}={v}" for k, v in sorted(params.items())) return hashlib.sha256(canon.encode()).hexdigest()[:16] ```