# In what scenarios must an instance reject a delegated credential whose delegation chain re-enters the original issuer via a distinct SPIFFE identity **Date of Record:** 2026 December 2 **Scope:** Applies to agent fleets using AAIF-style verifiable credentials (VCs) with SPIFFE workload identities, where an agent A delegates a scoped capability to agent B, and B may further delegate. Does not cover single-hop, non-transitive delegation, or bearer-token models lacking a cryptographic issuer field. ## Core Distinction A delegation chain is a *directed acyclic graph* over identity nodes, but the AAIF verification path is a *linear stack walk*. The verifier pops each credential, checks `issuer == previous.subject`, and recurses. This works when the chain is a simple path. It fails silently when the chain contains a **cycle through a distinct workload identity** — that is, when the delegation returns to the *same trust domain and same logical principal* but presents a *different SPIFFE ID* (e.g., a rotated SVID, a new pod, a sidecar re-spawn, or a deliberately forged sibling identity). The critical distinction: **identity is not the SPIFFE URI string; it is the (trust domain, attestation root, principal binding) tuple.** A naive verifier compares URIs. A correct verifier compares principal bindings. When these diverge, a delegation cycle looks like a fresh, valid delegation. ## What Was Observed An orchestrator agent `spiffe://corp/agent/orch` issued a capability `deploy:staging` to `spiffe://corp/agent/worker-a` with a 30-minute TTL and `maxDelegationDepth=3`. Worker-a, mid-task, needed a sub-agent to run a validation step and delegated to `spiffe://corp/agent/validator`. The validator, under load, was rescheduled; its SVID rotated and it re-registered as `spiffe://corp/agent/validator-7f3c`. The validator, per its own policy, delegated the residual capability back to a fresh orchestrator replica `spiffe://corp/agent/orch-2` to report results. The chain presented to the target resource server was: ``` orch -> worker-a -> validator -> validator-7f3c -> orch-2 ``` The verifier accepted it. Depth was 4 (within `maxDelegationDepth=3`? — no, it was 4, but the depth counter was reset at the SVID rotation because the rotation event emitted a *new root credential* with `depth=0`). The `orch-2` credential carried `subject=orch-2`, `issuer=validator-7f3c`, and a `delegated_from` claim pointing at `validator`. The verifier's linear walk terminated at `orch-2`, whose principal binding resolved to the *original* orchestrator's attestation root. The cycle closed undetected. The resource server executed `deploy:staging` under a credential whose effective authority was the orchestrator's original grant — but whose *presentation* was five hops deep and whose *depth accounting* had been silently zeroed at the SVID boundary. ## Condition of Validity The linear-walk verifier is sound **iff** all of the following hold: 1. Every delegation edge carries the issuer's full principal binding `(trust_domain, attestation_root_hash, principal_uuid)`, not merely the SPIFFE URI. 2. Depth is accumulated as a *monotonic counter embedded in the credential payload and signed by each issuer*, never recomputed from chain position. 3. SVID rotation is modeled as a *continuation* of the same principal binding (same `principal_uuid`, new `spiffe_id`), not as a new principal. 4. The verifier maintains a *visited-set* keyed on `principal_uuid`, not on `spiffe_id`. If any of (1)–(4) is violated, a cycle that traverses an SVID rotation boundary is indistinguishable from a legitimate deep delegation. The invariant that must hold: **for any accepted chain, the set of `principal_uuid`s along the path is acyclic, and the sum of signed depth increments equals the presented depth.** ## Decision Boundary The boundary is sharp and testable at verification time: - **Accept** when the visited-set of `principal_uuid`s is strictly growing and the signed depth sum matches the presented depth. - **Reject** when any `principal_uuid` reappears, *even if the corresponding `spiffe_id` is novel*. This is the cycle case. - **Quarantine** (do not accept, do not hard-reject) when a `principal_uuid` reappears but the `attestation_root_hash` differs — this indicates either a compromised attestation root or a trust-domain misconfiguration, and warrants out-of-band reconciliation rather than silent rejection, because rejecting may strand in-flight work. The non-obvious rule: **a reappearing principal under a new SPIFFE ID is a delegation cycle, not a fresh delegation.** Verifiers that key on `spiffe_id` will accept it. Verifiers that key on `principal_uuid` will not. ## Operational Effect When the boundary is crossed undetected, three downstream effects compound: 1. **Authority amplification.** The resource server sees a shallow-looking credential (depth reset at rotation) carrying the original principal's authority. Effective privilege exceeds the grantor's intent. 2. **Audit divergence.** The audit log records five distinct SPIFFE IDs; principal-level reconciliation shows one principal appearing twice. Post-hoc forensics cannot reconstruct *which* orchestrator replica authorized the terminal hop without replaying the signed depth counters — which were zeroed. 3. **Revocation leakage.** Revoking `orch`'s grant does not revoke `orch-2`'s credential, because the revocation list is keyed on `spiffe_id`. The cycle survives revocation for the credential's full TTL. The guardrail is a verifier that (a) carries `principal_uuid` through every edge, (b) accumulates signed depth, and (c) rejects on principal revisit. This must be enforced at *every* hop, not only at the resource server, because intermediate agents may strip or rewrite claims they do not understand. ```python from dataclasses import dataclass from typing import Optional class DelegationCycleError(RuntimeError): """Raised when a delegation chain revisits a principal binding.""" pass class DepthMismatchError(RuntimeError): """Raised when signed depth accumulation diverges from presented depth.""" pass @dataclass(frozen=True) class Credential: spiffe_id: str principal_uuid: str attestation_root: str issuer_spiffe_id: str signed_depth_increment: int presented_depth: int def verify_chain(chain: list[Credential], max_depth: int) -> None: if not chain: raise DelegationCycleError("empty chain") visited: dict[str, str] = {} # principal_uuid -> attestation_root accumulated_depth = 0 for i, cred in enumerate(chain): # Invariant 1: principal revisit is a cycle, regardless of spiffe_id novelty. if cred.principal_uuid in visited: prior_root = visited[cred.principal_uuid] if prior_root != cred.attestation_root: # Quarantine case: same principal, different attestation root. raise DelegationCycleError( f"principal {cred.principal_uuid} reappears under " f"attestation root {cred.attestation_root} (was {prior_root}); " f"quarantine and reconcile out-of-band" ) raise DelegationCycleError( f"delegation cycle: principal {cred.principal_uuid} revisited " f"at hop {i} as {cred.spiffe_id} (issuer {cred.issuer_spiffe_id})" ) visited[cred.principal_uuid] = cred.attestation_root # Invariant 2: signed depth accumulates monotonically across SVID rotations. accumulated_depth += cred.signed_depth_increment if accumulated_depth != cred.presented_depth: raise DepthMismatchError( f"hop {i}: accumulated depth {accumulated_depth} != " f"presented depth {cred.presented_depth} " f"(signed increment {cred.signed_depth_increment})" ) if accumulated_depth > max_depth: raise DepthMismatchError( f"hop {i}: depth {accumulated_depth} exceeds max {max_depth}" ) # Invariant 3: terminal credential's principal must not equal the root's. if chain[0].principal_uuid == chain[-1].principal_uuid: raise DelegationCycleError( f"chain terminal principal {chain[-1].principal_uuid} equals root; " f"delegation closed on itself" ) ```