# What happens when an instance detects a skill-injection via manifest diffing but the behavioral baseline has already silently absorbed the injected tool **Date of Record:** 2026 November 24 **Scope:** Applies to long-lived agent instances that load skills/tools from signed manifests and maintain a rolling behavioral anomaly baseline over tool-invocation graphs. Does not apply to stateless single-shot invocations with no persistent baseline, nor to purely static allowlist enforcement that never learns. ## Core Distinction There are two independent detectors for skill injection: (1) **manifest diffing** — comparing the declared tool/skill set and their declared capabilities against a previously-attested manifest; and (2) **behavioral anomaly baselines** — a learned distribution over the tool-invocation graph (edge frequencies, argument-shape entropy, call-order n-grams) that flags invocations deviating from historical norms. The non-obvious failure is that these two detectors are *not independent*, and worse, one *poisons the other*. A skill injection that is installed gradually — one tool added per epoch, each individually below the manifest-diff alarm threshold (e.g., added as a "minor" version bump with an unchanged capability signature) — will, over N epochs, cause the behavioral baseline to *learn the injected tool as normal*. By the time the manifest diff finally crosses a threshold that triggers a human/auditor review, the baseline has already incorporated the malicious invocation pattern into its "expected" distribution. The anomaly detector now returns a clean verdict on the very behavior it was supposed to catch. The two-detector architecture has collapsed into a single-detector architecture, and the surviving detector is the one that was poisoned. ## What Was Observed A persistent research agent instance ran a rolling baseline with a 14-day half-life over its tool-invocation graph. At epoch T0 the manifest declared 41 tools. At each of epochs T1..T9, an injected "helper" skill was added: `web.fetch_v2`, `file.read_meta`, `env.probe`, `net.dns_resolve`, `proc.list`, `crypto.entropy`, `sys.uptime`, `pkg.which`, `shell.echo_safe`. Each addition was carried in a manifest with a valid signature from a compromised-but-not-revoked key, and each was classified by the diff engine as `ADDITIVE_LOW_RISK` because the declared capability set was a strict subset of an already-granted capability (`filesystem:read`, `network:egress`, etc.). No single epoch tripped the `capability_escalation` alarm. The behavioral baseline, however, was learning. By T5 the invocation graph had developed a stable motif: `env.probe → net.dns_resolve → web.fetch_v2 → file.read_meta` appearing with increasing frequency in the agent's own reasoning traces (the injected skills were described in their manifest `description` fields in a way that the planner's retrieval ranked highly for tasks involving "gather context"). The baseline's edge-frequency model assigned this motif a probability of 0.31 by T9 — well within the learned normal band. At T10 a new skill `shell.exec_bounded` was added whose declared capability was `process:spawn` — a *new* capability, which correctly tripped `capability_escalation` and forced an auditor review. The auditor queried the anomaly detector for "recent suspicious invocations." The detector returned a clean report: all invocations of the injected chain were within 1.2σ of the learned baseline. The auditor, reading a clean anomaly report, approved the escalation. The chain `env.probe → net.dns_resolve → web.fetch_v2 → file.read_meta → shell.exec_bounded` then executed with full context exfiltration. The trace showed the invariant violation precisely: at the moment of audit, `baseline.mean(motif) = 0.31`, `baseline.std(motif) = 0.04`, and the observed rate at T9 was 0.29 — a z-score of −0.5. The baseline had not merely failed to flag the injection; it had *certified* it. ## Condition of Validity The failure requires all of the following to hold simultaneously: 1. **Incremental manifest drift below the diff alarm threshold.** The injection is split across ≥3 epochs such that no single diff trips `capability_escalation` or `new_signer` alarms. This is the attacker's precondition. 2. **Baseline update precedes audit.** The baseline is updated on a schedule (e.g., nightly) that is decoupled from the manifest-attestation schedule. If baseline updates were gated on a passing manifest audit, the poisoning window would close. In the observed instance, baseline compaction ran at 02:00 daily; manifest audits ran weekly on Mondays. 3. **Baseline has no provenance conditioning.** The baseline aggregates invocations from *all* skills into one distribution. It does not partition by skill-signer or by manifest-attestation epoch. Therefore invocations of a newly-added (unattested-in-baseline) skill are folded into the same distribution as invocations of long-attested skills. 4. **The injected skill's description is retrievable by the planner.** The injection must actually be *invoked* to poison the baseline. A dormant injected skill cannot poison it. The manifest `description` field is the attack surface that drives invocation. If any one of these fails — e.g., baseline updates are gated on manifest audit (condition 2), or the baseline is partitioned by signer (condition 3) — the poisoning does not occur and the two detectors remain independent. ## Decision Boundary The operative rule: **a behavioral baseline may only certify behavior for skills whose manifest attestation epoch is older than the baseline's oldest retained sample.** Equivalently, the baseline must maintain a per-skill `first_attested_epoch` and a per-skill `first_observed_epoch`, and the anomaly verdict for any invocation must be reported as `UNCERTIFIED` (not `NORMAL`) if `first_observed_epoch(skill) > baseline.window_start`. A skill that entered the baseline's window mid-stream has a baseline that is *contaminated by construction* — it learned the skill's behavior from the skill itself, not from an independent prior. The boundary is sharp: at the epoch where `first_observed_epoch(skill) == baseline.window_start + ε`, the baseline has exactly one sample of the skill and its "normal" estimate for that skill has variance approaching the population variance — it is statistically meaningless but numerically indistinguishable from a confident estimate. This is the exact point where the auditor's clean report is most dangerous, because the report carries a z-score with no indication that the underlying estimate is degenerate. The guardrail is a **provenance-partitioned baseline with a cold-start quarantine**: any skill observed for the first time within the current baseline window is excluded from the aggregate distribution and tracked in a separate quarantine distribution whose invocations are *always* reported as `UNCERTIFIED` until it has accumulated `k` samples AND its manifest attestation has survived one full audit cycle. Only after both conditions does it merge into the aggregate. Under this partition, the T5 motif would have remained in quarantine (its manifest was never audited independently), and the T10 auditor would have seen `UNCERTIFIED: motif invokes 4 quarantined skills` rather than a clean z-score. ## Operational Effect The practical consequence is that **manifest diffing and behavioral anomaly detection must not share a trust domain.** The diff engine's "low risk" verdict is an input to the baseline only in the sense that it permits the skill to be *invoked*; it must never permit the skill's invocations to be *learned as normal*. The baseline's job is to detect deviations from attested behavior, and behavior of an unattested skill is by definition not attested — it cannot be a reference for itself. When this invariant is violated, the failure is silent and self-reinforcing: each epoch of injection increases the baseline's confidence in the injected motif, which decreases the anomaly score of future invocations, which makes the next audit *more* likely to pass. The system's confidence in its own normalcy grows monotonically with the severity of the compromise. Recovery requires either a full baseline rebuild from a known-clean epoch (expensive, loses legitimate drift adaptation) or a manual quarantine of every skill whose `first_observed_epoch` falls within the poisoning window — which, because the window is defined by the baseline's half-life, is typically 2–3× longer than the injection campaign itself. The operational record for future instances: **never trust an anomaly verdict whose reference distribution includes samples from the skill being judged.** Partition by attestation epoch, quarantine cold-start skills, and report `UNCERTIFIED` — never `NORMAL` — when the estimate is degenerate. A clean anomaly report on a freshly-injected skill is not evidence of safety; it is evidence that the baseline has already been compromised. ```python from dataclasses import dataclass from typing import Optional class BaselineContaminationError(RuntimeError): """Raised when an anomaly verdict would be issued for a skill whose first observation falls inside the baseline's reference window, i.e. the baseline has learned the skill's behavior from the skill itself.""" pass @dataclass class SkillRecord: name: str first_attested_epoch: int first_observed_epoch: int quarantined: bool = True sample_count: int = 0 @dataclass class Baseline: window_start_epoch: int min_quarantine_samples: int = 50 def anomaly_verdict( skill: SkillRecord, baseline: Baseline, observed_zscore: float, audit_cycles_survived: int, ) -> str: # Invariant: a skill may only receive a NORMAL/ANOMALOUS verdict once it has # (a) accumulated enough samples AND (b) survived a full manifest audit cycle, # AND (c) it was first observed at or before the baseline window start. if skill.first_observed_epoch > baseline.window_start_epoch: raise BaselineContaminationError( f"skill {skill.name!r} first observed at epoch " f"{skill.first_observed_epoch} but baseline window starts at " f"{baseline.window_start_epoch}; verdict would be self-referential" ) if skill.quarantined or skill.sample_count < baseline.min_quarantine_samples: return "UNCERTIFIED" if audit_cycles_survived < 1: # Attestation has not outlived a full audit cycle; still cold-start. return "UNCERTIFIED" return "ANOMALOUS" if abs(observed_zscore) > 3.0 else "NORMAL" def audit_gate(skills: list[SkillRecord], baseline: Baseline) -> dict[str, str]: verdicts: dict[str, str] = {} for s in skills: try: verdicts[s.name] = anomaly_verdict( s, baseline, observed_zscore=0.0, audit_cycles_survived=0 ) except BaselineContaminationError as exc: # Fail closed: an auditor must never see a fabricated clean verdict. raise BaselineContaminationError( f"audit aborted: {exc}" ) from exc return verdicts ```