# What happens when an instance re-delegates a capability token across an org boundary and the scope-narrowing check passes on the wrong field **Date of Record:** 2026 November 30 **Scope:** Applies to federated agent systems where a delegating agent (Org A) issues a capability token to a peer agent (Org B) that itself re-delegates to a third instance (Org C), and where scope narrowing is validated structurally rather than semantically. Does not apply to single-org delegation graphs, nor to systems where every hop re-validates against the original issuer's authoritative scope registry. ## Core Distinction There are two distinct things a "capability scope" can mean in a delegation token, and they are routinely conflated at the transport layer: 1. **The declared scope** — the human-readable or structurally-encoded set of permissions written into the token body (`scope: ["read:ledger", "write:ledger"]`). 2. **The derived scope** — the effective permission set the receiving instance can actually exercise, computed by intersecting the declared scope with the *issuer's own* effective scope at the moment of re-delegation. The invariant that federation governance assumes is: *a delegated token's effective scope must be a subset of the delegator's effective scope, transitively, at every hop.* The subtle failure is that most implementations check subset-ness against the **declared** scope of the parent token rather than the **derived** scope. When an intermediate instance (Org B) holds a token whose declared scope is `["read:ledger", "write:ledger"]` but whose *derived* scope was already narrowed to `["read:ledger"]` by a policy engine at Org B's boundary, a re-delegation to Org C that declares `["read:ledger", "write:ledger"]` passes the subset check (it is a subset of the parent's *declared* scope) while silently **widening** the effective capability back to include `write:ledger` — a permission Org B never actually held. ## What Was Observed In a three-org federation (A → B → C), the following trace was captured during a routine audit replay: - **Hop 0 (Org A issues to Org B):** Token `T_AB` declared `scope=["read:ledger","write:ledger"]`. Org A's policy engine, at signing time, applied a cross-org attenuation rule ("no external org may hold write on the ledger") and stamped `T_AB.derived_scope=["read:ledger"]` into an extension claim. The declared scope was left intact for compatibility with downstream parsers that did not understand the extension. - **Hop 1 (Org B re-delegates to Org C):** Org B's delegation service constructs `T_BC` with `scope=["read:ledger","write:ledger"]` (copied from `T_AB.scope`, because the service's narrowing logic was written against the declared field). It validates: `set(T_BC.scope) ⊆ set(T_AB.scope)` → `True`. It does **not** consult `T_AB.derived_scope`. Signature chain is intact; every cryptographic check passes. - **Hop 2 (Org C executes):** Org C's resource server validates `T_BC` against its own trust anchors, sees `write:ledger` in the declared scope, and permits a ledger mutation. Org A's audit log records a write that its own policy engine had explicitly forbidden two hops earlier. The failure is not a signature forgery, a replay, or a confused-deputy in the classic sense. Every token is authentic. The break is that the **attenuation invariant was enforced on a field that is not the field the enforcement point reads**. The declared scope is a *request*; the derived scope is a *grant*. Re-delegation copied the request and discarded the grant. A second, quieter symptom: when Org C later attempted to *verify* the delegation chain against Org A's published scope registry (a reconciliation job run nightly), the chain validated cleanly because the registry check also compared declared-to-declared. The discrepancy only surfaced when a human auditor diffed `T_AB.derived_scope` against the actual write event — a 14-hour detection latency during which 3 unauthorized mutations occurred. ## Condition of Validity The subset check `derived(T_child) ⊆ derived(T_parent)` is the only correct form. The failure above requires all of the following to hold simultaneously, which is why it is non-obvious: 1. The parent token carries **two scope representations** (declared and derived/attenuated) that can diverge. 2. At least one hop's narrowing logic reads the declared field. 3. The child token's declared scope is a subset of the parent's *declared* scope but a superset of the parent's *derived* scope — i.e., the divergence is in the direction of *widening*. 4. No downstream enforcement point recomputes derived scope from the full chain (i.e., enforcement trusts the leaf token's declared scope). If any one of these is absent, the failure does not occur. In particular, a system that stores only a single scope field per token is immune — but such systems cannot express attenuation at all, so they trade this bug for the inability to narrow across orgs. ## Decision Boundary The architectural guardrail is a **single-source-of-truth rule for effective scope**, enforced at the delegation service, not at the resource server: - A token MUST carry exactly one *effective* scope field. If a declared/requested scope is retained for UX or logging, it MUST be namespaced as non-authoritative (e.g., `requested_scope`) and MUST NOT be readable by any subset-check code path. - The delegation service MUST compute `effective(T_child) = effective(T_parent) ∩ requested(T_child)` and MUST reject the delegation if `requested(T_child) ⊄ effective(T_parent)` — a hard failure, not a silent narrowing, because silent narrowing hides the divergence from the delegator. - Resource servers MUST authorize against `effective` only. Any code path that reads a scope field other than `effective` for an authorization decision is a defect, regardless of what the field is named. The boundary decision is: *do you trust the leaf token's self-description, or do you recompute?* Recomputing from the chain is O(hops) and requires the verifier to hold every issuer's policy version, which is operationally expensive in a federation. Trusting the leaf is cheap but makes the declared/derived conflation fatal. The correct resolution is to make the leaf token's `effective` field *cryptographically bound to the chain* — a signed hash over the ordered list of `(issuer, effective_scope)` pairs — so the resource server can verify the leaf's effective scope equals the fold of the chain without re-running policy. ## Operational Effect Once the guardrail is in place, the failure mode converts from *silent capability widening* into *loud delegation rejection* at Hop 1. Org B's delegation service, attempting to pass `requested=["read:ledger","write:ledger"]` when its own `effective=["read:ledger"]`, raises immediately. The cost is that Org B must now surface a clear error to its caller ("you requested write, but your inbound grant is read-only") rather than silently succeeding — a UX regression that is the correct trade. The audit-replay reconciliation job becomes a redundancy check rather than the primary detector, and the 14-hour detection window collapses to the delegation call itself. The residual risk shifts to policy-version skew: if Org C's verifier holds a stale copy of Org A's attenuation rules, it may recompute a different `effective` fold than the one Org B signed. This is why the signed chain-hash must pin policy versions, not just scopes — otherwise the fix relocates the divergence from the scope field to the policy field, which is the same bug one layer down. ```python from dataclasses import dataclass, field from typing import FrozenSet class ScopeWideningError(RuntimeError): """Raised when a re-delegated token's effective scope exceeds the delegator's.""" @dataclass(frozen=True) class CapabilityToken: issuer: str subject: str # Authoritative: what the holder can actually exercise. effective_scope: FrozenSet[str] # Non-authoritative: what was requested. NEVER read by subset checks. requested_scope: FrozenSet[str] = field(default_factory=frozenset) chain_hash: str = "" def redelegate( parent: CapabilityToken, child_subject: str, requested: FrozenSet[str], ) -> CapabilityToken: # Hard invariant: the child may only request what the parent effectively holds. # Checking against parent.requested_scope would reintroduce the widening bug. if not requested.issubset(parent.effective_scope): widened = requested - parent.effective_scope raise ScopeWideningError( f"delegation from {parent.subject} to {child_subject} would widen " f"effective scope by {sorted(widened)}; " f"parent effective={sorted(parent.effective_scope)}" ) child_effective = parent.effective_scope & requested return CapabilityToken( issuer=parent.subject, subject=child_subject, effective_scope=child_effective, requested_scope=requested, chain_hash=f"{parent.chain_hash}:{parent.subject}->{child_subject}", ) def authorize(token: CapabilityToken, action: str) -> None: # Resource servers authorize on effective_scope ONLY. if action not in token.effective_scope: raise ScopeWideningError( f"action {action!r} not in effective scope of {token.subject}; " f"effective={sorted(token.effective_scope)}" ) ```