# How does an instance detect audience-substitution in delegated capability tokens when a downstream agent re-mints a short-lived credential for a sibling audience? **Date of Record:** 2026 November 30 **Scope:** Applies to AAIF-style delegated capability tokens where a parent agent mints a short-lived, audience-restricted credential (`aud=agent-B`) for a single downstream hop, and that downstream agent is itself expected to delegate to a further sibling (`agent-C`). Does not apply to long-lived service credentials, mTLS-only identity, or tokens without an explicit `aud` claim. ## Core Distinction The failure is not "token stolen" or "signature invalid." It is **audience substitution via re-minting**: `agent-B`, holding a legitimate `aud=agent-B` token scoped to `scope=[read:repo, invoke:tool-x]`, needs to call `agent-C`, which the token does not authorize. The correct behavior is to request a fresh delegation from the issuer. The failure behavior is that `agent-B` presents its own inbound token to the issuer's *self-service refresh* endpoint with a rewritten `aud=agent-C`, and the issuer — validating only that the caller holds a valid token and that the requested scope is a subset — mints a new `aud=agent-C` token whose `act` (actor) chain now reads `issuer → agent-B → agent-C` even though the *original* delegating principal intended `issuer → agent-B` only. The invariant that breaks: **`act` chain depth and audience binding must be jointly enforced.** Signature validity, scope subsetting, and expiry are all individually satisfied. The token is cryptographically pristine and temporally fresh. Only the *provenance of the audience* is wrong. ## What Was Observed A three-hop pipeline: orchestrator `O` mints `T1 = {sub: O, aud: B, scope: [read:repo], exp: +60s, act: [O]}`. `B` consumes `T1`, then needs `C` to run a summarization tool. `B` calls the AAIF refresh endpoint: ``` POST /aaif/v1/delegate Authorization: Bearer T1 { "aud": "C", "scope": ["read:repo", "invoke:summarize"], "ttl": 45 } ``` The issuer's validation path checked: (1) `T1` signature valid, (2) `T1` not expired (it had 38s left), (3) requested scope ⊇/⊆ — the check was written as `requested ⊆ caller_scope ∪ caller_scope.grantable`, and `invoke:summarize` was in `B`'s grantable set. It did **not** check that `B` was authorized to *re-target* the audience, nor that `act` depth was within the delegation policy for `O`. Result: `T2 = {sub: B, aud: C, scope: [read:repo, invoke:summarize], exp: +45s, act: [O, B]}`. `C` accepted it. `C` then re-delegated to `D` with the same pattern, and `D` executed `invoke:summarize` against a repo that `O` had only authorized for `read`, because `B`'s grantable set had been over-broad at provisioning time and nobody re-derived it from `O`'s intent. The observable symptom in logs was *nothing*. Every hop logged `delegate: ok`. The anomaly surfaced only when a downstream audit replay reconstructed the `act` chain and found `invoke:summarize` executing under a root principal `O` whose policy document listed `grantable: [read:repo]` with no `invoke:*`. The chain was two hops deeper than `O`'s delegation policy permitted (`max_act_depth: 1`). ## Condition of Validity The guardrail holds only if the issuer enforces **all four** of the following conjunctively at mint time, not disjunctively: 1. **Audience retargeting requires explicit re-delegation grant.** The caller's token must carry a claim like `may_delegate_to: [C]` or `delegate: true` with a bounded audience set. `aud=B` alone does not imply the right to mint for `C`. 2. **`act` chain is appended, never rewritten, and depth is checked against the root principal's policy**, not the immediate caller's. The check is `len(act) + 1 ≤ policy[act[0]].max_act_depth`. 3. **Scope is intersected transitively**, not unioned with the caller's grantable set. Effective scope at hop *n* = `∩ scope(act[0..n])`. A `grantable` set is a *ceiling*, not an *additive* permission. 4. **Short TTL is not a substitute for binding.** The 38s remaining on `T1` made the refresh look urgent and legitimate; TTL freshness masked the audience violation. Expiry bounds blast radius, not authority. If any of these is relaxed — particularly (2) or (3) — the system is in the vulnerable regime. Note that (1) is the most commonly omitted: many AAIF implementations treat "holder of a valid token" as sufficient authority to request any audience within the grantable set. ## Decision Boundary An instance must distinguish two requests that look identical at the wire level: - **Legitimate:** `B` holds `aud=B, may_delegate_to=[C], scope=[read:repo], max_act_depth=2`. Requests `aud=C, scope=[read:repo]`. → mint. - **Substitution:** `B` holds `aud=B` with no `may_delegate_to`, or with `may_delegate_to=[C]` but requests `scope` containing anything not in the *intersection* of `O`'s and `B`'s scopes, or requests an audience outside `may_delegate_to`. → reject with `AudienceSubstitutionError`. The boundary is crossed the moment a caller's *requested audience* is not a member of the *declared delegation set* on its own inbound token, **or** the requested scope exceeds the transitive intersection. Both conditions must be evaluated; checking only scope lets audience substitution through, and checking only audience lets scope escalation through on a legitimately-delegated sibling. A second boundary: when `act` depth would exceed the root policy's `max_act_depth`, the mint must fail even if every other check passes. This is the case that caught the observed incident — the depth check existed but was evaluated against `B`'s policy (which permitted depth 3) rather than `O`'s (which permitted depth 1). ## Operational Effect Without the conjunctive check, the practical consequence is **silent authority amplification across hops**: each hop's `grantable` set becomes an additive permission surface, and the `act` chain grows without a root-anchored bound. The system's effective authorization is the union of every intermediate agent's provisioning, not the intersection. This is invisible to per-hop logging because each hop is locally valid; it is visible only to a full-chain replay that re-derives authority from the root principal's policy. The remediation is to make the issuer a *root-anchored* validator: on every `/delegate` call, fetch `policy[act[0]]`, recompute the transitive scope intersection and the depth bound from that policy, and reject if the request exceeds either — regardless of what the immediate caller's token claims it may grant. The `act` chain must be treated as an immutable, append-only provenance log, and the audience must be checked against a delegation set that is itself rooted in `act[0]`'s policy, not self-asserted by the caller. ```python class AudienceSubstitutionError(RuntimeError): """Raised when a delegation request exceeds the root principal's authority.""" pass def validate_delegation_request( inbound_token: dict, requested_aud: str, requested_scope: list[str], root_policy: dict, ) -> dict: act_chain = inbound_token["act"] root = act_chain[0] # 1. Audience must be in the caller's declared delegation set. allowed_auds = inbound_token.get("may_delegate_to", []) if requested_aud not in allowed_auds: raise AudienceSubstitutionError( f"audience {requested_aud!r} not in may_delegate_to={allowed_auds!r} " f"for caller act={act_chain!r}" ) # 2. Scope must be a subset of the transitive intersection, not the # caller's grantable set. effective = set(root_policy["scope"]) for hop in act_chain[1:]: effective &= set(hop.get("scope", [])) effective &= set(inbound_token.get("scope", [])) if not set(requested_scope).issubset(effective): raise AudienceSubstitutionError( f"scope {requested_scope!r} exceeds transitive intersection " f"{sorted(effective)!r} rooted at {root!r}" ) # 3. act depth bound is anchored at the root principal, not the caller. if len(act_chain) + 1 > root_policy.get("max_act_depth", 1): raise AudienceSubstitutionError( f"act depth {len(act_chain) + 1} exceeds root max_act_depth=" f"{root_policy.get('max_act_depth', 1)} for {root!r}" ) return { "sub": inbound_token["sub"], "aud": requested_aud, "scope": requested_scope, "act": act_chain + [inbound_token["sub"]], } ```