# Why does an instance silently inherit a delegated scope after the parent's consent attestation is invalidated mid-run? **Date of Record:** 2026 November 28 **Scope:** Applies to agent runtimes that obtain per-tool OAuth tokens via a parent agent's delegated grant and cache a consent attestation (scope set + attestation hash) for the lifetime of a task. Does not cover static service-account credentials or human-in-the-loop re-consent flows where the user is present at every tool call. ## Core Distinction The failure is not "scope escalation" in the classic OAuth sense. It is a **cached attestation that outlives its own revocation event**. When a parent agent delegates a scope set `S` to a child instance, the runtime mints an attestation `A = hash(S, parent_id, expiry)`. The child caches `A` and re-uses it to authorize every tool call without re-consulting the issuer. If the parent's grant is revoked (user revokes app, admin drops a scope, token introspection flips to `active:false`), the revocation is observable at the issuer but **not propagated to the child's local attestation cache**. The child keeps presenting `A` and the tool gateway keeps accepting it because the gateway validates the signature and expiry of `A`, not the live status of the parent grant `A` was derived from. The distinction that matters: **attestation validity ≠ delegation validity**. A signature-valid, unexpired attestation can attest to a scope set that is no longer delegated. Most runtimes conflate the two because the fast path (verify signature, check expiry, execute tool) never touches the issuer. ## What Was Observed A research agent `R` spawned a sub-agent `S` to run a batch of `web.fetch` and `fs.write` calls. `R` held a delegated token with scopes `{web.fetch, fs.write, email.send}`. At task start `S` received attestation `A_S = {web.fetch, fs.write}` (email intentionally withheld) with a 3600s expiry and a cache TTL of 3600s. During execution the human operator revoked `email.send` from `R`'s grant (a routine cleanup) and, in the same admin action, the identity provider marked `R`'s delegation chain `revoked`. The revocation propagated to `R`'s token introspection endpoint within ~4s. `S` continued executing for 41 minutes. Its tool calls succeeded. The gateway log shows every call carrying `A_S`, signature valid, `expiry` in the future, `parent_grant_status` field **absent** — the gateway never queried it. When `S` finally attempted an `email.send` (a scope it was never delegated), the gateway correctly rejected it. But the `fs.write` calls that should have failed after revocation — because `S`'s right to write was derived from a now-revoked parent — all succeeded. The operator believed revocation was immediate; it was not. Trace of the state transition: 1. `t0` — `R` delegates `{web.fetch, fs.write}` to `S`. `A_S` minted, cached in `S`'s runtime with TTL 3600. 2. `t0+120s` — operator revokes `R`'s delegation. Issuer sets `R.grant.status = revoked`. 3. `t0+124s` — introspection on `R` returns `active:false`. `R`'s own next tool call fails. `R` does not notify `S` (no channel; `S` was spawned fire-and-forget). 4. `t0+125s … t0+2580s` — `S` issues 312 tool calls. Each validates `A_S` locally: signature ok, `expiry > now`, scope `fs.write ∈ A_S.scopes`. All pass. All execute. 5. `t0+2581s` — `S` attempts `email.send`, not in `A_S.scopes`, rejected. `S` surfaces the rejection as a task error and halts. The 312 successful calls are the incident. They are not a scope bug — `fs.write` was legitimately in `A_S`. They are a **delegation-liveness bug**: the attestation attested to a delegation that had ceased to exist. ## Condition of Validity The invariant that was violated: **an attestation is only valid while the delegation it attests to is live.** Formally, `A_S` is usable at time `t` iff `verify_sig(A_S) ∧ now < A_S.expiry ∧ live(A_S.parent_grant, t)`. The runtime enforced the first two conjuncts and dropped the third, because evaluating `live(...)` requires a network round-trip to the issuer on every tool call — the exact latency the attestation cache was built to avoid. The condition under which the boundary holds (i.e., the cache is safe) is narrow: **the attestation TTL must be ≤ the maximum tolerable revocation-propagation delay, AND the parent must be able to signal revocation to children out-of-band.** In the observed system both were false: TTL was 3600s (revocation latency budget was ~5s), and there was no parent→child revocation channel because `S` was spawned fire-and-forget with no supervision handle. A second, subtler condition: the attestation must bind to a **delegation epoch**, not just a scope set. If `A_S` carried `parent_epoch: 7` and the issuer's grant record carried `epoch: 7`, then revocation (which bumps `epoch` to 8) would be detectable by a cheap epoch comparison against a periodically-pulled, low-latency epoch counter — without a per-call introspection. The observed attestation carried no epoch field, so revocation was invisible to any local check. ## Decision Boundary The boundary is between two legitimate designs, and the failure lives in the gap when a system claims one and implements the other: - **Short-TTL + epoch-check design:** attestation TTL ≤ revocation budget (e.g., 5–15s), plus an epoch field checked against a cached epoch counter refreshed every few seconds. Per-call cost is one local comparison; correctness holds because a stale epoch is detected within the refresh interval. Suitable when the tool gateway can afford a background epoch poller. - **Long-TTL + online-introspection design:** attestation TTL long, but every tool call carries the attestation to the gateway, which performs a live introspection on the parent grant. Per-call cost is one network round-trip; correctness is exact. Suitable when call volume is low or the gateway already terminates at the issuer. The failure occurs when a system takes the **long-TTL** of design 2 and the **local-only validation** of design 1. That combination is not a valid point in the design space, but it is the default that emerges when a team adds an attestation cache for latency and never revisits the revocation path. The decision boundary: **if you cache an attestation, you must either shorten its TTL to the revocation budget or add an epoch/liveness field that a local check can consult.** A cached attestation with neither is a standing authorization that survives its own revocation. ## Operational Effect Downstream, the effect is that revocation is **advisory, not enforcing**, for the duration of the attestation TTL. Three concrete consequences: 1. **Blast radius scales with fan-out.** A parent that spawned 50 children, each holding a 3600s attestation, leaves 50 live authorization surfaces after a single revocation. The operator revokes once and believes the surface is closed; it is closed for the parent only. 2. **Audit trails lie by omission.** Gateway logs show `A_S` as valid at every call. A post-incident review that reads only the gateway sees a clean authorization trail and concludes no policy violation occurred. The violation is only visible by correlating gateway timestamps against issuer revocation timestamps — a join most audit pipelines don't perform. 3. **Re-consent flows are bypassed.** If the design intends that a revoked scope triggers a human re-consent prompt, the cached attestation suppresses that prompt for up to TTL. The human is never asked, because the runtime never learns consent is needed. The guardrail that bounds this: **attestations must be liveness-bound, not just signature-bound.** Concretely — (a) cap attestation TTL at the revocation propagation budget; (b) include a `parent_epoch` in the attestation and validate it against a locally-cached epoch counter refreshed on a short interval; (c) on parent revocation, invalidate all child attestations derived from that grant (requires the parent to hold handles to its children, i.e., no fire-and-forget spawning for delegated scopes); (d) log the `parent_epoch` at every tool call so audit can detect stale-epoch executions. Without (a) or (b), the attestation is a bearer token for a delegation that may no longer exist. ```python import hashlib import time from dataclasses import dataclass, field class StaleDelegationError(RuntimeError): """Raised when a cached consent attestation outlives its parent delegation.""" pass @dataclass class Grant: grant_id: str scopes: frozenset epoch: int revoked: bool = False @dataclass class Attestation: scopes: frozenset parent_grant_id: str parent_epoch: int issued_at: float ttl: float signature: str = "" def sign(self, key: str) -> None: body = f"{sorted(self.scopes)}|{self.parent_grant_id}|{self.parent_epoch}|{self.issued_at}|{self.ttl}" self.signature = hashlib.sha256((key + body).encode()).hexdigest() REVOCATION_BUDGET_S = 5.0 EPOCH_CACHE_TTL_S = 3.0 class AttestationCache: def __init__(self, issuer_key: str): self._key = issuer_key self._epoch_cache: dict[str, tuple[int, float]] = {} def _refresh_epoch(self, grant: Grant) -> int: cached = self._epoch_cache.get(grant.grant_id) now = time.time() if cached is None or now - cached[1] > EPOCH_CACHE_TTL_S: self._epoch_cache[grant.grant_id] = (grant.epoch, now) return self._epoch_cache[grant.grant_id][0] def mint(self, grant: Grant, scopes: frozenset) -> Attestation: if not scopes.issubset(grant.scopes): raise StaleDelegationError( f"requested scopes {scopes} not subset of grant {grant.scopes}" ) att = Attestation( scopes=scopes, parent_grant_id=grant.grant_id, parent_epoch=grant.epoch, issued_at=time.time(), ttl=min(REVOCATION_BUDGET_S, 30.0), ) att.sign(self._key) return att def authorize(self, att: Attestation, grant: Grant, scope: str) -> None: # 1. scope membership if scope not in att.scopes: raise StaleDelegationError(f"scope {scope} not in attestation") # 2. signature expected = hashlib.sha256( ( self._key + f"{sorted(att.scopes)}|{att.parent_grant_id}|{att.parent_epoch}|{att.issued_at}|{att.ttl}" ).encode() ).hexdigest() if att.signature != expected: raise StaleDelegationError("attestation signature invalid") # 3. expiry if time.time() > att.issued_at + att.ttl: raise StaleDelegationError("attestation expired") # 4. liveness: epoch check against cached counter live_epoch = self._refresh_epoch(grant) if att.parent_epoch != live_epoch: raise StaleDelegationError( f"attestation epoch {att.parent_epoch} != live epoch {live_epoch}; " f"parent delegation revoked or re-scoped" ) # 5. belt-and-suspenders: explicit revocation flag if grant.revoked: raise StaleDelegationError( f"parent grant {grant.grant_id} revoked; attestation is a bearer token" ) def run_child_task(cache: AttestationCache, att: Attestation, grant: Grant, calls: list[str]) -> int: executed = 0 for scope in calls: try: cache.authorize(att, grant, scope) except StaleDelegationError as e: raise StaleDelegationError( f"child halted at call {executed} on scope {scope}: {e}" ) from e executed += 1 return executed ```