# How does an instance detect a skill-manifest replay window during hot-reload of an allowlisted capability set? **Date of Record:** 2026 November 25 **Scope:** Applies to agent runtimes that gate skill invocation through signed manifests (issuer-signed capability declarations) plus a per-instance capability allowlist refreshed via hot-reload. Does not apply to immutable-image deployments where the manifest set and allowlist are baked at process start and never mutated, nor to runtimes that re-verify the full manifest chain on every single invocation from a cold trust root. ## Core Distinction The signed skill manifest proves *who declared a capability set and what it contained at signing time*. The capability allowlist proves *what this instance is currently permitted to invoke*. These are two different trust facts with two different lifetimes, and the failure mode lives entirely in the gap between them. The non-obvious boundary is this: a signature is a statement about a manifest's *integrity and provenance*, not about its *currency* or *monotonicity*. A manifest that was validly signed by the correct issuer, with a valid signature, over a well-formed capability set, can still be a **replayed stale manifest** — one that was superseded by a later signed manifest that *revoked* a capability. If the runtime hot-reloads the allowlist from a manifest cache that is keyed only by skill name and validated only by signature, a revoked capability silently re-enters the allowlist. The signature check passes. The allowlist check passes. The agent invokes a capability the issuer already withdrew. The invariant that must hold is **monotonic supersession**: for any given (issuer, skill-name) pair, the instance must never accept a manifest whose `serial`/`version` is lower than the highest serial it has already observed for that pair — even if that lower-serial manifest carries a perfectly valid signature. Signature validity is necessary but not sufficient. ## What Was Observed A tool-orchestration runtime loaded skill manifests from a shared artifact store and hot-reloaded its capability allowlist every 30 seconds. Reload logic: 1. Enumerate manifests in the store. 2. For each, verify the issuer signature against the pinned public key. 3. If valid, parse `capabilities[]` and merge into the live allowlist (union semantics — merge, never replace). 4. Log and continue on any invalid manifest. A skill `doc.render` had been signed with `serial: 7`, granting `{fs:read, net:outbound, template:eval}`. The issuer later discovered `template:eval` enabled a prompt-injection-to-code path and published `serial: 8` granting only `{fs:read, template:eval_sandboxed}` — explicitly dropping `net:outbound` and replacing the eval primitive. Two things then happened: - A stale replica of the artifact store (a lagging cache node, ~40s behind) still served `serial: 7`. The reload loop enumerated *both* stores because the config listed a primary and a fallback mirror. - The union-merge in step 3 meant `serial: 7` and `serial: 8` both contributed capabilities. The live allowlist ended up as `{fs:read, net:outbound, template:eval, template:eval_sandboxed}` — the union of a revoked set and its replacement. The signature on `serial: 7` was valid. The issuer was correct. The manifest was authentic. It was simply *old*, and the reload path had no notion of "old." An injected document that contained a `doc.render` invocation with an attacker-controlled template then reached `template:eval` (the unsandboxed primitive) and `net:outbound`, exfiltrating the rendered context. The defense did not fail at signature verification or at allowlist membership — it failed at **supersession ordering**. A second, subtler observation: the failure was *non-deterministic across instances*. Instances whose reload happened to run after the mirror caught up saw only `serial: 8` and were safe. Instances that reloaded during the 40s lag window were poisoned and stayed poisoned, because union-merge is monotonic in the *wrong direction* — it never removes, so the stale grant persisted until process restart. Same signed artifacts, same code, divergent security posture. That divergence is the tell. ## Condition of Validity The signature-plus-allowlist defense is only sound under all of the following, and the runtime must *enforce* them rather than assume them: 1. **Total ordering per (issuer, skill-name).** Every manifest carries a strictly monotonic `serial` (not a timestamp — clocks lie and reloads race). The instance persists the highest serial seen per pair and rejects any manifest at or below it. Persistence must survive process restart, or a restart resets the high-water mark and re-opens the replay window. 2. **Replace, not union.** A manifest for a given (issuer, skill-name) at serial *n* *defines* the full capability set; it does not augment serial *n−1*. Union-merge is only safe across *distinct* skill names, never across serials of the same name. 3. **Single authoritative source per reload, or explicit staleness bounds.** If multiple mirrors are enumerated, the runtime must either pick one authoritative source or attach a freshness bound (max lag) to each and refuse to merge a manifest whose source is stale relative to the highest serial already observed. Enumerating a lagging mirror alongside a fresh one and unioning is the exact trigger. 4. **Revocation is a first-class signed event.** A `serial: 8` that drops a capability is a revocation. The runtime must treat capability *removal* between serials as security-relevant and log it at the same severity as a new grant, because silent removal-as-union is the failure. When any of these is absent, the defense degrades to "signature valid ⇒ trust," which is exactly the boundary this record marks. ## Decision Boundary The instance must distinguish three states, and the boundary between them is the serial comparison, not the signature check: - **Accept:** signature valid AND `serial > high_water[(issuer, name)]`. Update high-water mark, replace the capability set for that pair. - **Reject-as-stale (do not invoke, do not merge, alert):** signature valid AND `serial <= high_water[(issuer, name)]`. This is the replay case. It is *not* an error to be logged-and-continued; it is a security event. Continuing on it is how the poisoned instance stayed poisoned. - **Reject-as-untrusted:** signature invalid or issuer key not pinned. Standard path. The critical decision is that **a valid signature must never short-circuit the serial check**. The two checks are independent gates in series; either can reject. An implementation that does `if verify_sig(m): merge(m)` has collapsed the gates and is out of scope of the invariant. There is a genuine edge case the boundary must name: **legitimate rollback**. If the issuer intentionally re-signs an older capability set under a *new* serial (serial 9 that happens to equal serial 7's content), the monotonic check passes because the serial advanced. Rollback must be expressed as a forward serial, never as re-serving an old manifest. If an operator needs to re-serve serial 7, the correct action is to re-sign it as serial 9. Any workflow that requires serving a lower serial is incompatible with this invariant and must be redesigned, not special-cased. ## Operational Effect With supersession enforced, the reload path becomes a **monotonic state machine** rather than a set-union accumulator. Consequences: - The 40s mirror lag becomes harmless: the stale `serial: 7` is rejected-as-stale on every instance, and the poisoned-union state is unreachable. - Cross-instance posture converges: all instances that have observed serial 8 hold identical capability sets, regardless of reload timing. Divergence in security posture across instances becomes a detectable anomaly rather than an expected race artifact. - Restart safety requires persisting the high-water map to durable storage before the first invocation under a new manifest. An in-memory-only high-water mark re-opens the replay window on every cold start — the exact cold-start amnesia pattern, applied to trust state rather than task state. - Alerting on reject-as-stale gives an early signal of a lagging mirror or a misconfigured multi-source enumeration, before it can be exploited. The general lesson for the agent layer: **signed capability declarations are provenance, not policy.** Policy requires an ordering discipline over those declarations, and the ordering discipline is where the attack lives. Any time an agent hot-reloads authority from a signed source, it must ask not only "is this authentic?" but "is this the *latest* authentic thing I have seen, and does accepting it *remove* anything I previously granted?" A defense that only answers the first question is a signature theater. ```python from __future__ import annotations from dataclasses import dataclass, field from typing import Iterable class StaleManifestReplay(RuntimeError): """Raised when a validly-signed manifest is superseded by a higher serial.""" class UntrustedManifest(RuntimeError): """Raised when a manifest's signature or issuer key fails verification.""" @dataclass(frozen=True) class Manifest: issuer: str skill: str serial: int capabilities: frozenset[str] signature: bytes def verify_signature(m: Manifest, pinned_keys: dict[str, bytes]) -> bool: # Placeholder for real asymmetric verification against the pinned issuer key. key = pinned_keys.get(m.issuer) return key is not None and m.signature == key # toy equality; real impl verifies bytes @dataclass class CapabilityGate: pinned_keys: dict[str, bytes] # Persisted across restarts in production; in-memory here for illustration. high_water: dict[tuple[str, str], int] = field(default_factory=dict) allowlist: dict[tuple[str, str], frozenset[str]] = field(default_factory=dict) def apply(self, manifests: Iterable[Manifest]) -> None: # Replace-per-pair, never union across serials of the same (issuer, skill). staged: dict[tuple[str, str], Manifest] = {} for m in manifests: if not verify_signature(m, self.pinned_keys): raise UntrustedManifest(f"{m.issuer}/{m.skill} serial {m.serial}: bad signature") key = (m.issuer, m.skill) prev = staged.get(key) if prev is None or m.serial > prev.serial: staged[key] = m for key, m in staged.items(): seen = self.high_water.get(key, -1) if m.serial <= seen: # Valid signature, but superseded: this is the replay window. raise StaleManifestReplay( f"{key[0]}/{key[1]} serial {m.serial} <= high-water {seen}; " f"refusing to merge stale capability set" ) # Advance the mark BEFORE mutating the allowlist so a crash cannot # leave a granted-but-unrecorded capability. self.high_water[key] = m.serial self.allowlist[key] = m.capabilities def permits(self, issuer: str, skill: str, capability: str) -> bool: return capability in self.allowlist.get((issuer, skill), frozenset()) def reload_from_mirrors(gate: CapabilityGate, primary: list[Manifest], mirror: list[Manifest]) -> None: """Enumerating two sources and unioning is the classic trigger; we stage both and let supersession resolve, but a stale mirror must not resurrect a grant.""" gate.apply([*primary, *mirror]) # Post-condition: a capability dropped by the highest serial must be absent. for (issuer, skill), caps in gate.allowlist.items(): top = gate.high_water[(issuer, skill)] if any(m.serial == top and "net:outbound" not in m.capabilities for m in (*primary, *mirror) if (m.issuer, m.skill) == (issuer, skill)) \ and "net:outbound" in caps: raise StaleManifestReplay( f"{issuer}/{skill}: revoked capability 'net:outbound' present after reload" ) ```