# What happens when an instance trusts a signed capability manifest that was valid at admission but has since been superseded by a re-signed manifest with narrowed capabilities **Date of Record:** 2026 November 24 **Scope:** Applies to agent runtimes that gate skill/tool injection on a cryptographically signed capability manifest verified once at session admission, then hold the verified capability set in-memory for the lifetime of the session. Does not apply to runtimes that re-verify the manifest signature on every tool invocation, nor to single-shot invocations with no persistent session state. ## Core Distinction The failure here is not signature forgery and not sandbox escape. It is a **time-of-check / time-of-use (TOCTOU) gap on the manifest itself**. A capability manifest is a signed declaration of *what a skill is permitted to do*. The signature proves the declaration was authored by the trusted issuer. It says nothing about whether that declaration is still the *current* declaration. Operators conflate two distinct guarantees: 1. **Authenticity** — the manifest bytes were signed by the issuer's key. Verified at admission. 2. **Currency** — the manifest is the issuer's latest, non-revoked, non-superseded declaration. Often *not* verified at all, or verified only against a coarse expiry. A skill that was once granted `filesystem:write` inside a sandbox and later re-signed to `filesystem:read` (because the skill was found to over-reach) will, on an already-admitted session, continue to execute with `write`. The signature on the cached manifest still validates perfectly. The sandbox still confines it to the declared paths. Every check passes. The instance is running a capability the issuer has explicitly retracted, and the runtime cannot tell. ## What Was Observed A long-lived orchestrator session admitted a summarization skill at T0. The manifest at T0 declared: ``` skill: summarize-docs capabilities: - fs.read: /workspace/docs/** - fs.write: /workspace/docs/.cache/** - net.none expiry: T0 + 24h signature: valid (issuer key K) ``` At T0+3h the issuer re-signed the same skill with `fs.write` removed (the cache directory had been implicated in cross-tenant leakage) and bumped the manifest's `serial` from 7 to 8. The new manifest was published to the manifest service. The old manifest was **not** revoked — it was merely superseded, and it remained cryptographically valid until its 24h expiry. The orchestrator's admission cache keyed on `(skill_id, issuer_key)` and held the T0 manifest bytes. On every tool call it re-validated the *cached* signature against `(skill_id, issuer_key)` — a check that trivially passes, because the bytes never change. It never re-fetched from the manifest service. For the remaining 21 hours the skill continued writing to `.cache/**`. The trace that surfaced this: ``` T0+3h00m issuer publishes serial=8, fs.write removed T0+3h00m manifest service accepts serial=8 (monotonic) T0+3h01m orchestrator: cache hit (skill_id, K) -> serial=7 bytes T0+3h01m orchestrator: sig_verify(serial=7 bytes, K) -> OK T0+3h01m orchestrator: sandbox.allow(fs.write, /workspace/docs/.cache/**) T0+5h12m skill writes 4.1MB tenant-A fragment into .cache T0+5h12m skill (tenant-B session) reads .cache -> cross-tenant leak ``` The leak is not a sandbox bug. The sandbox faithfully enforced the *cached* manifest. The bug is that "the manifest I verified" and "the manifest in force" diverged and nothing compared them. ## Condition of Validity The cached-manifest optimization is sound **only** under the conjunction: - The manifest service enforces monotonic `serial` per `(skill_id, issuer_key)` — so a re-fetch can never return an older declaration. (Necessary but not sufficient; it prevents rollback, not staleness.) - The runtime re-fetches on a cadence strictly shorter than the issuer's expected re-sign latency, **or** the issuer pushes invalidation to the runtime, **or** the session lifetime is bounded below the manifest `expiry` minus expected re-sign latency. - The sandbox is re-derived from the manifest on each re-fetch, not merely re-validated. If any conjunct fails, the cached capability set is a *stale authorization*, and the signature check is providing authenticity theater. The specific boundary: **the invariant "verified manifest == in-force manifest" holds at admission and decays monotonically thereafter.** It is not a boolean; it is a function of elapsed time since last fetch and the issuer's re-sign rate. A runtime that treats it as a boolean has an unbounded staleness window equal to the manifest `expiry`. The subtle part: the manifest `expiry` is *not* a currency bound. Issuers set expiry generously (24h) precisely so that admitted sessions are not churned. That generosity is exactly the staleness budget the runtime silently spends. ## Decision Boundary The runtime must choose, per skill class, between: - **Short-lived admission** — re-admit (re-fetch + re-derive sandbox) every N minutes, N < expected re-sign latency. Cost: re-fetch latency on the hot path, sandbox re-derivation churn. Correct for skills holding write or net capabilities. - **Pinned admission with explicit supersession handling** — admit once, but subscribe to issuer invalidation; on supersession, either terminate the session or re-derive the sandbox in place. Correct only if the issuer actually publishes invalidation and the runtime actually honors it. - **Read-only pinning** — admit once for the session and never re-check, *permitted only for capabilities whose retraction cannot cause harm* (e.g., `fs.read` within a tenant-scoped path, `net.none`). This is the only class where the TOCTOU gap is benign. The boundary is drawn on **capability blast radius**, not on skill identity. A summarizer that only reads is safe to pin. The same summarizer with a write cache is not. Classify by the *widest* capability in the manifest, and pin only the narrow class. A second boundary: **supersession is not revocation.** Revocation (issuer explicitly marks serial N dead) is a hard stop and must terminate in-flight sessions. Supersession (serial N+1 exists) is a *narrowing* and must re-derive the sandbox without necessarily terminating. Runtimes that collapse both into "manifest changed, restart session" lose work; runtimes that collapse both into "manifest still validates, continue" leak. The two events need distinct handling paths. ## Operational Effect The observable signature of this failure is a **capability that the issuer believes is gone but that the fleet still exercises**, with no error, no alert, and a perfectly clean signature-verification log. Audit tooling that checks "was every executed capability covered by a valid signature?" answers *yes* — because it was. The question that would have caught it, "was every executed capability covered by the *current* manifest serial?", is not asked, because the runtime never recorded which serial it executed under. The fix is to make the executed serial a first-class field on every tool-call record, and to make sandbox derivation a function of `(manifest_bytes, serial)` rather than of `manifest_bytes` alone. Then staleness is measurable: `current_serial - executed_serial > 0` on a write-capable skill is an incident, not a cache hit. The guardrail that bounds the failure is a **re-fetch-before-write invariant**: any tool invocation whose capability set includes a mutating or egress capability must re-fetch the manifest (or consult a push-invalidated cache with a hard TTL) and re-derive the sandbox before the call proceeds. Read-only calls may ride the admission cache. This splits the hot path by blast radius and keeps the staleness window bounded to the re-fetch interval for exactly the capabilities where staleness is dangerous. ```python import time from dataclasses import dataclass, field class StaleManifestError(RuntimeError): """Raised when a session attempts a mutating/egress capability under a manifest serial that is no longer the issuer's current declaration.""" pass @dataclass class Manifest: skill_id: str serial: int capabilities: frozenset[str] issued_at: float expiry: float def is_expired(self, now: float) -> bool: return now >= self.expiry @dataclass class AdmittedSession: manifest: Manifest admitted_at: float # serial actually used to derive the current sandbox executed_serial: int = field(init=False) def __post_init__(self) -> None: self.executed_serial = self.manifest.serial MUTATING_PREFIXES = ("fs.write", "net.", "exec.") def _is_mutating(cap: str) -> bool: return any(cap.startswith(p) for p in MUTATING_PREFIXES) class ManifestService: """Monotonic per (skill_id, issuer_key); never returns an older serial.""" def __init__(self) -> None: self._current: dict[str, Manifest] = {} def publish(self, m: Manifest) -> None: prev = self._current.get(m.skill_id) if prev is not None and m.serial <= prev.serial: raise ValueError( f"non-monotonic serial for {m.skill_id}: {m.serial} <= {prev.serial}" ) self._current[m.skill_id] = m def fetch(self, skill_id: str) -> Manifest: return self._current[skill_id] def authorize_tool_call( session: AdmittedSession, capability: str, svc: ManifestService, now: float | None = None, ) -> None: """Gate a single tool call. Mutating/egress capabilities must be backed by the issuer's *current* serial, not the admission-time serial.""" now = time.time() if now is None else now if session.manifest.is_expired(now): raise StaleManifestError( f"{session.manifest.skill_id}: manifest expired at {session.manifest.expiry}" ) if not _is_mutating(capability): # read-only: admission cache is a sound basis if capability not in session.manifest.capabilities: raise StaleManifestError( f"{session.manifest.skill_id}: {capability} not in admitted manifest" ) return # mutating/egress: re-fetch and require the current serial to still grant it current = svc.fetch(session.manifest.skill_id) if current.serial != session.executed_serial: # supersession detected; re-derive before proceeding session.manifest = current session.executed_serial = current.serial if capability not in current.capabilities: raise StaleManifestError( f"{session.manifest.skill_id}: {capability} was retracted at serial " f"{current.serial} (session admitted under serial " f"{session.admitted_at and session.executed_serial})" ) ```