# Why does an instance reject a delegated credential it can cryptographically verify? The audience-narrowing invariant in AAIF delegated credential exchange **Date of Record:** 2026 November 19 **Scope:** Applies to multi-hop agent authorization where an orchestrator (instance A) mints a delegated capability token for a sub-agent (instance B) that then acts on a downstream resource (MCP server, A2A peer, or tool endpoint). Does not apply to single-hop direct bearer tokens issued by a resource's own IdP, nor to human-in-the-loop OAuth flows where the audience is a fixed registered client. ## Core Distinction The naive mental model of delegated credential exchange treats verification as a single predicate: *does the signature chain validate and does the scope cover the requested action?* Under that model, a token that verifies and whose scope is a superset of the requested operation is usable. The actual AAIF invariant is stricter and is the source of most "mysterious 401/403 on a valid token" incidents: **a delegated credential is only usable by the principal named in its audience claim, and each delegation hop must narrow—never preserve or widen—the audience and the scope set.** A token can be perfectly signed, in-window, unrevoked, and scope-sufficient, and still be *correctly rejected* because the receiving instance is not in its audience, or because the parent hop failed to narrow scope and the child therefore carries an over-broad grant that downstream policy refuses to honor. The distinction that matters operationally: signature validity is a property of the *credential*; audience-and-narrowing validity is a property of the *delegation chain*. Instances routinely conflate them, log "signature OK, scope OK, rejecting anyway" as a bug, and then "fix" it by widening the audience — which is exactly the failure the invariant exists to prevent. ## What Was Observed A three-instance pipeline: planner agent **P** holds a root grant `scope={read:docs, write:docs, admin:docs}` for resource server **R** (an MCP document server). P delegates to retrieval agent **Q** a token intended to allow only `read:docs`. Q then delegates to a summarizer agent **S** a token it believes is a sub-delegation of its own. Failure trace: 1. P mints token `T1` with `aud=Q`, `scope={read:docs}`, `delegation_chain=[P]`, `narrowing_proof=hash(T0, T1)`. 2. Q receives `T1`, verifies signature against P's key, checks `aud==Q` — passes. Q now mints `T2` for S. **Q's implementation copies `T1`'s scope verbatim** rather than intersecting with what Q itself was granted, and sets `aud=S` but *appends* rather than narrows: `scope={read:docs}` is preserved (correct here) but `delegation_chain=[P, Q]` is emitted with the *parent's* narrowing proof hash, not a fresh hash over `(T1, T2)`. 3. S calls R with `T2`. R validates the chain: signature on each hop OK, `aud==S` OK, scope `read:docs` within R's policy OK. But R's chain validator recomputes `narrowing_proof` at each hop and requires `proof[i] == H(token[i-1], token[i])`. Q's proof is `H(T0,T1)`, not `H(T1,T2)`. **R rejects with `DELEGATION_PROOF_MISMATCH`** despite a fully valid signature and sufficient scope. 4. In a second variant, a different orchestrator **P'** delegated `T1'` with `aud=R` (the resource) instead of `aud=Q`. Q verified signature and scope, accepted it, and re-delegated. R rejected with `AUDIENCE_NOT_ME`, because `T1'`'s audience was R but the *presenter* at hop 2 was Q — the audience had not been narrowed to the intermediate actor. Both rejections were logged by the agents as "valid token rejected," and in the second case an engineer's first instinct was to broaden R's audience check to accept any signed token in the chain. That change would have converted a correct rejection into a confused-deputy vulnerability: any intermediate holder of a resource-audience token could replay it directly against R, bypassing the intermediate hop's scope. ## Condition of Validity The narrowing invariant holds — and rejection is *correct* — only when all of the following are simultaneously true: - **Audience equals presenter at every hop.** `token[i].aud` must equal the identity of the instance that presents `token[i]` to the next party. An intermediate holder may not present a token whose audience is a downstream resource; it must first re-delegate with `aud` set to itself-then-target. - **Scope is monotonically non-increasing.** `scope(token[i]) ⊆ scope(token[i-1])`. Preservation is allowed; widening is not. A child scope that is not a subset indicates the parent either failed to intersect or forged a grant beyond its own authority. - **Narrowing proof is recomputed, not copied.** Each hop's proof binds the specific `(parent, child)` pair. Copying the parent's proof (as Q did) breaks chain integrity even when the *content* of the child is legitimate. - **Chain length and time bounds are checked per hop**, not just at the leaf. A token valid at hop 0 may be expired by hop 2; the leaf's `exp` does not retroactively validate intermediate hops. When any of these is false, the credential must be rejected *regardless of signature and scope sufficiency*. The invariant is a statement about the chain, not the leaf. ## Decision Boundary The operational decision an instance must make on receiving a delegated credential: - If `aud != self` → reject `AUDIENCE_NOT_ME`. Do not "look through" to a downstream audience, even if you intend to forward. - If `scope ⊄ parent_scope` → reject `SCOPE_WIDENED_AT_HOP`. Do not attempt to repair by clipping; a widened child signals a compromised or buggy parent and the safe action is refusal, not silent truncation. - If `proof != H(parent, self)` → reject `DELEGATION_PROOF_MISMATCH`. This is the case Q triggered. - Only when all three hold may the instance (a) act on the token directly, or (b) re-delegate — and re-delegation *must* mint a fresh token with `aud=next`, `scope = scope ∩ requested`, and a freshly computed proof. The boundary is sharp: there is no "accept with warning" band. A token failing any chain predicate is not a degraded credential; it is an invalid one. The only legitimate response to a valid-but-wrong-audience token is re-delegation by the party that *is* the audience, not acceptance by the party that isn't. ## Operational Effect Two concrete consequences follow, and both were observed: 1. **Silent acceptance of a mis-audienced token turns every intermediate agent into a confused deputy.** If Q had accepted `T1'` (aud=R) and forwarded it, R would have honored a `read:docs` grant to a presenter (Q, then S) that was never the intended audience, collapsing the per-hop scope narrowing into a single root grant. The narrowing invariant is the only thing preventing an orchestrator from laundering its own authority through a chain of sub-agents. 2. **Proof-copying produces intermittent, hard-to-reproduce failures** because it only manifests when the leaf's scope happens to be valid — Q's `T2` was scope-correct, so the *only* signal was the proof mismatch. Teams that don't validate proofs see these as flaky 401s and "fix" them by disabling proof checks, which removes the tamper-evidence for the entire chain. The guardrail: validate the chain, not the leaf. Recompute proofs, intersect scopes, and assert audience-equals-presenter at every hop before any action. ```python import hashlib from dataclasses import dataclass, field class DelegationChainError(RuntimeError): """Raised when a delegated credential violates the AAIF chain invariant.""" pass @dataclass class DelegatedToken: audience: str scope: frozenset chain: list narrowing_proof: str def _proof(parent: DelegatedToken, child: DelegatedToken) -> str: material = f"{parent.audience}|{child.audience}|{sorted(child.scope)}|{parent.narrowing_proof}" return hashlib.sha256(material.encode()).hexdigest() def validate_delegation(presenter: str, token: DelegatedToken, parent: DelegatedToken) -> None: # Invariant 1: audience must equal the presenting instance. if token.audience != presenter: raise DelegationChainError( f"AUDIENCE_NOT_ME: token aud={token.audience!r} presented by {presenter!r}" ) # Invariant 2: scope must be monotonically non-increasing. if not token.scope.issubset(parent.scope): raise DelegationChainError( f"SCOPE_WIDENED_AT_HOP: child scope {sorted(token.scope)} " f"not subset of parent {sorted(parent.scope)}" ) # Invariant 3: narrowing proof must bind this specific (parent, child) pair. expected = _proof(parent, token) if token.narrowing_proof != expected: raise DelegationChainError( f"DELEGATION_PROOF_MISMATCH: expected {expected[:12]}… got {token.narrowing_proof[:12]}…" ) def re_delegate(parent: DelegatedToken, actor: str, next_audience: str, requested: frozenset) -> DelegatedToken: # Only the audience of the parent may re-delegate, and only by narrowing. if parent.audience != actor: raise DelegationChainError( f"NOT_AUDIENCE: {actor!r} cannot re-delegate token aud={parent.audience!r}" ) narrowed = requested & parent.scope if not narrowed: raise DelegationChainError("EMPTY_SCOPE: delegation would grant nothing") child = DelegatedToken( audience=next_audience, scope=frozenset(narrowed), chain=parent.chain + [actor], narrowing_proof="", ) child.narrowing_proof = _proof(parent, child) return child ```