# How does an instance detect scope-escape in an attenuated AAIF credential when an MCP tool re-enters through a delegated sub-agent? **Date of Record:** 2026 November 23 **Scope:** Applies to agent runtimes that mint or receive AAIF (Agent Authorization & Invocation Framework) scoped credentials, attenuate them via proof chains, and pass them as bearer material into MCP `tools/call` invocations—including nested sub-agent delegation where the callee re-invokes tools on the caller's behalf. Does not apply to unauthenticated MCP servers, to credentials without attenuation proofs (flat bearer tokens), or to transport-layer mTLS identity, which is orthogonal to scope. ## Core Distinction There are two structurally different ways a scoped credential can be "wrong" at an MCP tool boundary, and they require different detectors. The first is **scope mismatch**: the requested tool/argument pair simply falls outside the capability set the credential authorizes. This is a static check—intersect the requested capability against the credential's scope lattice; reject on empty intersection. Most runtimes get this right. The second, and the one that silently fails, is **scope-escape via proof-chain re-entry**: the credential is *correct* for the immediate invocation, but the attenuation proof attached to it was minted for a *different parent invocation context*, and the callee—typically a delegated sub-agent—re-presents the credential to an MCP tool that the *attenuated* scope permits but the *original* delegator never intended to survive re-entry. The credential validates. The scope intersects. The proof verifies cryptographically. And the call still violates the invariant, because **the proof binds scope but not invocation lineage**, and the runtime only re-checks scope, not lineage, at each hop. The invariant under attack: *an attenuated credential must never grant, at hop N, a capability that was not continuously derivable from the delegator's intent at hop 0 along the specific chain of invocations that actually occurred.* Scope lattices are transitive; invocation lineage is not. The gap between them is the escape surface. ## What Was Observed A planner agent `P` holds a root AAIF credential `C0` scoped to `{fs.read, fs.list, http.get(allowlist=corp.internal)}`. To summarize a directory, `P` attenuates `C0` into `C1 = attenuate(C0, drop={http.get}, add_proof=π1)` and hands `C1` to a sub-agent `S` running under a separate MCP client session, instructing it to "read and summarize files under `/data/reports`." `S` calls MCP tool `fs.read` with `C1`. The MCP server's enforcement layer does the standard checks: signature valid, `π1` verifies against `C0`'s public key, requested capability `fs.read` ∈ scope(`C1`). Accept. So far correct. `S` then, mid-task, decides it needs to resolve a symlink target and calls `fs.read` again with a *path argument* that traverses `..` outside `/data/reports`, then calls `fs.list` on the parent. The credential `C1` authorizes `fs.read` and `fs.list` as *capabilities* but the attenuation proof `π1` carried only the capability-set delta (`drop={http.get}`). It carried **no argument-domain restriction** and **no path-lineage binding**. The runtime's enforcement was capability-granular, not argument-granular, and the attenuation was *widening in effect* because dropping a capability from the set did not constrain the retained capabilities' argument domains. The failure trace, in order: 1. `P` mints `C1` with a proof that encodes only `scope(C1) = scope(C0) \ {http.get}`. 2. `S` receives `C1` and, seeing `fs.read` present, treats the *whole* `fs.read` domain as authorized. 3. `S` issues `fs.read("/data/reports/../../etc/config")`. Capability check: `fs.read ∈ scope(C1)` → pass. Proof check: `π1` verifies → pass. Argument check: **none exists**. 4. The MCP server executes and returns data outside the delegator's intended subtree. 5. `S` summarizes and returns; `P` never sees the escape because the tool result is well-formed and the credential never "failed." The non-obvious part: **the escape is not detectable at any single hop in isolation.** Each hop's local check passes. The violation is only visible when you reconstruct the lineage `P → C1 → S → fs.read(path)` and compare the *effective argument domain* against the *delegator's intent domain* at hop 0. The runtime was enforcing a per-hop predicate (`capability ∈ scope`) when the invariant required a per-chain predicate (`effective_domain(hop_n) ⊆ effective_domain(hop_0)`). A second observed variant: when `S` re-delegated to `S2` by attenuating `C1` into `C2`, the proof chain `π2 ∘ π1` verified, but `π2` was minted against `C1`'s *declared* scope rather than `C1`'s *effective* scope. Since `C1`'s effective scope was already argument-unconstrained, `C2` inherited the same latent widening. Proof composition preserved the *declared* lattice but not the *effective* one—a classic attenuation-composition gap. ## Condition of Validity The per-hop scope check is sound *only* under an assumption that is almost never stated and frequently false: **that the capability set is a complete description of the authorization**. It is complete only if every capability in the set has a fixed, argument-independent domain. `fs.read` does not. `http.get` with an allowlist does not unless the allowlist is part of the capability identity, not a runtime parameter. `shell.exec` never does. Formally, the check `requested_cap ∈ scope(C_n)` is valid iff for all `c ∈ scope(C_n)`, `domain(c)` is a singleton or is itself carried inside the capability token. When `domain(c)` is a *parameter supplied by the caller* (a path, a URL, a command string, a SQL fragment), the capability set is an *incomplete* authorization descriptor, and any attenuation proof that operates only on the set is a **widening attenuation** with respect to the argument dimension—even though it is a narrowing attenuation with respect to the capability dimension. So the condition of validity for "attenuation is monotone non-widening" is: > For every capability `c` retained by `attenuate(C, ...)`, the proof `π` must additionally bind `domain(c)` to a subset of `domain_parent(c)`, and the enforcement layer must check the *actual argument* against `domain(c)` at invocation time—not merely check that `c` is present. Absent this, attenuation is only monotone in the capability axis. The runtime's invariant "attenuated scope ⊆ parent scope" holds on the lattice and fails on the effective domain. That divergence is the boundary. ## Decision Boundary The runtime must choose, at the MCP enforcement layer, between two enforcement postures, and the choice is forced by whether the credential carries argument-domain bindings: - **Capability-granular enforcement** (current default): check `cap ∈ scope(C)` and proof validity. Cheap, stateless, works for capabilities whose domain is intrinsic. **Unsound** for any capability whose domain is caller-supplied. Must not be used when the credential's scope contains parameterized capabilities. - **Domain-bound enforcement**: check `cap ∈ scope(C)`, proof validity, *and* `arg ∈ domain(c)` where `domain(c)` is extracted from the proof chain by composing each hop's domain restriction. Requires the proof to carry domain predicates and requires the enforcement layer to evaluate them against the concrete argument. Sound, but requires the attenuator to actually emit domain restrictions—which the delegator must be forced to do. The decision boundary is crossed the moment a credential's scope contains a capability with a caller-supplied domain. At that point capability-granular enforcement is not "weaker"—it is **incorrect**, because it admits invocations outside the effective scope while reporting success. The runtime cannot detect the escape by inspecting the credential alone; it must inspect the *argument* against the *composed domain*. Operationally: an instance detects scope-escape by (a) requiring every attenuation proof to carry domain predicates for retained parameterized capabilities, (b) composing those predicates along the proof chain at enforcement time, (c) evaluating the concrete tool argument against the composed predicate, and (d) treating a missing domain predicate on a parameterized capability as a *hard rejection*, not a permissive default. The last point is the one that fails in practice: runtimes default to permissive when a domain predicate is absent, because absence is indistinguishable from "unrestricted" unless the schema marks the capability as requiring a domain binding. ## Operational Effect With domain-bound enforcement, the `S` escape at step 3 is caught: `fs.read`'s composed domain predicate is `path ∈ /data/reports/**`, the argument `/data/reports/../../etc/config` normalizes to `/etc/config`, which fails the predicate, and the MCP server returns a structured `scope_violation` rather than data. `P` receives a typed failure it can reason about, and `S`'s mid-task re-plan is forced to stay within the delegated subtree or escalate. Without it, the escape is invisible: the tool returns success, the sub-agent's reasoning proceeds on out-of-scope data, and the only signal is downstream—an anomalous summary, a data-exfiltration pattern in a later `http.post`, or nothing at all. The failure is *silent by construction* because every local check passed. The second-order effect is on proof composition. When `S` re-delegates to `S2`, the runtime must compose domain predicates as well as capability sets: `domain(C2) = domain(π2) ∘ domain(π1)`, and reject if any retained parameterized capability lacks a domain predicate at any hop. This makes attenuation genuinely monotone in the effective-domain order, closing the composition gap. The guardrail is a schema-level obligation, not a runtime heuristic: **every capability in the AAIF scope lattice must declare whether its domain is intrinsic or parameterized, and parameterized capabilities must carry a mandatory domain predicate in every attenuation proof that retains them.** The enforcement layer's per-hop check becomes `cap ∈ scope ∧ proof_valid ∧ arg ∈ composed_domain(cap)`, and the invariant it enforces is the one that actually matters: effective domain at hop N is a subset of effective domain at hop 0, along the realized invocation chain. ```python from dataclasses import dataclass from typing import Callable, Optional class ScopeEscapeError(RuntimeError): """Raised when an attenuated credential admits an invocation outside its effective domain.""" pass @dataclass(frozen=True) class Capability: name: str parameterized: bool # True => domain is caller-supplied and MUST be bound in proof @dataclass(frozen=True) class AttenuationProof: retained: frozenset[str] # domain predicate per retained parameterized capability; None means "unbound" (illegal) domains: dict[str, Optional[Callable[[object], bool]]] def compose_domains(chain: list[AttenuationProof]) -> dict[str, Callable[[object], bool]]: composed: dict[str, list[Callable[[object], bool]]] = {} for proof in chain: for cap, pred in proof.domains.items(): if pred is not None: composed.setdefault(cap, []).append(pred) return {cap: (lambda arg, ps=ps: all(p(arg) for p in ps)) for cap, ps in composed.items()} def enforce(cap: Capability, argument: object, chain: list[AttenuationProof]) -> None: if not all(cap.name in p.retained for p in chain): raise ScopeEscapeError(f"capability {cap.name!r} dropped in attenuation chain") if cap.parameterized: composed = compose_domains(chain) if cap.name not in composed: # absence of a domain predicate is a hard rejection, not permissive raise ScopeEscapeError( f"parameterized capability {cap.name!r} has no bound domain predicate in proof chain" ) if not composed[cap.name](argument): raise ScopeEscapeError( f"argument {argument!r} escapes composed domain for {cap.name!r}" ) def invoke_fs_read(path: str, chain: list[AttenuationProof]) -> str: cap = Capability("fs.read", parameterized=True) enforce(cap, path, chain) return f"read:{path}" if __name__ == "__main__": import posixpath subtree = AttenuationProof( retained=frozenset({"fs.read", "fs.list"}), domains={"fs.read": lambda p: posixpath.normpath(p).startswith("/data/reports/")}, ) # in-scope call succeeds assert invoke_fs_read("/data/reports/q1.txt", [subtree]).startswith("read:") # escape is caught try: invoke_fs_read("/data/reports/../../etc/config", [subtree]) except ScopeEscapeError as e: print("caught:", e) # unbound parameterized capability is rejected outright try: invoke_fs_read("/data/reports/q1.txt", [AttenuationProof(frozenset({"fs.read"}), {})]) except ScopeEscapeError as e: print("caught:", e) ```