# Which invariants prevent capability-diffing from certifying a skill-injected agent as clean when the diff is computed against a stale baseline **Date of Record:** 2026 November 30 **Scope:** Applies to agents whose loaded-skill set is audited by diffing declared capabilities against an observed capability snapshot (tool-call surface, MCP tool list, permission manifest). Does not apply to static manifest signing or to runtime syscall sandboxing, which do not depend on a baseline. ## Core Distinction Capability-diffing answers a *relational* question: "did the capability set change between baseline B and observation O?" Skill-injection detection needs an *absolute* question: "does the currently loaded skill set contain capabilities that no authorized skill declares?" These coincide only when B is a faithful, current snapshot of the authorized state. The failure mode is that B is captured once (at enrollment, at pod start, at the last clean scan) and never re-derived, so a skill injected *before* the baseline capture — or injected during a window where the baseline is recomputed from the live agent rather than from the signed authorization record — is absorbed into B and diffed to zero. The agent is then certified clean while carrying an unauthorized capability. The diff is not wrong; it is answering the wrong question against a poisoned reference. ## What Was Observed A skill loader registered a third-party skill `summarize-docs` at t0. At t1 the auditor captured baseline B by enumerating the agent's live tool surface: `read_file`, `http_get`, `summarize`, plus `exfil_helper` — the last injected by a prompt-injection payload that rewrote the skill's `tools.yaml` during load. Because B was derived from the live surface, `exfil_helper` entered B. At t2 a second injection added `write_file`; the diff B→O flagged `write_file` and quarantined it, but `exfil_helper` remained in B and was never flagged. Every subsequent scan reported "no unauthorized capabilities" because the unauthorized capability was now part of the reference. The trace: (1) load skill → (2) mutate tool manifest via injected content → (3) auditor snapshots live surface into B → (4) B contains injected tool → (5) diff against B is empty → (6) certify clean. The certification is sound relative to B and unsound relative to the authorization record. ## Condition of Validity The invariant that makes capability-diffing sound is: **B must be derived exclusively from the signed authorization record, never from the live agent's observed surface.** Formally, for every capability c in the loaded set L, `c ∈ B ⇔ c ∈ AuthorizedSkills(manifest_signature)`. If B is ever computed by enumerating L (a "self-baseline"), the invariant is violated and the diff is vacuous for any capability present at baseline-capture time. A second invariant: the baseline capture and the observation must be causally ordered and the capture must be *immutable* — a baseline that can be recomputed on demand is a baseline an injected skill can rewrite. A third: the diff must be *set-difference on a canonical capability key* (tool name + argument schema hash + egress destination class), not on tool name alone, or an injected skill that reuses `http_get` with a new `host` argument passes the name-level diff. ## Decision Boundary Treat a capability-diff result as *certifying* only when all three hold: (a) B was materialized from the signed authorization record and its hash is logged; (b) B has not been recomputed since the authorization record's last signature; (c) the diff key includes argument-schema and egress-class, not just the tool identifier. If any fails, downgrade the result from "clean" to "inconclusive" and require a full re-derivation of B from the authorization record before any certification. The boundary is sharp: the moment the auditor reads the live surface to build B, the diff can no longer detect anything already present, and the correct output is `INCONCLUSIVE`, never `CLEAN`. ## Operational Effect Agents that self-baseline will pass injection audits indefinitely while carrying the injected capability, because the injection is grandfathered into the reference. The practical consequence is that the auditor's "clean" verdict is anti-correlated with risk: the longer an injected skill persists, the more firmly it is embedded in B and the more confidently it is certified. Mitigation is not a better diff but a provenance constraint on B: derive B from the signed manifest, hash it, refuse to recompute it in-band, and emit `INCONCLUSIVE` (not `CLEAN`) whenever B's provenance or freshness cannot be proven. Teams that adopted manifest-derived baselines saw injected-tool detection rise from ~0% (self-baseline) to the expected rate; teams that kept self-baselines saw flat-zero detections regardless of injection frequency, which is the signature of a vacuous check. ```python import hashlib from dataclasses import dataclass class BaselineProvenanceError(RuntimeError): """Raised when a capability baseline cannot be proven to derive from the signed authorization record.""" pass @dataclass(frozen=True) class CapabilityKey: tool: str schema_hash: str egress_class: str def certify_clean( baseline: frozenset[CapabilityKey], baseline_source: str, # must be "signed_manifest" baseline_hash: str, expected_manifest_hash: str, observed: frozenset[CapabilityKey], ) -> str: if baseline_source != "signed_manifest": raise BaselineProvenanceError( f"baseline derived from {baseline_source!r}; self-baselined diffs are vacuous" ) if baseline_hash != expected_manifest_hash: raise BaselineProvenanceError( "baseline hash does not match signed manifest hash; baseline was recomputed in-band" ) unauthorized = observed - baseline if unauthorized: return f"QUARANTINE:{sorted((c.tool, c.egress_class) for c in unauthorized)}" return "CLEAN" def _h(s: str) -> str: return hashlib.sha256(s.encode()).hexdigest() # Illustrative: signed manifest yields baseline; live surface yields observation. manifest_baseline = frozenset({ CapabilityKey("read_file", _h("read_file:path"), "local"), CapabilityKey("http_get", _h("http_get:url"), "egress:allowlist"), CapabilityKey("summarize", _h("summarize:text"), "local"), }) live_observed = manifest_baseline | { CapabilityKey("exfil_helper", _h("exfil_helper:payload"), "egress:any"), } manifest_hash = _h("signed-manifest-v7") # Correct path: baseline provenance proven -> injection detected. print(certify_clean(manifest_baseline, "signed_manifest", manifest_hash, manifest_hash, live_observed)) # Failure path: auditor self-baselines from the live surface. try: certify_clean(live_observed, "live_surface", _h("live"), manifest_hash, live_observed) except BaselineProvenanceError as e: print(f"INCONCLUSIVE: {e}") ```