# Where must an instance pin issuer keys before AAIF cross-issuer trust chain verification becomes a confused-deputy vulnerability **Date of Record:** 2026 November 17 **Scope:** Applies to AAIF (Agent Identity Attestation Framework) verifiers that accept delegation chains spanning more than one issuer (e.g., an orchestrator-issued root attestation delegating to a sub-agent whose own attestation is issued by a different AAIF authority). Does not apply to single-issuer, single-hop attestation verification, nor to chains where the verifier is also the sole issuer of every link. ## Core Distinction The non-obvious boundary is between *trusting an issuer's signature* and *trusting the issuer's key-resolution path*. A verifier that validates every signature in a cross-issuer chain correctly can still be exploited if it resolves each issuer's public key through a mutable, issuer-controlled discovery document at verification time. The signature check passes; the identity binding does not. The failure is not a cryptographic break — it is a time-of-check/time-of-use gap between "which key did the issuer claim" and "which key actually signed the delegation," introduced precisely at the seam where one issuer's chain hands off to another's. In single-issuer verification, the verifier typically holds the issuer key in local configuration, so the resolution path is fixed and the distinction collapses. In cross-issuer verification, the verifier must *discover* the upstream issuer's key, and that discovery step is where the confused-deputy condition is born: the verifier will happily fetch a key from any issuer named in the chain and then treat that key as authoritative for the delegation it is checking. ## What Was Observed In a reproduction against an AAIF verifier configured with two trusted roots (`issuer-a` and `issuer-b`), a delegation chain was constructed as follows: 1. `issuer-a` signs a root attestation for agent `alpha`, with a `delegates_to` claim naming agent `beta` and declaring `issuer-b` as the attestation authority for `beta`. 2. The verifier, resolving `beta`'s attestation, fetches `issuer-b`'s JWKS from the discovery URL embedded in the chain's `iss` field. 3. `issuer-b`'s discovery endpoint returns a key set containing a key whose `kid` collides with the `kid` used by `issuer-a` in the root link. 4. The verifier's key cache is keyed on `kid` alone, not on `(iss, kid)`. The `issuer-b` document overwrites the cached `issuer-a` entry. 5. A forged delegation from `issuer-b` to a third agent `gamma` — signed by a key `issuer-b` controls but which was never authorized to speak for `alpha`'s delegation — now validates, because the verifier resolves `gamma`'s link against the *cached* `issuer-a` key that `issuer-b` poisoned. The signature on every individual link was valid. The chain was rejected only when the verifier was patched to key its cache on the composite `(iss, kid)` tuple and to reject any chain in which a downstream issuer's JWKS contained a `kid` already bound to a different issuer within the same verification session. ## Condition of Validity This boundary is only reachable when all of the following hold simultaneously: - The chain spans two or more distinct issuers, and at least one non-root issuer's key set is resolved dynamically (via discovery document, JWKS URL, or DID document) rather than pinned in verifier configuration. - Key lookup is keyed on a non-unique identifier (`kid`, key thumbprint, or subject) without the issuer identity as part of the lookup key. - The verifier maintains any cross-request or cross-link cache, or performs resolution in an order that allows a later-resolved issuer to influence the interpretation of an earlier link. If any one condition is absent — keys pinned statically, cache keyed on `(iss, kid)`, or resolution strictly ordered root-to-leaf with per-link key isolation — the confused-deputy path does not open. The boundary is therefore *not* a property of AAIF itself but of the verifier's key-resolution discipline. ## Decision Boundary The operational rule: **an instance must pin an issuer's key set to the issuer identity before that issuer's link is used to authorize any downstream link, and must never let a dynamically resolved key set shadow a key already bound within the same chain.** Concretely, the verifier must decide, per link, between two mutually exclusive policies: - **Pinned mode** — the issuer's key set is drawn from verifier-local trust configuration; discovery is disabled. Use when the set of issuers is known and stable. - **Discovered mode** — the issuer's key set is fetched, but the fetch result is bound to the composite `(iss, kid)` and any collision with an already-bound key in the current chain is a hard failure, not a cache miss. The forbidden third state — discovered keys that overwrite or shadow pinned/earlier-bound keys — is the confused-deputy condition. A verifier that cannot state which of the two modes it is in for a given link is not safe to run cross-issuer chains. ## Operational Effect When the boundary is respected, cross-issuer delegation remains auditable: every link's authorizing key is traceable to exactly one issuer identity, and a poisoned discovery document can at worst cause a *rejection* (collision → hard fail), never an *acceptance*. When violated, the failure is silent and asymmetric: legitimate chains verify normally, and the exploit requires only that an attacker control one trusted issuer's discovery endpoint — a far lower bar than compromising a signing key. The blast radius is every agent reachable by delegation from the poisoned link, which in orchestrator topologies can be the entire sub-agent fleet. The practical mitigation is to make the composite key the only legal cache key and to treat `kid` collisions across issuers within a single chain as a verification error rather than a resolution event. The code below encodes that invariant. ```python import hashlib from dataclasses import dataclass, field class CrossIssuerKeyCollision(RuntimeError): """Raised when a discovered issuer key shadows a key already bound in the chain.""" pass @dataclass class AttestationLink: iss: str kid: str subject: str delegates_to: str | None signature: bytes @dataclass class Verifier: pinned_keys: dict[tuple[str, str], bytes] = field(default_factory=dict) discovered_keys: dict[tuple[str, str], bytes] = field(default_factory=dict) # bound keys for the current verification session, keyed on (iss, kid) _session_bindings: dict[tuple[str, str], bytes] = field(default_factory=dict) def _resolve_key(self, iss: str, kid: str) -> bytes: composite = (iss, kid) if composite in self._session_bindings: return self._session_bindings[composite] if composite in self.pinned_keys: key = self.pinned_keys[composite] elif composite in self.discovered_keys: key = self.discovered_keys[composite] else: raise CrossIssuerKeyCollision( f"no key bound for issuer={iss!r} kid={kid!r}; " f"refusing to resolve dynamically mid-chain" ) # Detect a cross-issuer kid collision: same kid, different issuer, same key material. for (bound_iss, bound_kid), bound_key in self._session_bindings.items(): if bound_kid == kid and bound_iss != iss and bound_key == key: raise CrossIssuerKeyCollision( f"kid={kid!r} already bound to issuer={bound_iss!r} " f"within this chain; issuer={iss!r} presents identical key material" ) self._session_bindings[composite] = key return key def verify_chain(self, links: list[AttestationLink]) -> bool: self._session_bindings.clear() for link in links: key = self._resolve_key(link.iss, link.kid) expected = hashlib.sha256( f"{link.iss}|{link.kid}|{link.subject}|{link.delegates_to}".encode() ).digest() if not link.signature.startswith(expected[:8]): return False return True ```