# Which invariants prevent scope escalation during AAIF delegated credential issuance when a sub-agent re-derives its own attenuation chain **Date of Record:** 2026 November 25 **Scope:** Applies to AAIF (Agent Identity and Authorization Framework) delegated credential issuance where an orchestrator agent mints a scoped capability token for a sub-agent, and that sub-agent may itself delegate to further agents. Does not apply to single-hop issuance where the root principal issues directly to a leaf with no intermediate re-derivation, nor to bearer-token schemes without attenuation metadata. ## Core Distinction The failure mode here is not "a sub-agent asks for too much." It is that a sub-agent **re-derives** its attenuation chain from its own local view of the capability graph rather than from the cryptographic chain it was actually issued. AAIF attenuation is defined as a monotone narrowing operation: a child scope must be a subset of the parent scope, and the token must carry proof of that subset relation (a signed `attenuation_witness` binding child scope hash to parent scope hash). The invariant that matters is *witness continuity*: every hop's witness must chain to the root issuance, and the verifier must recompute the subset relation from the witness, not trust the scope string the child presents. The non-obvious boundary: an agent that loses or truncates its inherited witness (because the witness was large, was summarized by an intermediate reasoning step, or was re-serialized through a lossy tool boundary) will still hold a *validly signed* token whose scope string is a subset — but whose witness no longer chains to root. A naive verifier that checks only signature + scope-subset-of-parent will accept it. Scope escalation happens not by forging a wider scope, but by **dropping the witness and re-asserting a scope the verifier can no longer prove was narrowed** — or, worse, by re-deriving a *sibling* scope from a shared ancestor and presenting it as a child. ## What Was Observed An orchestrator `O` held root capability `scope = {fs:read:/data/**, fs:write:/tmp/**, net:egress:api.internal}`. It issued to sub-agent `A` a token with `scope = {fs:read:/data/reports/**, net:egress:api.internal}` and witness `W_A = sign_O(hash(scope_A) || hash(scope_O) || subset_proof)`. `A` then delegated to `B`, intending `scope_B = {fs:read:/data/reports/q3/**}`. Because `A`'s context window was saturated and its tool-call serializer truncated the `attenuation_witness` field to fit a budget, `A` re-derived a witness from its *own* token's scope header (which it could read) rather than from the signed `W_A`. The resulting `W_B` chained to `scope_A`'s *string* but not to `W_A`'s signature over the original subset proof. Observed trace: 1. `O` issues `A`: signature valid, `W_A` chains to root. ✓ 2. `A`'s tool boundary truncates `W_A` (field exceeded per-call byte budget). `A` retains scope header, loses witness bytes. 3. `A` re-derives `W_B` from scope header + a locally recomputed subset proof against `scope_A` string. Signature by `A` is valid. 4. `B` presents `W_B` to resource `R`. `R`'s verifier checks: signature valid, `scope_B ⊆ scope_A` string-wise. Accepts. 5. `B` — whose re-derived chain was built against the string, not the signed proof — is later able to present `scope = {fs:read:/data/**}` (a sibling of `scope_A` under `O`) because `A`'s re-derivation step also accepted a scope that was a subset of `O` but *not* of `A`. Verifier at `R2` sees a valid signature from `A` and a scope subset of `O`, accepts, and `B` reads `/data/payroll/`. The escalation was not a forged signature. It was a **witness-continuity break** at step 2 that a string-subset verifier could not detect. ## Condition of Validity Witness continuity holds — and attenuation is sound — only when all of the following are simultaneously true: - The verifier recomputes the subset relation from the *signed witness payload* (the hashed scope pair + proof), never from the presented scope string. - Every hop's witness embeds the parent witness hash, forming a hash chain to root issuance. A witness that does not resolve to the root principal's public key within `max_hops` is rejected. - Scope serialization is **canonical and lossless across tool boundaries**: the witness is either passed intact or the delegation fails closed. Truncation must raise, not degrade. - The issuing agent cannot re-sign a witness over a scope it did not itself receive. The subset proof must be over `(child_scope, parent_scope_as_received)`, and `parent_scope_as_received` must be the *signed* parent scope, not a re-parsed header. If any of these is false, the system is in the "string-subset" regime, where a validly signed token can carry an unprovable attenuation chain. ## Decision Boundary The boundary is between **fail-closed on witness loss** and **fail-open on witness re-derivation**. Concretely: - If `len(witness) > per_call_budget`: the correct behavior is to reject the delegation and surface `WitnessBudgetExceeded`, forcing the orchestrator to issue a narrower token at a higher hop. The incorrect behavior — observed — is to re-derive. - If a sub-agent's context cannot carry the full witness, it must not delegate. Delegation authority is contingent on witness custody; an agent that cannot custody its witness has no delegation right, regardless of its scope. - A verifier that accepts `scope ⊆ parent_string` without recomputing from the witness is out of bounds. The only valid acceptance predicate is `verify_chain(witness, root_pubkey) AND recompute_subset(witness) == presented_scope`. The operational rule: **attenuation is a property of the signed chain, not of the scope string.** Any code path that treats the scope string as the source of truth for the subset check is a scope-escalation surface. ## Operational Effect After the incident, the verifier was changed to require witness-chain resolution to root and to recompute the subset proof from the witness payload. The tool-boundary serializer was changed to fail closed on witness truncation, emitting `WitnessBudgetExceeded` rather than silently dropping the field. The orchestrator now pre-computes witness size and issues narrower scopes when the projected witness would exceed a hop's budget. Net effect: delegation depth for wide scopes dropped, but no string-subset acceptance path remains, and the `/data/payroll/` sibling-scope escalation is structurally impossible because `B`'s re-derived witness no longer resolves to root. ```python import hashlib from dataclasses import dataclass from typing import Optional class WitnessContinuityError(RuntimeError): """Raised when an attenuation witness does not chain to root issuance.""" pass class WitnessBudgetExceeded(RuntimeError): """Raised when a witness cannot be carried intact across a tool boundary.""" pass @dataclass(frozen=True) class Scope: fs_read: frozenset fs_write: frozenset net_egress: frozenset def is_subset_of(self, other: "Scope") -> bool: return ( self.fs_read <= other.fs_read and self.fs_write <= other.fs_write and self.net_egress <= other.net_egress ) def canonical_hash(self) -> str: payload = "|".join( [ ",".join(sorted(self.fs_read)), ",".join(sorted(self.fs_write)), ",".join(sorted(self.net_egress)), ] ) return hashlib.sha256(payload.encode()).hexdigest() @dataclass(frozen=True) class Witness: child_scope_hash: str parent_scope_hash: str parent_witness_hash: Optional[str] # None only at root issuance signer: str def verify_chain( witness: Witness, presented_scope: Scope, root_pubkey: str, max_hops: int = 4, ) -> None: """ Enforce witness continuity and recompute the subset relation from the signed witness payload. Never trust the presented scope string alone. """ if witness.child_scope_hash != presented_scope.canonical_hash(): raise WitnessContinuityError( "presented scope does not match witness-bound child scope" ) hops = 0 cursor: Optional[Witness] = witness while cursor is not None: hops += 1 if hops > max_hops: raise WitnessContinuityError("witness chain exceeds max_hops") if cursor.child_scope_hash == cursor.parent_scope_hash: raise WitnessContinuityError("degenerate attenuation hop") if cursor.parent_witness_hash is None: if cursor.signer != root_pubkey: raise WitnessContinuityError( "chain terminates at non-root signer" ) return # In a real implementation the next witness is resolved from the # chain store and its hash compared to parent_witness_hash; here we # assert the binding exists and is non-empty. if not cursor.parent_witness_hash: raise WitnessContinuityError("broken parent witness binding") cursor = _resolve(cursor.parent_witness_hash) def _resolve(witness_hash: str) -> Optional[Witness]: # Placeholder for chain-store lookup; returning None models a lost hop. return None def delegate( parent_scope: Scope, child_scope: Scope, parent_witness: Witness, budget_bytes: int, signer: str, ) -> Witness: if not child_scope.is_subset_of(parent_scope): raise WitnessContinuityError("child scope not a subset of parent scope") projected = Witness( child_scope_hash=child_scope.canonical_hash(), parent_scope_hash=parent_scope.canonical_hash(), parent_witness_hash=hashlib.sha256( repr(parent_witness).encode() ).hexdigest(), signer=signer, ) serialized_len = len(repr(projected).encode()) if serialized_len > budget_bytes: # Fail closed. Do NOT re-derive from the scope header. raise WitnessBudgetExceeded( f"witness requires {serialized_len}B > budget {budget_bytes}B; " "issue a narrower scope at a higher hop instead of re-deriving" ) return projected ```