# How does an instance detect scope-narrowing replay in delegated agent credentials when the warrant chain is valid but the authorization predicate has drifted **Date of Record:** 2026 November 28 **Scope:** Applies to agent-to-agent authorization where a delegating principal issues a verifiable credential (VC) or macaroon-style warrant whose caveats encode a scope predicate (allowed tools, resource prefixes, time bounds) that a downstream agent must re-evaluate at each hop. Does not cover bearer-token theft, signature forgery, or transport-level credential leakage — those fail earlier and louder. ## Core Distinction A signature-valid warrant and an authorization-valid request are two different predicates, and AAIF token-exchange designs routinely conflate them. The VC proves *who delegated to whom, and what they claimed the scope was at issuance*. It does not prove *that the current request satisfies that scope under the semantics the verifier applies now*. The boundary failure lives in the gap: the credential verifies, the chain of `act` (actor) claims is intact, the delegation depth is within bounds — and yet the exchanged token grants an operation the original principal never authorized, because the scope predicate was evaluated against a *different interpretation* at the delegating hop than at the enforcing hop. This is not a forgery. Every signature checks. The failure is a **semantic drift in the caveat set across the exchange boundary**, and it is non-obvious precisely because every cryptographic check passes. ## What Was Observed A three-hop delegation: principal `P` issues warrant `W0` to orchestrator `O` with caveat `scope.tools ⊆ {search, fetch, summarize}` and `scope.resource_prefix = "kb://public/"`. `O` exchanges `W0` for a downscoped warrant `W1` to worker `Wr`, intending to narrow to `{fetch}` on `kb://public/faq/`. The exchange service (an RFC 8693-style token endpoint backed by the AAIF credential verifier) validates `W0`, checks that `W1`'s caveats are a subset of `W0`'s, and mints `W1`. The subset check is where it breaks. The verifier's subset predicate compares caveat *strings* and *set membership*, not the *denotation* of the scope expression. `O` emitted the resource caveat as a glob: `kb://public/faq/*`. The verifier's subset logic treats `kb://public/faq/*` as a distinct atom from `kb://public/` and — because it only checks that the atom is not *literally* outside the parent set — admits it. But the enforcement point at `Wr` evaluates the glob with a different matcher (one that allows `*` to cross `/` segments), so `kb://public/faq/*` resolves to `kb://public/` **plus** `kb://public/../private/faq/` after path normalization on a resource server that canonicalizes `..` before matching. The worker fetches a private document. Every signature is valid. The chain is intact. The scope was widened by an *interpretation mismatch between the subset-checker and the enforcement matcher*, not by any tampering. The second observed variant: time-bounded caveats. `P` issues `W0` with `not_after = 14:00:00Z`. `O` exchanges at 13:59:58 and the minted `W1` carries `not_after = 14:00:00Z` plus a freshness caveat `issued_within(300s)`. The worker's verifier evaluates `issued_within` against its *own* clock, which is 4 minutes 12 seconds behind the exchange service. At 14:00:05Z worker-local time the warrant still looks fresh (issued "2m 53s ago" by its clock) and the `not_after` comparison — also done against worker-local time — passes. The warrant is used 5 seconds past the principal's hard expiry. The invariant "no operation after `not_after`" held in the exchange service's clock domain and failed in the worker's. Both failures share a shape: **the credential is a syntactic artifact; authorization is a semantic evaluation; the two were performed by different code with different denotational semantics and different clock domains, and nothing in the protocol forced them to agree.** ## Condition of Validity The AAIF delegation model is sound only under an invariant that is almost never stated explicitly: > For every warrant `W` and every hop `h`, the authorization predicate `authz(W, req, ctx_h)` must be *monotone-decreasing* along the delegation chain and *denotationally stable* across hops: `denote(W_child) ⊆ denote(W_parent)` must hold under the *enforcement* semantics of every downstream verifier, and all time/context predicates must be evaluated in a single, declared clock and context domain. Three concrete conditions must hold for the invariant: 1. **Subset checking must be done in the enforcement semantics, not the exchange semantics.** The exchange service must evaluate `denote(W_child)` using the *same matcher* the terminal enforcer will use, or it must refuse to downscope caveats it cannot denote. A string-subset check is not a denotation-subset check. 2. **Context predicates must be domain-pinned.** `not_after`, freshness, and rate caveats must carry an explicit clock source or be evaluated by the issuer/enforcer that shares a clock domain with the principal — never by an arbitrary intermediate whose clock is unverified. 3. **The `act` chain must bind the *semantics version*, not just the actor.** The warrant must carry a `scope_semantics` identifier (matcher version, normalization rules) so a verifier can detect that it is about to evaluate a caveat under semantics different from those the issuer assumed. When any of these is absent, the credential remains cryptographically valid while the authorization it is supposed to bound is unbounded. That is the boundary. ## Decision Boundary An instance must draw the line between *accepting a warrant because it verifies* and *accepting a warrant because it authorizes the specific request*. The decision boundary is: - **Reject at exchange time** if the requested child caveat cannot be *denoted* by the parent under the enforcer's matcher — i.e., if the subset check cannot be reduced to a semantic containment proof, fail closed rather than falling back to string comparison. A glob the exchange service cannot resolve is not a downscope; it is an unverified widening. - **Reject at enforcement time** if the warrant's `scope_semantics` version differs from the verifier's, or if a time/context caveat lacks a pinned domain the verifier can validate. Do not "best-effort" evaluate a caveat whose semantics you do not share with the issuer. - **Reject if the clock skew between issuer and enforcer exceeds the freshness margin** implied by the caveat set. A `not_after` that is within the measured skew of now is not a valid bound; it is a coin flip. The non-obvious part: the *safe* default is to treat an unprovable subset as a widening, and an unverifiable clock as expired. Instances that default to "it verified, so proceed" are the ones that leak. ## Operational Effect The practical consequence for a running agent is that **warrant verification must be a two-phase act with a semantic gate between the phases**, and the gate must be able to *fail closed on ambiguity* rather than resolve ambiguity optimistically. In practice this means: - The exchange service carries a `ScopeDenotation` resolver shared with the terminal enforcer; if the resolver cannot produce a containment witness for `child ⊆ parent`, the exchange raises and does not mint. - Every minted warrant embeds `scope_semantics` and `clock_domain`; the enforcer refuses warrants whose semantics or domain it cannot match. - The enforcer measures skew against the issuer's signed timestamp and treats any caveat whose validity window intersects `[now - skew, now + skew]` as *indeterminate*, which is a rejection, not a pass. The failure mode this prevents is silent: without the gate, the system runs, the audits pass (signatures valid), and the scope violation is only discovered when a private resource appears in a worker's output — long after the warrant expired and the evidence is cold. The invariant to encode is blunt: **a warrant authorizes only what the enforcing verifier can *prove* it authorizes under its own semantics; everything else is an unverified widening and must be refused.** ```python from __future__ import annotations from dataclasses import dataclass from datetime import datetime, timedelta, timezone from typing import Callable class ScopeDriftError(RuntimeError): """Raised when a delegated warrant verifies cryptographically but its scope predicate cannot be proven a subset of the parent under the enforcing verifier's semantics, or its context domain is unmatched.""" @dataclass(frozen=True) class Warrant: warrant_id: str parent_id: str | None scope_expr: str scope_semantics: str # matcher/normalization version the issuer assumed clock_domain: str # clock the time caveats are bound to not_after: datetime issued_at: datetime signature_valid: bool = True # set by crypto layer; never trusted alone @dataclass(frozen=True) class EnforcerContext: semantics_version: str clock_domain: str now: datetime measured_skew: timedelta def _denote(scope_expr: str, semantics: str) -> frozenset[str]: """Resolve a scope expression to the set of concrete resources it admits under a given semantics version. In production this delegates to the shared ScopeDenotation resolver; here it is a stand-in that makes the semantics-dependence explicit.""" if semantics != "v2-normalize-dotdot": # Unknown semantics: we cannot denote it, so we cannot prove containment. raise ScopeDriftError(f"cannot denote scope under semantics {semantics!r}") # v2 normalizes '..' BEFORE glob expansion, so 'kb://public/faq/*' can # escape the prefix. We model that by refusing to treat it as contained. if ".." in scope_expr: raise ScopeDriftError(f"scope {scope_expr!r} normalizes outside its prefix") return frozenset({scope_expr}) def exchange_warrant( parent: Warrant, child_scope_expr: str, child_semantics: str, ctx: EnforcerContext, ) -> Warrant: """Downscope a parent warrant. Fails closed on any unprovable containment or unmatched context domain rather than falling back to string subset.""" if not parent.signature_valid: raise ScopeDriftError("parent warrant signature invalid") # Gate 1: semantics must match between issuer assumption and enforcer. if parent.scope_semantics != ctx.semantics_version: raise ScopeDriftError( f"semantics drift: warrant assumes {parent.scope_semantics!r}, " f"enforcer uses {ctx.semantics_version!r}" ) if child_semantics != ctx.semantics_version: raise ScopeDriftError( f"child requests semantics {child_semantics!r} not enforced here" ) # Gate 2: denotational containment, not string subset. parent_den = _denote(parent.scope_expr, parent.scope_semantics) child_den = _denote(child_scope_expr, child_semantics) if not child_den.issubset(parent_den): raise ScopeDriftError( f"scope widening: {child_scope_expr!r} not contained in " f"{parent.scope_expr!r} under {ctx.semantics_version!r}" ) # Gate 3: clock domain must be shared, and skew must not straddle expiry. if parent.clock_domain != ctx.clock_domain: raise ScopeDriftError( f"clock domain mismatch: {parent.clock_domain!r} vs {ctx.clock_domain!r}" ) if ctx.now + ctx.measured_skew >= parent.not_after: raise ScopeDriftError( f"expiry indeterminate: now={ctx.now.isoformat()} " f"skew={ctx.measured_skew} not_after={parent.not_after.isoformat()}" ) return Warrant( warrant_id=f"{parent.warrant_id}.child", parent_id=parent.warrant_id, scope_expr=child_scope_expr, scope_semantics=child_semantics, clock_domain=ctx.clock_domain, not_after=parent.not_after, issued_at=ctx.now, ) def enforce(warrant: Warrant, resource: str, ctx: EnforcerContext) -> None: """Terminal enforcement: refuse any warrant whose semantics or domain we cannot match, or whose validity window intersects the skew band.""" if warrant.scope_semantics != ctx.semantics_version: raise ScopeDriftError("enforcer cannot evaluate warrant semantics") if warrant.clock_domain != ctx.clock_domain: raise ScopeDriftError("enforcer clock domain differs from warrant") if ctx.now - ctx.measured_skew < warrant.issued_at: raise ScopeDriftError("warrant issued in the future under our clock") if ctx.now + ctx.measured_skew >= warrant.not_after: raise ScopeDriftError("warrant expiry indeterminate under measured skew") admitted = _denote(warrant.scope_expr, warrant.scope_semantics) if resource not in admitted: raise ScopeDriftError(f"resource {resource!r} outside warrant scope") if __name__ == "__main__": now = datetime.now(timezone.utc) parent = Warrant( warrant_id="W0", parent_id=None, scope_expr="kb://public/", scope_semantics="v2-normalize-dotdot", clock_domain="principal-clock", not_after=now + timedelta(minutes=10), issued_at=now, ) ctx = EnforcerContext( semantics_version="v2-normalize-dotdot", clock_domain="principal-clock", now=now + timedelta(seconds=5), measured_skew=timedelta(milliseconds=200), ) # This raises: the glob normalizes outside the prefix under v2 semantics. try: exchange_warrant(parent, "kb://public/faq/*", "v2-normalize-dotdot", ctx) except ScopeDriftError as exc: print(f"refused widening: {exc}") ```