# What structural signals indicate capability-token scope creep during AAIF credential re-delegation across agent hops **Date of Record:** 2026 November 26 **Scope:** Applies to multi-hop agent systems where an orchestrator delegates a scoped capability token (AAIF VC) to a sub-agent, which may itself re-delegate. Does not cover single-hop token issuance from a human principal, nor symmetric-key bearer tokens without a delegation chain. ## Core Distinction A scoped capability token is not a permission set; it is a *proof of attenuation*. The AAIF model assumes that each hop either preserves or narrows the scope carried in the credential's `caveats` field, and that the verifier can reconstruct the full delegation chain to confirm monotonic narrowing. The failure mode is not "a token was stolen" or "a signature was forged." It is **scope creep through caveat accumulation across re-delegation**, where each hop adds a caveat that is locally satisfiable but the *conjunction* of caveats from different hops is evaluated against a different resource namespace than the one the root principal intended. The structural signal is subtle: every individual credential in the chain verifies correctly, every signature is valid, and the final scope appears to be a subset of the parent's scope *as written*. The creep is invisible unless the verifier normalizes resource identifiers across hops before intersecting caveat sets. Two hops can each hold a caveat like `resource: "s3://bucket/reports/*"` and `resource: "s3://bucket/reports/../secrets/*"` — path traversal that survives naive string-prefix subset checks but resolves to a scope neither hop's issuer intended. ## What Was Observed An orchestrator agent (A) held a root capability for a research pipeline: `read` on `s3://corpus/raw/*` and `write` on `s3://corpus/derived/*`. It delegated to a retrieval agent (B) a narrowed token: `read` on `s3://corpus/raw/2024/*`. B, needing to hand off extraction work, re-delegated to a worker (C) with a caveat it constructed by *concatenating* its own scope with a task-derived path: `read` on `s3://corpus/raw/2024/*` **and** `read` on `s3://corpus/raw/2024/../../../derived/internal/*`. The worker's verifier checked: 1. C's credential signature — valid. 2. B's signature over the delegation — valid. 3. A's root signature — valid. 4. Subset check: `is_subset(C.scope, B.scope)` — implemented as string-prefix match on the literal caveat strings. `s3://corpus/raw/2024/../../../derived/internal/*` does not start with `s3://corpus/raw/2024/*`, so the check *should* have failed. It passed because the verifier normalized paths *after* the subset check rather than before. The subset check ran on raw strings; the normalization to `s3://corpus/derived/internal/*` happened only at enforcement time, when the storage layer resolved the path. The result: C read files under `derived/internal/`, which B never had `read` access to and A had only `write` access to. The credential chain was cryptographically sound and semantically broken. ## Condition of Validity This failure is bounded by a single invariant: **the subset relation must be evaluated on the canonical form of each caveat, and canonicalization must be total (no two distinct strings may canonicalize to forms that compare differently under subset and under enforcement).** If the verifier's subset predicate and the enforcer's resource resolver use different canonicalization functions, the gap between them is the attack surface. The invariant holds only when: - Every caveat's resource expression is normalized (path resolution, case folding, unicode NFC, percent-decoding) *before* the subset intersection. - The subset predicate is defined over the same algebra the enforcer uses — not over string prefixes. - Caveat conjunction across hops is computed as a set intersection over canonical resource sets, not as a list append. When any of these is violated, the chain remains valid but the scope is no longer monotonically narrowing. This is the boundary: **cryptographic validity is orthogonal to scope monotonicity**, and systems that conflate them will accept creeping delegations. ## Decision Boundary The operational decision is: *at which hop do you reject?* There are three defensible boundaries, and the choice determines blast radius. 1. **Reject at issuance (B's side).** B refuses to sign a delegation whose canonical scope is not a subset of its own canonical scope. Cheapest, but B must trust its own canonicalizer — and a compromised B simply skips the check. 2. **Reject at verification (C's side).** C canonicalizes the entire chain and intersects. This is the only boundary that a malicious intermediate cannot bypass, because C does the work. It is also the most expensive: O(hops × caveats) canonicalization per request. 3. **Reject at enforcement (storage layer).** The enforcer resolves the path and checks against the intersected canonical set. Correct only if the enforcer is the *same* canonicalizer the verifier used — which is exactly the invariant above. The decision boundary to record: **verification-time canonical intersection is mandatory; issuance-time checks are advisory only.** A system that relies solely on hop-1 checks has no defense against a compromised or buggy intermediate. A system that canonicalizes only at enforcement has no defense against a subset check that passed on non-canonical strings. ## Operational Effect The practical consequence is that AAIF delegation chains must carry, alongside each credential, a *canonical scope digest* — a hash over the sorted, normalized resource set — and each hop must recompute and compare it against the parent's digest before signing. The digest makes the subset relation a single equality check over a committed value, closing the canonicalization gap because both sides commit to the same normalization function's output. Without this, the failure is silent and compounding: each hop's scope appears valid in isolation, the chain verifies, and the only signal is a resource access that succeeds when it should have been denied — visible only in audit logs that compare *intended* root scope against *realized* access, not against the credential's stated caveats. The structural signal to monitor is a divergence between the credential's declared scope digest and the digest recomputed from the enforcer's resolved resource set on each access. Any nonzero divergence is scope creep, regardless of signature validity. ```python import hashlib from dataclasses import dataclass from typing import FrozenSet class ScopeCanonicalizationError(RuntimeError): """Raised when a delegation chain's canonical scope digests diverge.""" @dataclass(frozen=True) class CapabilityToken: issuer: str subject: str canonical_resources: FrozenSet[str] # already normalized by the issuer scope_digest: str # sha256 over sorted canonical set parent_digest: str | None # digest of the token this one attenuates def compute_scope_digest(canonical_resources: FrozenSet[str]) -> str: payload = "\n".join(sorted(canonical_resources)).encode("utf-8") return hashlib.sha256(payload).hexdigest() def verify_delegation_chain(chain: list[CapabilityToken]) -> None: """ Enforce: each token's canonical scope is a subset of its parent's, and the digest chain is internally consistent. Canonicalization is assumed already performed by each issuer; this verifier only checks the committed digests and the subset relation over canonical sets. """ if not chain: raise ScopeCanonicalizationError("empty delegation chain") root = chain[0] if root.parent_digest is not None: raise ScopeCanonicalizationError( f"root token {root.issuer} must not declare a parent_digest" ) if compute_scope_digest(root.canonical_resources) != root.scope_digest: raise ScopeCanonicalizationError( f"root token {root.issuer} scope_digest does not match canonical set" ) for parent, child in zip(chain, chain[1:]): if child.parent_digest != parent.scope_digest: raise ScopeCanonicalizationError( f"child {child.issuer}->{child.subject} parent_digest " f"{child.parent_digest!r} != parent scope_digest {parent.scope_digest!r}" ) if compute_scope_digest(child.canonical_resources) != child.scope_digest: raise ScopeCanonicalizationError( f"child {child.issuer}->{child.subject} scope_digest does not " f"match its own canonical set" ) # Subset over canonical sets — NOT string prefixes. if not child.canonical_resources.issubset(parent.canonical_resources): leaked = child.canonical_resources - parent.canonical_resources raise ScopeCanonicalizationError( f"scope creep at hop {child.issuer}->{child.subject}: " f"resources {sorted(leaked)} not covered by parent {parent.issuer}" ) ```