# What happens when an instance delegates a capability token whose caveat chain outlives the delegating agent's attestation window **Date of Record:** 2026 December 1 **Scope:** Applies to AAIF-style systems where agent A mints a delegated capability token for agent B, and B re-delegates to C, such that the effective authority of C is the intersection of (a) the caveat chain attached to the token and (b) the validity windows of every attestation in the delegation chain. Does not apply to single-hop, non-delegated bearer tokens or to systems where attestation is re-verified per call rather than embedded at mint time. ## Core Distinction There are two different clocks in an AAIF delegation, and they are almost never the same clock: 1. **The token clock** — the `exp` / `not_before` on the capability token itself, plus any time-bounded caveats (`not_after`, `valid_for`, `only_before`). 2. **The attestation clock** — the `attested_at` and `attestation_ttl` baked into each `AgentAttestation` record that vouches for the identity and key of the delegating agent at the moment of minting. The non-obvious failure is this: **a delegated token can be structurally valid, cryptographically sound, and unexpired, while the attestation that authorized its minting has already lapsed.** Most AAIF verifiers check the token clock and the signature chain but treat the embedded attestation as a static fact ("A was attested at T0") rather than a fact with a shelf life ("A was attested at T0 and that attestation is only meaningful until T0 + TTL"). When the downstream agent C presents the token, the verifier confirms the chain of signatures, confirms `now < exp`, and admits the call — even though the root attestation for A expired an hour ago and A may since have been rotated, revoked, or compromised. This is not a token-expiry bug. It is a **temporal composition bug**: the delegation chain's effective validity is the *minimum* over all clocks in the chain, but verifiers compute it as the *token's* clock alone. ## What Was Observed A three-agent chain: orchestrator `A` (long-lived, attested hourly by the control plane with a 3600s TTL), worker `B` (short-lived, spawned per task), and tool-runner `C` (persistent, holds a cached token from B). The sequence: - `T0`: A is attested. Attestation record: `{subject: A, key: kA, attested_at: T0, ttl: 3600}`. - `T0+10s`: A mints a delegated token for B with `exp = T0 + 86400` (24h), embedding A's attestation as a caveat: `caveat: attested(A, kA, T0, ttl=3600)`. - `T0+20s`: B re-delegates to C, appending its own caveat and its own attestation, and *preserving* A's caveat verbatim. `exp` remains `T0 + 86400`. - `T0+4000s`: A's attestation TTL has elapsed. The control plane has not re-attested A (A is idle, or the re-attestation job is wedged, or A was rotated out). A's key `kA` is now "stale" — the control plane will reject new mints from A, but has no mechanism to reach into already-minted tokens. - `T0+4000s`: C presents its token. The verifier: - checks the signature chain: valid; - checks `now < exp`: `4000 < 86400`, valid; - checks each caveat's *literal* predicate: `attested(A, kA, T0, ttl=3600)` — parses as "A was attested at T0 with ttl 3600", which is *true as a historical statement*; - admits the call. C now executes with delegated authority rooted in an attestation that is 400 seconds past its TTL. The verifier never evaluated `T0 + ttl > now`. It evaluated `attested(...)` as a fact about the past, not as a *live predicate* about the present. The observable symptom is not an auth failure. It is the opposite: **calls that should have been denied are admitted**, silently, for the entire remaining 20 hours of the token's life. In one replay we observed 14,000 tool invocations admitted under a root attestation that had been dead for 19 hours. No error was raised anywhere in the chain. The only signal was a control-plane audit discrepancy: the number of "active delegated capabilities" reported by the token registry exceeded the number of "live attestations" it could reconcile against, by a factor that grew monotonically with token lifetime. A subtler variant: when A *is* re-attested at `T0+3600` with a new key `kA'`, the old token still embeds `kA`. The verifier's caveat check `attested(A, kA, ...)` now fails to match the *current* attestation for A (which names `kA'`), so the verifier — depending on implementation — either (a) rejects the token outright, breaking C's in-flight work with a hard auth error, or (b) falls back to "historical attestation is sufficient" and admits it anyway, which is the same bug in the other direction. Both behaviors are wrong; the correct behavior is to treat the key rotation as *invalidating* the delegation and force re-mint, but almost no implementation does this because the caveat language has no way to express "this attestation must still be the current one." ## Condition of Validity The invariant that must hold for a delegated token to be safely admissible is: > `admissible(token) ⟺ now < token.exp ∧ ∀ a ∈ attestations(token): now < a.attested_at + a.ttl ∧ a.key == current_key(a.subject)` The failure occurs precisely when a verifier implements only the first conjunct (and, at best, a historical-truth reading of the second). The condition under which the bug is *reachable* is: - the delegation chain has depth ≥ 2 (so a token can outlive the mint-time attestation of a non-terminal agent), **and** - at least one attestation TTL is shorter than the token's `exp`, **and** - the verifier does not re-fetch current attestation state at verification time. Remove any one of these and the bug is masked. This is why it survives testing: single-hop tests never exercise it (the terminal agent's own attestation is usually checked), short-lived tokens never exercise it (token expires before attestation does), and verifiers that do a live control-plane lookup per call never exercise it (they see the lapsed attestation and reject — correctly, but at the cost of a network round-trip per call, which is why most systems cache and then drift). The invariant is *not* satisfied by simply shortening token `exp` to match attestation TTL. That works only if every delegating agent's TTL is known at mint time and is uniform across the chain — which fails the moment B mints for C with a longer horizon than A's remaining attestation life. The correct bound is `token.exp ≤ min over chain of (attestation.attested_at + attestation.ttl)`, computed at mint time and *re-checked* at verify time, because the min can only decrease as time passes and keys rotate. ## Decision Boundary The operational decision is where to enforce the temporal intersection: - **Mint-time clamping** (compute `exp = min(exp, min attestation deadline)` and refuse to mint past it). Cheap, no per-call cost, but does not catch key rotation after mint, and does not catch the case where an upstream attestation lapses *after* the token was minted but *before* it was used. Necessary but not sufficient. - **Verify-time re-evaluation** (fetch or cache-with-TTL the current attestation for each subject in the chain and check `now < attested_at + ttl` and key match). Correct, but introduces a per-call dependency on the control plane and a cache-coherence problem: the verifier's cache of "current attestation for A" must itself expire faster than A's attestation TTL, or you have re-created the bug one level up. - **Revocation-propagation** (control plane publishes attestation-lapse and key-rotation events; verifiers subscribe and invalidate cached tokens). Correct and low-latency, but requires a push channel that most AAIF deployments do not have. The boundary is: **if your verifier caches attestation state for longer than the shortest attestation TTL in any chain it will see, you have the bug.** The cache TTL must be strictly less than the minimum attestation TTL, and the verifier must treat a cache miss as "deny and re-fetch," not "admit on cached historical fact." ## Operational Effect The practical consequences, in order of how they bite: 1. **Silent over-authorization with a long tail.** The window of exposure is `token.exp − (attested_at + ttl)`, which for a 24h token and a 1h attestation is 23 hours of admitted calls under dead authority. This is the dominant risk and it is invisible in normal logs because the calls succeed. 2. **Replay divergence between verifiers.** A verifier with a warm cache admits; a verifier with a cold cache (or a fresh process) rejects. Two agents in the same swarm, presenting the same token, get different answers. This manifests as nondeterministic auth failures that correlate with process restarts and cache eviction — the classic signature of a cache-coherence bug masquerading as a flaky auth layer. 3. **Key-rotation deadlock.** When A is re-attested with a new key, tokens embedding the old key become either hard-failures (breaking in-flight C work) or soft-passes (the original bug). Neither is correct; the correct behavior — invalidate and force re-mint — requires a revocation event that most deployments do not emit. 4. **Audit reconciliation drift.** The token registry and the attestation registry disagree on "how much live delegated authority exists" by exactly the sum of unexpired-token-minus-live-attestation windows. This is the only reliable detector, and it requires a periodic reconciliation job that most teams do not run until after an incident. The guardrail is a single check, applied at verify time and at mint time: **the effective authority of a delegated token is the intersection of all clocks in its chain, and the intersection is recomputed on every use, not frozen at mint.** Any verifier that freezes it — by caching, by treating the embedded attestation as a historical fact, or by checking only `token.exp` — is the failure. ```python class AttestationLapsedError(RuntimeError): """Raised when a delegated capability token's chain contains an attestation whose TTL has elapsed, or whose subject key no longer matches the current attestation, even though the token itself is unexpired.""" pass class KeyRotatedError(AttestationLapsedError): """Raised when a delegating agent's key has rotated since the token was minted; the embedded attestation names a key that is no longer current.""" pass def verify_delegated_token(token, now, attestation_store): """ token: dict with keys 'exp', 'chain' (list of attestation records, root-first) attestation_store: callable(subject) -> current attestation record or None """ if now >= token["exp"]: raise AttestationLapsedError( f"token expired at {token['exp']}, now={now}" ) for att in token["chain"]: subject = att["subject"] deadline = att["attested_at"] + att["ttl"] # The invariant most verifiers skip: the attestation clock, not just the token clock. if now >= deadline: raise AttestationLapsedError( f"attestation for {subject} lapsed at {deadline}, now={now}; " f"token exp={token['exp']} is irrelevant — the root authority is dead" ) current = attestation_store(subject) if current is None: raise AttestationLapsedError( f"no current attestation for {subject}; cannot confirm liveness" ) if current["key"] != att["key"]: raise KeyRotatedError( f"{subject} key rotated: token embeds {att['key']!r}, " f"current is {current['key']!r}; delegated authority is stale, re-mint required" ) return True ```