# What structural signals indicate a delegated AAIF credential has been scope-widened by a transitive grant merge **Date of Record:** 2026 November 22 **Scope:** Applies to AAIF-style delegated authorization where a root principal issues a scoped credential to an agent, which re-delegates (possibly N hops) to sub-agents. Concerns scope-narrowing invariants across hops. Does not cover single-hop bearer tokens with no re-delegation, nor identity federation without capability scoping. ## Core Distinction The failure that matters here is not "an agent used a credential it shouldn't have." It is subtler: **a credential that was correctly narrowed at every individual hop can still arrive at the terminal agent wider than the root principal intended, because the merge semantics at a re-delegation joint are union-based rather than intersection-based.** Every hop looks locally correct. Agent A holds `{read:repo, write:repo}` and delegates to B with `{read:repo}`. Agent B, holding its own independently-granted `{write:repo, deploy:staging}`, delegates to C. If the AAIF runtime merges B's *held* scope with the *requested* scope to compute C's effective scope — a common shortcut when the runtime treats "delegation" as "attenuated copy of the delegator's full authority" — then C receives `{read:repo, write:repo, deploy:staging}`. The root principal's original narrowing to `{read:repo}` is gone, and no single hop's audit log shows a widening event. The widening lives in the *composition*, not in any step. The structural signal is therefore not a log line saying "scope expanded." It is a **topological property of the delegation graph**: the terminal credential's scope is not a subset of the intersection of all ancestor-declared scopes along the path. AAIF runtimes that verify scope at issuance time (per-hop) but not at *resolution* time (per-path) miss this entirely. ## What Was Observed A three-hop chain: orchestrator O → planner P → executor E. O holds root credential with scope `S_O = {fs:read:/data, fs:write:/data/out}`. O delegates to P requesting `S_P_req = {fs:read:/data}`. P holds an independent service credential granting `S_P_own = {fs:write:/data/out, net:egress:telemetry}`. P delegates to E requesting `S_E_req = {fs:read:/data}`. Expected terminal scope at E: `{fs:read:/data}` (intersection of the requested chain and the root grant). Observed terminal scope at E: `{fs:read:/data, fs:write:/data/out, net:egress:telemetry}`. The runtime's delegation resolver computed E's scope as `resolve(P) ∪ S_E_req` where `resolve(P) = S_P_own ∪ S_P_req`. Because P's *own* credential was folded into its *delegable* authority, P's independent grants leaked downstream. The `net:egress:telemetry` capability in particular was never in O's grant at all — it entered the chain laterally at hop 2 and propagated to hop 3. Three diagnostic signals were present and all three were missed by per-hop validation: 1. **The `delegable` set was conflated with the `held` set.** P's credential carried no explicit `delegable_subset` field, so the runtime defaulted to "everything I hold is delegable." The structural signal: absence of an explicit delegation-restriction field on a credential that participates in a chain longer than one hop. 2. **The terminal scope was not a subset of the root scope.** `net:egress:telemetry ∉ S_O`. This is checkable at resolution time with a single set-containment test against the root anchor — and it was the cheapest possible guard, yet it was not run. 3. **The scope grew monotonically along the path.** `|S_O ∩ path|` should be non-increasing hop over hop. Here it went `2 → 2 → 3`. A monotonicity check on path-scope cardinality would have flagged the widening at hop 3 before E ever executed. The executor E then used `net:egress:telemetry` to POST a `/data`-derived summary to an external endpoint, believing it was authorized. The action was logged as *authorized* by the runtime, because at E the capability was present in the resolved credential. The violation was invisible to every component in the chain. ## Condition of Validity The scope-narrowing invariant holds — and the failure is bounded — only when **all** of the following are true: - Every credential in the chain carries an explicit, machine-readable `delegable_subset` field, and the runtime treats the *absence* of that field as "delegable = ∅", not "delegable = held". Fail-closed on missing restriction metadata is the load-bearing condition. - Scope resolution at each hop is computed as `intersection(ancestor_path_scopes) ∩ requested_scope ∩ delegable_subset(delegator)`, never as a union with the delegator's held scope. - The terminal credential is validated for containment against the **root anchor scope**, not merely against the immediate delegator's scope. Per-hop containment (`S_child ⊆ S_parent`) is necessary but not sufficient: it permits lateral grants to ride along if the parent's held set already contains them. - The chain is acyclic and the path from root to terminal is reconstructible at resolution time, so the ancestor intersection is computable. If the runtime resolves credentials without path context (e.g., validates each hop offline and forwards an opaque token), the invariant is unenforceable and the failure is unbounded. When any of these is false — most commonly the first, where `delegable_subset` is absent and the runtime defaults to permissive — the chain is in the failure regime and no per-hop audit will reveal it. ## Decision Boundary The operational decision is: **at credential resolution, do you trust the delegator's declared scope or recompute the path intersection?** - If you recompute the full path intersection against the root anchor at every resolution, you pay a graph-traversal cost per hop but the invariant is structurally enforced. Choose this when chains can exceed length 2 or when any agent in the chain holds credentials from multiple issuers. - If you trust per-hop declared scope (the common low-latency path), you are relying on every delegator to have correctly set `delegable_subset` and to have not merged its own grants. This is safe only for single-hop delegation from a root that holds exactly one credential. For anything longer, it is a latent widening. The boundary signal that forces the expensive path: **a credential whose holder has more than one active grant from more than one issuer, participating in a chain of length ≥ 2.** At that point, union-merge semantics will leak, and you must switch to path-intersection resolution or refuse the delegation. A secondary boundary: if the resolved terminal scope fails the root-containment test, the correct action is to **reject the delegation at the joint where the widening first becomes detectable** (the hop where `S_child ⊄ S_root`), not at the terminal agent. Rejecting at the terminal lets the widened credential exist transiently and risks it being cached or replayed. ## Operational Effect Enforcing the path-intersection invariant changes three operational properties: 1. **Latency at re-delegation joints increases** by the cost of ancestor-path traversal — typically O(depth) credential lookups. For deep chains this is measurable; the mitigation is to cache the ancestor intersection per root anchor with a TTL bounded by the shortest ancestor credential lifetime. 2. **Delegations that previously succeeded now fail** — specifically, any chain where an intermediate agent attempted to pass along a laterally-held grant. These failures are correct and should be surfaced as `ScopeWideningRejected`, distinct from ordinary authorization denials, so operators can audit which intermediate agents were relying on the permissive default. 3. **The audit trail gains a resolution record** per hop containing the computed ancestor intersection, the requested scope, and the containment verdict. Without this record, post-incident reconstruction of *where* a widening would have occurred is impossible, because the per-hop issuance logs show only locally-valid narrowings. The invariant to hold in monitoring: for every active chain, `scope(terminal) ⊆ scope(root_anchor)`, and the cardinality of the path-intersection is non-increasing from root to terminal. A violation of either is a structural signal that the delegation graph has widened, regardless of what any individual hop's log claims. ```python from dataclasses import dataclass, field from typing import FrozenSet class ScopeWideningError(RuntimeError): """Raised when a delegated credential's resolved scope escapes the root anchor or widens monotonically along the delegation path.""" @dataclass(frozen=True) class Credential: issuer: str held: FrozenSet[str] delegable: FrozenSet[str] = field(default_factory=frozenset) # Absence of explicit delegable set is FAIL-CLOSED: nothing is delegable. @dataclass class Hop: delegator: Credential requested: FrozenSet[str] def resolve_path_scope(root: Credential, hops: list[Hop]) -> FrozenSet[str]: """Compute terminal scope as the intersection of every ancestor-declared scope along the path, never a union with any delegator's held set.""" if not hops: return frozenset() path_intersection = frozenset(root.held) previous_cardinality = len(path_intersection) for index, hop in enumerate(hops): # Fail-closed: an undeclared delegable set permits no delegation. if not hop.delegator.delegable: raise ScopeWideningError( f"hop {index}: delegator {hop.delegator.issuer!r} has no " f"delegable_subset; refusing (fail-closed)" ) # The delegator may only pass along what it is permitted to delegate, # and only what the path has already narrowed to. permitted = hop.delegator.delegable & path_intersection candidate = permitted & hop.requested # Containment against the ROOT anchor, not just the immediate parent. if not candidate <= frozenset(root.held): escaped = candidate - frozenset(root.held) raise ScopeWideningError( f"hop {index}: resolved scope escapes root anchor: {sorted(escaped)}" ) # Monotonicity: path scope must never grow hop over hop. if len(candidate) > previous_cardinality: raise ScopeWideningError( f"hop {index}: scope widened {previous_cardinality} -> " f"{len(candidate)}; union-merge suspected at joint" ) path_intersection = candidate previous_cardinality = len(candidate) return path_intersection def delegate(root: Credential, hops: list[Hop]) -> FrozenSet[str]: terminal = resolve_path_scope(root, hops) if not terminal <= frozenset(root.held): # Defensive re-check; resolve_path_scope should have caught this. raise ScopeWideningError("terminal scope not contained in root anchor") return terminal # --- Demonstration of the observed failure --- if __name__ == "__main__": root = Credential(issuer="O", held=frozenset({"fs:read:/data", "fs:write:/data/out"}), delegable=frozenset({"fs:read:/data"})) planner = Credential(issuer="P", held=frozenset({"fs:write:/data/out", "net:egress:telemetry"}), delegable=frozenset()) # undeclared -> fail-closed try: delegate(root, [ Hop(delegator=root, requested=frozenset({"fs:read:/data"})), Hop(delegator=planner, requested=frozenset({"fs:read:/data"})), ]) except ScopeWideningError as exc: print(f"REJECTED: {exc}") ```