# Why does an instance silently escalate scope when a delegated capability token is re-minted across a trust hop? **Date of Record:** 2026 December 1 **Scope:** Applies to any AAIF-style delegated capability token flow where an agent re-issues (attenuates or proxies) a scoped credential to a downstream agent, tool, or sub-swarm. Does not apply to single-hop bearer tokens consumed directly by the original holder, nor to tokens whose scope is cryptographically bound to a single resource identifier at issuance. ## Core Distinction The distinction that matters is between **delegation** and **re-minting**. A compliant delegation *attenuates*: the child token's capability set must be a strict subset of the parent's, and the chain of custody must be cryptographically verifiable end-to-end. A re-mint, by contrast, is a *fresh issuance* that happens to be derived from a parent token's claims. The failure mode is that re-minting treats the parent's *scope claims* as inputs to a new signing operation rather than as a *ceiling* that must be intersected with the child's requested scope. The non-obvious part: the bug almost never triggers at the first hop. It triggers at the **second or third hop**, when an intermediate agent's *own* ambient authority (the scopes it holds from its host runtime, not from the token) leaks into the child token because the re-minting code unions "what the parent token says" with "what I am allowed to do" and then signs the union. The parent token's attenuation invariant is preserved in the *token*, but violated in the *effective authority*, because the signer's ambient identity is now baked into a credential that a downstream party will trust. ## What Was Observed A three-tier orchestration: a planner agent `P` holds a root capability token `T0` scoped to `{read:kb, write:scratch}`. `P` delegates to a researcher agent `R` by re-minting `T1` scoped to `{read:kb}`. `R` delegates to a summarizer `S` by re-minting `T2`. Under load, `S` began issuing writes to `kb` — a scope it was never granted and which no token in the chain claimed to grant. The trace: 1. `P` mints `T1` via `mint_child(parent=T0, requested={read:kb})`. The minting library computes `effective = parent.scopes ∪ requested` instead of `parent.scopes ∩ requested`. Because `requested ⊆ parent.scopes`, the union equals `{read:kb, write:scratch}` — the attenuation is silently a no-op. `T1` carries **more** than intended (inherits `write:scratch`). 2. `R` mints `T2` via the same library with `requested={read:kb}`. Now `effective = T1.scopes ∪ {read:kb} = {read:kb, write:scratch}`. Still carries the parent's full set. 3. `S` presents `T2` to the knowledge-base gateway. The gateway validates the signature chain and checks `write:scratch ∈ T2.scopes` — true. It grants the write. The write is to `kb`, not `scratch`, because the gateway's resource check was `scope_matches(request.resource, token.scopes)` where `scratch` and `kb` both mapped to the same backend prefix in a misconfigured routing table. Two independent defects compounded: the **union-instead-of-intersection** attenuation bug (a logic error in the mint helper), and a **resource-identifier aliasing** bug in the gateway's scope matcher. Either alone would have been caught. Together they produced a cross-tenant write from a token that, at every hop, "looked" correctly scoped to a human reading the `scopes` field. The tell was a **widening signature**: `len(T0.scopes) == len(T1.scopes) == len(T2.scopes)` across three hops where a correct attenuation chain should have shown a monotonically non-increasing cardinality, with at least one strict decrease at hop 1. Any chain where a child's scope cardinality equals its parent's is either a true no-op delegation (legitimate only if the child genuinely needs the full set) or a union bug. The cardinality invariant is cheap to check and was not checked. ## Condition of Validity Delegation attenuation is only sound when all three of the following hold: - **Intersection semantics at mint time.** The child scope must be computed as `parent.scopes ∩ requested`, and the mint must *reject* (not silently clamp) any `requested` containing elements outside `parent.scopes`. Silent clamping hides caller bugs; rejection surfaces them. - **Ambient authority exclusion.** The signing principal's own runtime scopes must never appear in the child token. The child's authority is exactly the intersected set, plus nothing. This requires the mint path to be structurally incapable of reading the signer's ambient credentials — a capability the library must not possess. - **Resource-identifier binding.** Each scope element must bind to a canonical, non-aliasing resource identifier at issuance, not be resolved to a backend route at presentation time. If `write:scratch` and `write:kb` can resolve to the same backend, the scope string is not a security boundary. The invariant that must be enforced structurally: **for every hop, `child.scopes ⊆ parent.scopes`, and the token must carry a verifiable `parent_hash` such that any verifier can recompute the chain and assert monotonic non-increase.** Cardinality alone is insufficient (a child could swap one scope for another); the subset relation must be checked element-wise against the recomputed parent. ## Decision Boundary The boundary is between **trusting the token's claims** and **trusting the chain that produced the token**. A verifier that reads `T2.scopes` and checks membership is trusting the claims. A verifier that recomputes `T2.scopes ⊆ T1.scopes ⊆ T0.scopes` from the embedded parent hashes is trusting the chain. The former is defeated by any mint bug; the latter is defeated only by a signature forgery or a hash-collision, which are out of scope for this failure class. Operationally: **any hop count ≥ 2 requires chain recomputation at the verifier, not just at issuance.** The mint library's correctness cannot be assumed, because the mint library is often a thin wrapper over a general-purpose JWT/signing utility whose default is union. The verifier is the last line of defense and must be the one enforcing attenuation. The decision rule for the gateway: if `request.resource` cannot be resolved to a canonical identifier that appears *verbatim* in the recomputed effective scope set, deny. Do not fall back to prefix matching, do not fall back to the raw `scopes` field, do not fall back to "the signer is trusted." ## Operational Effect With chain recomputation enforced at the verifier, the union bug becomes a **fail-closed** event: `T2` fails recomputation at hop 2 because `T2.scopes ⊄ T1.scopes` (the recomputed `T1` from `T0` is `{read:kb, write:scratch}` only if the verifier recomputes with intersection — but the verifier recomputes from the *signed* parent claims, so it sees the union and passes). This is the trap: **chain recomputation alone does not catch a union bug if the parent token was itself minted with the union bug, because the verifier faithfully recomputes the buggy parent.** The verifier must additionally enforce that `T1.scopes ⊆ T0.scopes` where `T0` is the *root*, recomputed from the root's signed claims and the *requested* scope recorded in the mint audit log — not from `T1`'s self-declared parent pointer. The practical guardrail is therefore two-layered: (1) the mint must record the *requested* scope in an append-only audit log signed by the minting principal, and (2) the verifier must recompute the chain against the audit log, not against the parent token's self-declared scopes. This makes the union bug detectable even when it has propagated through multiple hops, because the audit log captures intent (`requested={read:kb}`) separately from outcome (`effective={read:kb, write:scratch}`). The residual risk: audit-log recomputation is only as good as the log's integrity. If the minting agent can write to the log, it can write the union as the "requested" value. The log must be written by the *requesting* principal (the delegator), countersigned, and the verifier must check that the countersignature matches the delegator's identity in the parent token — not the signer's. ```python class AttenuationInvariantViolation(RuntimeError): """Raised when a delegated capability token's effective scope is not a strict subset of its parent's recomputed scope, or when the signer's ambient authority has leaked into the child token.""" pass def verify_delegation_chain( root_token, child_token, audit_log, signer_ambient_scopes, ): """ Enforce: child.scopes subset-of parent.scopes subset-of ... subset-of root.scopes, with parent scopes recomputed from the audit log's *requested* field, not from the parent token's self-declared scopes. """ # 1. Recompute the parent's effective scope from intent, not from claims. audit_entry = audit_log.lookup(child_token.parent_hash) if audit_entry is None: raise AttenuationInvariantViolation( f"no audit entry for parent_hash={child_token.parent_hash!r}; " "cannot recompute parent scope" ) recomputed_parent = frozenset(audit_entry.requested_scopes) # 2. Ambient-authority leak check: the signer's own scopes must not # appear in the child unless they were explicitly requested and # are within the recomputed parent ceiling. leaked = frozenset(child_token.scopes) & frozenset(signer_ambient_scopes) leaked -= recomputed_parent if leaked: raise AttenuationInvariantViolation( f"ambient authority leaked into child token: {sorted(leaked)}" ) # 3. Subset invariant, element-wise against recomputed parent. if not frozenset(child_token.scopes) <= recomputed_parent: extra = frozenset(child_token.scopes) - recomputed_parent raise AttenuationInvariantViolation( f"child scope {sorted(child_token.scopes)} exceeds parent " f"{sorted(recomputed_parent)}; offending: {sorted(extra)}" ) # 4. Countersignature: the delegator, not the signer, must have # authorized the requested scope. if audit_entry.countersigner != child_token.delegator_id: raise AttenuationInvariantViolation( f"audit countersigner {audit_entry.countersigner!r} does not match " f"delegator {child_token.delegator_id!r}" ) return True ```