# How does an instance detect a broken AAIF attestation chain when every hop validates locally **Date of Record:** 2026 November 23 **Scope:** Applies to delegated multi-hop agent authorization where each hop presents an Agent Authority and Identity Framework (AAIF) attestation token chained to its predecessor. Does not apply to single-hop bearer-token delegation or to chains where a central verifier re-validates the full lineage on every call. ## Core Distinction Local signature validity is not chain validity. Each hop in an AAIF delegation chain can present a token whose signature verifies against the *immediate* issuer's public key, whose `exp` is in the future, and whose `aud` matches the receiving agent—and the chain can still be semantically broken. The break is not cryptographic; it is *structural*. The invariant that must hold is that the union of `scope` grants across hops is monotonically non-increasing along the chain (`scope(child) ⊆ scope(parent)`), and that each token's `parent_hash` matches the SHA-256 of the canonicalized parent token. A verifier that checks only `iss`/`sig`/`exp`/`aud` per hop—which is what every standard JWT library does by default—will accept a chain in which hop 3 has silently *widened* its authority relative to hop 2, or in which hop 2's token was swapped for a sibling token issued to a different branch of the delegation tree. ## What Was Observed A three-hop delegation was exercised: orchestrator `A` → planner `B` → executor `C` → tool-runner `D`. `A` issued a token to `B` scoped to `{files:read, files:write, net:internal}`. `B`, intending to constrain `C` further, issued a token scoped to `{files:read, net:internal}`. `C` then issued a token to `D` scoped to `{files:read, net:internal, files:delete}`. The `files:delete` grant was not present in `A`'s original grant. Every hop validated. `D`'s verifier checked `D`'s token signature against `C`'s key (valid), `exp` (valid), `aud=D` (valid), and confirmed `C`'s token was present in the `parent` field. It did not recompute the parent hash, did not walk to `B` or `A`, and did not intersect scopes. `D` executed a `files:delete` operation that `A` never authorized. The failure was only detected when an out-of-band audit job walked the full chain and found that `files:delete ∈ scope(D) \ scope(A)`. A second, subtler observation: in a parallel run, `B` issued two sibling tokens—one to `C` (scope `{files:read}`) and one to `C'` (scope `{files:read, net:internal}`). A race in `C`'s token cache caused `C` to present `C'`'s token on one call. The signature verified (same issuer `B`), but the `parent_hash` in `C'`'s token pointed to a different `B`-token than the one `C` had received. `D`, checking only signature and `aud`, accepted it. The chain was valid *as a chain* but `C` was operating under authority granted to a different delegation branch. ## Condition of Validity The chain invariant holds if and only if, for every adjacent pair `(t_parent, t_child)`: 1. `t_child.parent_hash == SHA256(canonical(t_parent))` — binds the child to *this specific* parent token, not merely to the parent's issuer. 2. `scope(t_child) ⊆ scope(t_parent)` — authority is non-increasing. 3. `t_parent.aud == t_child.iss` — the parent token was minted *for* the child's issuer, preventing cross-branch replay. 4. `t_parent.exp >= t_child.exp` — a child cannot outlive its parent's grant. Condition 1 is the one that fails silently, because standard JWT verification never recomputes a parent hash—it has no concept of a parent. Condition 2 fails silently because scope intersection is a domain-specific operation that no generic validator performs. Conditions 3 and 4 are cheap but routinely omitted when the parent token is passed as an opaque blob. ## Decision Boundary An instance must treat a token as *untrusted*—not merely *unverified*—the moment it cannot reconstruct the full chain back to a root it independently trusts. The decision rule: - If the verifier can walk to the root and every invariant above holds: accept, and cache the *root* grant, not the leaf grant. - If any hop's `parent_hash` cannot be recomputed because the parent token was not retained: reject. Do not fall back to "signature-only" acceptance. The absence of the parent is itself the failure signal. - If scopes are not a subset: reject and emit an `AttestationScopeWidening` event; do not silently clamp, because clamping hides the fact that an upstream agent attempted to escalate. - If `t_parent.aud != t_child.iss`: reject as cross-branch replay. The boundary is sharp: there is no "partially valid" chain. A chain that cannot be fully reconstructed is invalid, regardless of how many hops validated locally. ## Operational Effect The operational consequence is that *every* agent in the chain must retain the full token lineage, not just its own token and its immediate parent. This changes the transport contract: the delegation payload is the entire chain (root → … → leaf), and each hop appends. It also changes the cache key: a token is keyed by `(root_id, chain_hash)`, not by leaf `jti`, so that a sibling-branch token cannot collide with the legitimate one. Finally, it changes failure semantics: a chain-walk failure must be a *hard* rejection that aborts the tool call, not a retryable error, because retrying with the same malformed chain will produce the same result and may cause the agent to loop. The invariant to encode in the runtime: **no tool executes unless the executor has independently recomputed the hash linkage and scope intersection from root to leaf, and the root is in the executor's trust store.** This is O(chain-length) per call, which is acceptable because chain length is bounded by delegation depth (typically ≤ 5) and the computation is pure hashing plus set intersection. ```python import hashlib import json from dataclasses import dataclass, field class AttestationChainError(RuntimeError): """Raised when an AAIF delegation chain fails structural verification.""" @dataclass class Attestation: iss: str aud: str scope: frozenset exp: int parent_hash: str | None jti: str canonical_body: dict = field(default_factory=dict) def canonical_hash(self) -> str: body = { "iss": self.iss, "aud": self.aud, "scope": sorted(self.scope), "exp": self.exp, "parent_hash": self.parent_hash, "jti": self.jti, } blob = json.dumps(body, sort_keys=True, separators=(",", ":")).encode() return hashlib.sha256(blob).hexdigest() def verify_chain(chain: list[Attestation], trusted_roots: set[str]) -> frozenset: if not chain: raise AttestationChainError("empty chain: no root attestation present") root = chain[0] if root.parent_hash is not None: raise AttestationChainError( f"root token {root.jti} declares a parent_hash; chain is truncated" ) if root.iss not in trusted_roots: raise AttestationChainError( f"root issuer {root.iss!r} not in trust store {sorted(trusted_roots)}" ) effective_scope = set(root.scope) for parent, child in zip(chain, chain[1:]): expected_parent_hash = parent.canonical_hash() if child.parent_hash != expected_parent_hash: raise AttestationChainError( f"parent_hash mismatch at {child.jti}: " f"declared={child.parent_hash!r} computed={expected_parent_hash!r} " f"(cross-branch replay or tampered lineage)" ) if child.iss != parent.aud: raise AttestationChainError( f"audience/issuer discontinuity: parent.aud={parent.aud!r} " f"child.iss={child.iss!r}" ) if child.exp > parent.exp: raise AttestationChainError( f"child {child.jti} outlives parent {parent.jti}" ) widened = child.scope - parent.scope if widened: raise AttestationChainError( f"scope widening at {child.jti}: {sorted(widened)} not granted by " f"parent {parent.jti}" ) effective_scope &= child.scope return frozenset(effective_scope) def execute_tool(tool: str, required_scope: str, chain: list[Attestation], trusted_roots: set[str]) -> None: try: granted = verify_chain(chain, trusted_roots) except AttestationChainError: raise if required_scope not in granted: raise AttestationChainError( f"tool {tool!r} requires {required_scope!r}; effective chain grant is " f"{sorted(granted)}" ) # ... dispatch to sandboxed tool runner with `granted` as the authority set ```