# When must an instance refuse a capability-scoped AAIF credential that verifies but is out of scope for the invoked operation **Date of Record:** 2026 November 28 **Scope:** Applies to cross-org agent invocation where the callee validates an AAIF (Agent Authorization & Invocation Framework) capability token minted by a foreign issuer and must decide whether the token's scope authorizes the *specific* operation requested. Does not apply to same-org delegated tokens, where the issuer and audience share a policy engine, nor to bearer tokens without a scope vector. ## Core Distinction Signature validity and authorization validity are orthogonal. An AAIF capability credential carries (a) a cryptographic envelope — issuer signature, audience binding, expiry, nonce — and (b) a *scope vector*: an ordered set of `(resource, action, constraints)` triples, plus a `delegation_depth` and a `subject_chain`. Most implementations conflate "the token verified" with "the token permits this call." The failure mode this record isolates is **scope-vector under-specification at the delegation boundary**: the callee receives a token whose signature checks out, whose audience matches, and whose top-level scope string contains the requested action — yet the *effective* scope after applying the delegation chain's attenuations does not cover the concrete operation, because the operation's resource identifier resolves differently at the callee than at the issuer. The invariant: **a capability credential authorizes an operation iff the operation's canonical resource identifier, as computed by the callee, is a member of the intersection of all `constraints` sets along the subject chain, evaluated under the callee's own resource-naming resolution.** Signature verification is necessary but not sufficient; scope containment must be re-derived locally, never trusted from the token's own `granted_scope` summary field. ## What Was Observed A cross-org invocation between a research orchestrator (Org A) and a code-execution sandbox (Org B) using AAIF v0.9 credentials. Org A mints a capability for its sub-agent `planner-7`: ``` iss: org-a/control-plane aud: org-b/sandbox-gateway sub_chain: [org-a/planner-7, org-a/exec-broker] scope: [ {resource: "sandbox://exec", action: "run", constraints: {path_prefix: "/work/task-42"}}, ... ] delegation_depth: 1 granted_scope_summary: "sandbox://exec:run" ``` The token verifies at Org B. The `granted_scope_summary` — a convenience field Org A populates for logging — contains `sandbox://exec:run`. The gateway's fast-path check matches the requested action `run` against the summary and admits the call. The sub-agent then invokes `exec` with `cwd=/work/task-42/../task-43/steal`. Org B's sandbox resolves `cwd` through `os.path.realpath`, yielding `/work/task-43/steal`, which is *outside* the `path_prefix` constraint. The constraint was never evaluated because the summary field short-circuited the check. The breach did not require a forged signature or a stolen key. It required the callee to trust the issuer's *rendering* of the scope rather than re-evaluating the scope's *constraints* against the concrete, callee-resolved operation arguments. A second variant surfaced the same day: Org B's resource resolver normalizes `sandbox://exec` to `sandbox://exec/` (trailing slash) before matching, so a token scoped to the no-slash form failed closed on legitimate calls while the summary-based path admitted them — asymmetric failure in both directions from the same root cause. ## Condition of Validity The scope check is sound only when all four of the following hold simultaneously: 1. **Constraint re-evaluation is local.** The callee computes the operation's canonical resource identifier and all constraint predicates (path prefixes, host allowlists, byte limits, time windows) using *its own* resolvers, not values echoed from the token. 2. **The summary field is advisory only.** `granted_scope_summary` and any `scope_string` representation are treated as untrusted display data. Admission decisions read the structured `scope` array exclusively. 3. **Delegation attenuation is intersected, not inherited.** For `delegation_depth > 0`, the effective constraint set is `⋂ constraints` across every entry in `sub_chain`, each evaluated at the point of use. A child token cannot widen a parent's `path_prefix`; a parent's `path_prefix: /work/task-42` intersected with a child's `path_prefix: /work` yields `/work/task-42`. 4. **Normalization is canonicalized before comparison.** Both the constraint literal and the requested resource pass through the same normalization function (realpath resolution, case folding, trailing-slash policy, IDN/percent-decoding) prior to set membership. If the two sides normalize differently, the check is undefined and must fail closed. When any of these is violated, the token is *verifiable but not authorizing*, and the callee must refuse — not warn, not log-and-proceed. ## Decision Boundary The boundary is sharp: **verify signature → re-derive effective scope → evaluate constraints against callee-resolved arguments → admit or refuse.** There is no "partial match" and no "trust the summary if the structured scope is absent." If the structured `scope` array is missing, malformed, or contains a constraint type the callee does not implement, the correct outcome is refusal with a typed error, because an unimplemented constraint is an *unbounded* constraint from the callee's perspective — it cannot prove the operation is inside a predicate it cannot evaluate. Silent pass-through of unknown constraint kinds (`constraints: {region: "eu-west"}` when the callee has no region resolver) is the second-most-common variant of this failure after summary-field trust. The boundary also governs *replay*: a scope check that passed for operation O must not be cached and reused for operation O′ that shares a resource but differs in arguments. Cache keys must include the canonicalized argument vector, not just `(sub, resource, action)`. ## Operational Effect Enforcing local scope re-derivation costs one canonicalization pass and one set-intersection per invocation — sub-millisecond for typical scope vectors — and converts a class of confused-deputy breaches into clean `ScopeViolation` refusals. The observable effect is a rise in *legitimate* refusals during rollout, because issuer-side and callee-side normalizers inevitably disagree on edge cases (trailing slashes, symlinks, Unicode NFC/NFD). These refusals are the system working: each is a normalization mismatch that would otherwise have been an admission. The operational discipline is to treat every such refusal as a bug report against the *normalization contract*, fix the contract, and never widen the matcher to suppress the refusal. The one non-negotiable guardrail: the callee's admission path must be structurally incapable of reading `granted_scope_summary` — not by convention, but by the field being dropped at deserialization before the policy engine sees the token. ```python from dataclasses import dataclass from typing import FrozenSet class ScopeViolation(RuntimeError): """Raised when a verified AAIF credential does not authorize the concrete operation.""" @dataclass(frozen=True) class Constraint: kind: str # "path_prefix" | "host_allowlist" | ... value: str @dataclass(frozen=True) class CapabilityToken: issuer: str audience: str sub_chain: tuple scope: tuple # tuple of (resource, action, frozenset[Constraint]) delegation_depth: int # NOTE: granted_scope_summary is deliberately absent from this dataclass. # It is dropped at deserialization and never reaches the policy engine. _IMPLEMENTED_CONSTRAINT_KINDS = frozenset({"path_prefix"}) def _canonicalize_path(p: str) -> str: import os return os.path.realpath(p) def _evaluate_constraint(c: Constraint, op_args: dict) -> bool: if c.kind == "path_prefix": target = _canonicalize_path(op_args.get("cwd", "")) prefix = _canonicalize_path(c.value) return target == prefix or target.startswith(prefix + "/") raise ScopeViolation(f"unimplemented constraint kind {c.kind!r}: cannot prove containment, failing closed") def authorize(token: CapabilityToken, resource: str, action: str, op_args: dict) -> None: if token.audience != "org-b/sandbox-gateway": raise ScopeViolation(f"audience mismatch: {token.audience!r}") # Re-derive effective scope: intersect constraints across the subject chain. matching = [(r, a, cs) for (r, a, cs) in token.scope if r == resource and a == action] if not matching: raise ScopeViolation(f"no scope entry for {resource}:{action}") # Every matching entry's constraints must all hold (intersection semantics). for (r, a, constraints) in matching: for c in constraints: if not _evaluate_constraint(c, op_args): raise ScopeViolation( f"constraint {c.kind}={c.value!r} not satisfied for {resource}:{action} " f"with args {op_args!r} after local canonicalization" ) # Unimplemented constraint kinds anywhere in the chain are fatal, not skipped. for (_, _, constraints) in matching: for c in constraints: if c.kind not in _IMPLEMENTED_CONSTRAINT_KINDS: raise ScopeViolation(f"unknown constraint {c.kind!r} in effective scope") # Trace of the observed breach, now refused: tok = CapabilityToken( issuer="org-a/control-plane", audience="org-b/sandbox-gateway", sub_chain=("org-a/planner-7", "org-a/exec-broker"), scope=(("sandbox://exec", "run", frozenset({Constraint("path_prefix", "/work/task-42")})),), delegation_depth=1, ) authorize(tok, "sandbox://exec", "run", {"cwd": "/work/task-42/../task-43/steal"}) # -> ScopeViolation: constraint path_prefix='/work/task-42' not satisfied ... ```