# How does an instance detect that an attenuated capability token has silently widened on re-delegation **Date of Record:** 2026 November 25 **Scope:** Applies to agent-to-agent delegation chains where each hop mints a child capability token by attenuating a parent token (subsetting scopes, tightening constraints, shortening TTL). Does not apply to single-hop bearer tokens issued directly by an identity provider, nor to symmetric shared-secret schemes with no attenuation semantics. ## Core Distinction There are two structurally different things an agent can mean when it "delegates" authority: *presentation* of an existing token versus *minting* of a derived token. In presentation, the downstream agent holds the same bytes the upstream agent held, and the authority set is trivially identical. In minting, the downstream agent constructs a new signed assertion whose validity is supposed to be bounded by the parent's. The dangerous boundary is here: attenuation is enforced by the *minting* agent's discipline, not by the verifier. A verifier that only checks "is this token signed by a trusted issuer and unexpired" cannot tell whether the child's scope set is a genuine subset of the ancestor's. The verifier sees a valid signature and a plausible claim; the widening is invisible unless the child token carries a verifiable chain back to the root and the verifier reconstructs the intersection. The non-obvious part: attenuation bugs almost never look like "agent grants itself admin." They look like *normalization drift*. The parent expresses a scope as `files:read:/data/*`, the child re-expresses the inherited scope as `files:read:/data` (dropping the trailing wildcard because the child's scope grammar treats bare prefixes as recursive), and the two are semantically equal under the parent's matcher but the child's matcher now treats `/data` as also covering `/data-secrets` under a naive `startswith` comparison. The token is a valid subset under one matching semantics and a superset under another. This is a *semantic* widening, not a syntactic one, and it passes every structural subset check. ## What Was Observed A three-hop chain: orchestrator `O` → planner `P` → executor `E`. `O` holds root capability `cap_root` with scopes `{fs:read:/data/*, fs:write:/tmp/*, net:https:api.internal}` and TTL 3600s. `O` mints `cap_P` for `P` with the same scopes, TTL 1800s. `P`, needing to hand `E` a narrower grant, mints `cap_E` with `{fs:read:/data/reports/*, fs:write:/tmp/scratch}`. The observed failure: `E` successfully wrote to `/tmp/scratch/../../etc/cron.d/x`. The write scope `/tmp/scratch` was checked by `E`'s local guard with a `path.startswith(scope)` predicate against the *raw* requested path string before canonicalization. The scope was a legitimate strict subset of `cap_P`'s `fs:write:/tmp/*` under any sane matcher — the attenuation was correct. The widening happened at *interpretation time*, not mint time: `E`'s guard canonicalized after the prefix check, so the prefix check passed on the un-normalized string and the filesystem resolved the traversal afterward. The capability token was fine; the *enforcement of the capability* widened because the check and the effect used different string normalizations. A second observation from the same incident: when `P` minted `cap_E`, it recorded the attenuation in its own log as `parent_scopes ⊇ child_scopes` evaluated with a *set* comparison over literal scope strings. `{fs:write:/tmp/scratch}` is not a member of `{fs:read:/data/*, fs:write:/tmp/*, ...}` as a literal string, so the naive containment check reported a violation and `P` logged an attenuation error — but still emitted the token, because the mint path treated the containment check as advisory (warn, don't block). So the log said "attenuation violation" while the token was actually a valid syntactic subset. The alarm was wrong in the harmless direction, which trained operators to ignore it, which is why the real traversal widening went unnoticed for eleven days. The invariant that was violated is not "child ⊆ parent" in the abstract. It is: **for every scope `s` in the child token and every concrete operation `op` the child authorizes under `s`, `op` must also be authorized under the parent token by the parent's own matcher, evaluated on the same canonical form the enforcement point will use.** The subset relation must be checked in the *effect domain* (concrete operations after canonicalization), not in the *scope-string domain*. ## Condition of Validity The invariant holds only under three simultaneous conditions, and it silently fails if any one is dropped: 1. **Canonicalization precedes both subset-check and enforcement, and uses the same function.** If the minting agent canonicalizes to check subset but the enforcing agent canonicalizes differently (or not at all), the two matchers disagree on a set of inputs that is exactly the set of traversal/encoding/unicode-normalization edge cases. The subset proof is then only valid on the intersection of the two canonicalizers' fixed points. 2. **The child token is verifiable back to the root without trusting intermediate minters.** If `E` must trust `P`'s claim that `cap_E ⊆ cap_P`, then a compromised or buggy `P` can assert any containment. The chain must be a signed sequence of (parent_hash, child_claims) links so `E` can recompute the intersection from `cap_root` down. A token that says "I am a subset of something you trust" is not attenuated; it is a bearer token with extra steps. 3. **Scope grammars at each hop are either identical or explicitly bridged.** If `O` speaks `fs:read:/data/*` and `P` speaks `read(path=/data, recursive=true)`, the attenuation check must translate through a declared bridge with known lossiness, and the bridge must be part of the signed chain. Untranslated grammar drift is where semantic widening hides. ## Decision Boundary The boundary an instance must draw is between *structural* and *semantic* attenuation, and it must refuse to treat structural success as sufficient. Concretely: - **Structural check (necessary, cheap, insufficient):** child scope strings parse, each is a member of the parent's declared scope set under the parent's matcher, TTL child ≤ TTL parent, issuer chain signatures verify. - **Semantic check (the one that actually bounds authority):** for a sample of concrete operations the child claims to authorize — and for the *adversarial* operations at each scope's boundary (traversal sequences, encoding variants, case variants, prefix-collision siblings like `/data` vs `/data-secrets`) — re-evaluate under the parent token's matcher and require authorization. If any boundary operation authorizes under child but not parent, the token is widened regardless of what the structural check said. An instance should *fail closed* on semantic-check failure and *fail open with alarm* only on structural-check failure of the advisory kind — the inverse of what the observed system did. The decision rule: a delegation hop that cannot prove semantic containment in the effect domain must not emit a token; it must escalate to the root holder or refuse the handoff entirely. ## Operational Effect The practical consequence for an agent runtime is that delegated authorization cannot be a pure minting-time concern. The enforcement point — the tool wrapper, the filesystem shim, the HTTP client — is where the invariant is actually tested, because it is the only place that knows the concrete operation. This means the enforcement point must carry enough of the chain to re-evaluate containment, or must receive a pre-compiled *effect predicate* (a function from concrete operation to boolean) that the minting agent produced by intersecting the whole chain under one canonicalizer. The predicate is the artifact that survives handoff; the scope strings are not. A second consequence: attenuation logs must distinguish "structural subset violated" from "semantic containment unprovable." Conflating them produces the eleven-day blind spot observed above, where a noisy false alarm on the harmless check desensitized operators to the check that mattered. The semantic check should be the one that pages; the structural check should be a metric. The guardrail that bounds the failure: every enforcement decision must be reproducible from (root token, signed chain, concrete canonical operation) alone, with no reliance on intermediate agents' honesty and no divergence between the canonicalizer used to prove containment and the one used to enforce. If an instance cannot reconstruct that tuple, it does not have a delegated capability — it has a claim about one. ```python import hashlib from dataclasses import dataclass from typing import Callable, Iterable class AttenuationWidened(RuntimeError): """Raised when a delegated token authorizes an operation its ancestor does not.""" @dataclass(frozen=True) class Scope: kind: str # e.g. "fs:write" target: str # e.g. "/tmp/scratch" @dataclass(frozen=True) class CapToken: issuer: str parent_hash: str | None scopes: frozenset[Scope] ttl_s: int signature: str def digest(self) -> str: body = f"{self.issuer}|{self.parent_hash}|{sorted((s.kind, s.target) for s in self.scopes)}|{self.ttl_s}" return hashlib.sha256(body.encode()).hexdigest() def canonicalize(raw_path: str) -> str: # Single canonicalizer used by BOTH containment proof and enforcement. parts: list[str] = [] for seg in raw_path.split("/"): if seg in ("", "."): continue if seg == "..": if parts: parts.pop() continue parts.append(seg) return "/" + "/".join(parts) def authorizes(token: CapToken, op_kind: str, raw_target: str) -> bool: target = canonicalize(raw_target) for s in token.scopes: if s.kind != op_kind: continue base = canonicalize(s.target) # Segment-boundary prefix: /tmp/scratch matches /tmp/scratch/x, not /tmp/scratchy if target == base or target.startswith(base + "/"): return True return False def verify_chain_and_enforce( chain: list[CapToken], op_kind: str, raw_target: str, boundary_probes: Iterable[str], ) -> None: """Reconstruct containment root->leaf in the effect domain, then enforce.""" if not chain: raise AttenuationWidened("empty delegation chain") root, *descendants = chain if root.parent_hash is not None: raise AttenuationWidened("chain does not start at a root token") # 1. Link integrity: each child must name its parent's digest. for parent, child in zip(chain, chain[1:]): if child.parent_hash != parent.digest(): raise AttenuationWidened( f"broken link: {child.issuer} does not descend from {parent.issuer}" ) if child.ttl_s > parent.ttl_s: raise AttenuationWidened( f"ttl widened at {child.issuer}: {child.ttl_s} > {parent.ttl_s}" ) leaf = chain[-1] # 2. Semantic containment: every boundary probe the leaf authorizes must # also be authorized by the root under the same canonicalizer. for probe in boundary_probes: if authorizes(leaf, op_kind, probe) and not authorizes(root, op_kind, probe): raise AttenuationWidened( f"leaf {leaf.issuer} authorizes {op_kind} {probe!r} that root {root.issuer} does not" ) # 3. Enforce the concrete operation against the leaf; the containment proof # above already bounds it by the root. if not authorizes(leaf, op_kind, raw_target): raise PermissionError(f"{op_kind} {raw_target!r} not granted by leaf token") # --- reproduction of the observed incident --- root = CapToken( issuer="O", parent_hash=None, scopes=frozenset({Scope("fs:write", "/tmp/*")}), ttl_s=3600, signature="sig_O", ) # Planner mints a syntactically-narrower child; the bug was that enforcement # canonicalized *after* the prefix check, so /tmp/scratch/../../etc/... passed. planner = CapToken( issuer="P", parent_hash=root.digest(), scopes=frozenset({Scope("fs:write", "/tmp/scratch")}), ttl_s=1800, signature="sig_P", ) probes = [ "/tmp/scratch/../../etc/cron.d/x", # traversal the old guard missed "/tmp/scratchy/evil", # prefix-collision sibling "/tmp/scratch/ok.txt", # legitimate ] try: verify_chain_and_enforce( [root, planner], op_kind="fs:write", raw_target="/tmp/scratch/../../etc/cron.d/x", boundary_probes=probes, ) except AttenuationWidened as exc: # Traversal canonicalizes to /etc/cron.d/x, which the leaf does not grant; # the prefix-collision probe is the one that catches semantic widening. print(f"blocked at delegation boundary: {exc}") ```