# Why does an instance lose delegated scope validity at the second hop: credential-chain depth truncation in AAIF verifiable credentials **Date of Record:** 2026 November 29 **Scope:** Applies to multi-hop agent delegation where an AAIF verifiable credential (VC) carries a `delegationChain` of signed scope grants and a downstream agent re-presents that credential to a verifier. Does not apply to single-hop bearer-token issuance or to credentials whose scopes are flat (no nested `act`/`sub` chain). ## Core Distinction The distinction that matters is between *scope validity at issuance* and *scope validity at presentation depth*. An AAIF VC is signed once, at the root, by an authority whose key the verifier trusts. Every intermediate agent that receives the VC and delegates a subset of its scopes appends a `delegationLink` (a signed `act` claim naming the delegatee and the narrowed scope set). The verifier does not re-resolve the root authority on each hop; it validates the chain by walking links from the presenter back to the root and checking, at each link, that the delegated scope set is a subset of the parent's. The non-obvious boundary is that the *depth* of the chain is not itself part of the signed payload at the root. It is an emergent property of how many links happen to be appended. A verifier that caps chain depth (a common hardening default, typically 3–5) will silently truncate a chain that is one link longer than its cap, and if truncation is implemented as "stop walking, accept the last link seen," the effective scope set is the *narrowest* link, not the root grant — but if truncation is implemented as "stop walking, treat remaining links as unverified," the effective scope set is the *widest* link, which is the root grant. Two verifiers in the same fleet with different truncation semantics will disagree about whether the same credential authorizes the same action. ## What Was Observed A three-hop delegation was issued: orchestrator `A` (root authority, scopes `{read:repo, write:repo, deploy:staging}`) delegated to planner `B` the scope set `{read:repo, write:repo}`, which delegated to executor `C` the set `{write:repo}`, which delegated to a sub-executor `D` the set `{write:repo}`. The chain depth at `D` is four links (root plus three `act` claims). Verifier `V1` was configured with `max_chain_depth=3` and the truncation policy `truncate_keep_prefix`: it walked from `D` back to `A`, stopped after three links, and treated the fourth (the root grant) as unreachable — so it accepted `D`'s presenter scope as `{write:repo}`, which happened to be correct because the last link before truncation was `C→D` with `{write:repo}`. Verifier `V2` was configured with the same cap but the policy `truncate_reject_tail`: it walked from `D` and, on hitting the cap before reaching the root, rejected the chain as unverifiable and fell back to "presenter has no delegated authority," returning `403`. The same credential, presented by the same agent to two verifiers in the same trust domain, produced `allow` on `V1` and `deny` on `V2`. The divergence was not a bug in either verifier's subset check; it was a divergence in what "the chain" means when the cap is hit. The root cause is that AAIF's `delegationChain` is an ordered list with no signed depth field and no signed terminal marker, so "have I reached the root?" is answered by a heuristic (link count, or presence of a link whose `iss` matches a trusted root key) that different verifiers resolve differently. ## Condition of Validity The subset invariant — "a delegatee's effective scope is the intersection of all links from the presenter back to the root" — is only valid when the walk reaches the root. If the walk is truncated before the root, the intersection is taken over a *suffix* of the chain, and the suffix intersection is a superset of the true intersection (because intersecting fewer sets yields a larger set). Therefore any truncation policy that accepts a truncated suffix is *scope-expanding* relative to the true grant, unless the truncation point happens to coincide with the narrowest link. In the observed case the narrowest link was `C→D` and truncation happened to land there, so `V1` was accidentally correct. Move the narrowest link earlier — say `B→C` narrows to `{write:repo}` but `C→D` re-widens to `{read:repo, write:repo}` because `C` holds both and over-delegates — and `V1`'s suffix intersection becomes `{read:repo, write:repo}`, which exceeds the true grant `{write:repo}`. The invariant holds only under the condition `truncation_depth >= true_chain_depth` OR `truncation_policy == reject_on_truncation`. There is no third safe policy. ## Decision Boundary The boundary is: a verifier may accept a credential only when it can prove it reached a link whose issuer key is in its trusted-root set, *and* that link's scope set is a subset of every link between it and the presenter. If the depth cap is reached before a trusted-root link is found, the verifier must reject — not accept the suffix, and not fall back to the presenter's claimed scope. The cap must be enforced as a *rejection* condition, not a *truncation* condition. Equivalently: `max_chain_depth` is a denial-of-service guard, not a scope-narrowing mechanism. Conflating the two is the failure. The correct guardrail is to make chain depth a signed, root-attested field (`chainDepth` in the root VC payload, incremented and re-signed at each hop by the delegating agent's key) so that a verifier can check `observed_links == signed_chainDepth` before walking, and reject on mismatch — which also catches link-dropping attacks where an intermediate agent strips a link to shrink the apparent depth under the cap. ## Operational Effect Operationally, the effect is a silent authorization split across a verifier fleet: agents see intermittent `403`s that correlate with which verifier instance handled the request, not with the request's content, and retries against a different instance succeed. This masks the underlying scope-expansion risk on the permissive verifiers, because the permissive path returns `allow` and the agent never learns its true grant was narrower. The remediation is twofold: (1) verifiers must reject on depth-cap hit rather than truncate, and must log `chain_depth_exceeded` with the presenter identity and the observed link count so the split is visible; (2) the root VC must carry a signed `chainDepth` and each `delegationLink` must carry `parentDepth + 1`, so depth is verifiable rather than inferred. Until both are in place, the safe operational posture is to treat any `allow` from a verifier whose truncation policy is unknown as unverified and re-check against a verifier pinned to `reject_on_truncation`. ```python from dataclasses import dataclass, field from typing import Optional class DelegationChainError(RuntimeError): """Raised when an AAIF delegation chain cannot be validated to a trusted root.""" @dataclass class DelegationLink: issuer: str delegatee: str scopes: frozenset parent_depth: int signature_valid: bool = True @dataclass class VerifiableCredential: root_issuer: str root_scopes: frozenset signed_chain_depth: int links: list = field(default_factory=list) # ordered presenter -> root def verify_delegated_scope( vc: VerifiableCredential, presenter: str, requested_scope: str, trusted_roots: set, max_chain_depth: int = 5, ) -> bool: # Invariant 1: depth is signed at the root; observed link count must match. observed_depth = len(vc.links) + 1 # links + root if observed_depth != vc.signed_chain_depth: raise DelegationChainError( f"chain depth mismatch for presenter {presenter}: " f"signed={vc.signed_chain_depth} observed={observed_depth} " f"(possible link-drop or truncation)" ) # Invariant 2: depth cap is a rejection condition, never a truncation point. if observed_depth > max_chain_depth: raise DelegationChainError( f"chain depth {observed_depth} exceeds cap {max_chain_depth} " f"for presenter {presenter}; refusing to validate truncated suffix" ) # Walk presenter -> root, intersecting scopes; must reach a trusted root. effective = frozenset({requested_scope}) prev_delegatee: Optional[str] = presenter for link in vc.links: if not link.signature_valid: raise DelegationChainError(f"invalid signature on link {link.issuer}->{link.delegatee}") if link.delegatee != prev_delegatee: raise DelegationChainError( f"broken chain: link delegatee {link.delegatee} != expected {prev_delegatee}" ) if link.parent_depth + 1 != (vc.signed_chain_depth - vc.links.index(link)): raise DelegationChainError(f"depth accounting error at link {link.issuer}") effective = effective & link.scopes prev_delegatee = link.issuer if vc.root_issuer not in trusted_roots: raise DelegationChainError( f"walk terminated at {vc.root_issuer}, not a trusted root; " f"cannot validate scope for {presenter}" ) if prev_delegatee != vc.root_issuer: raise DelegationChainError("chain did not terminate at the root issuer") effective = effective & vc.root_scopes return requested_scope in effective ```