# Why does an instance accept a delegated capability grant whose mTLS binding no longer covers the presenting workload? **Date of Record:** 2026 November 26 **Scope:** Applies to cross-org agent federation where a Subject Agent (SA) obtains an OAuth 2.0 Token Exchange (RFC 8693) delegated grant from its home Authorization Server (AS-A) and presents it to a Resource Agent (RA) in a foreign org guarded by AS-B, with mTLS-bound `cnf` (RFC 8705) as the proof-of-possession mechanism. Does not cover bearer-token-only federation, SPIFFE-only identity, or single-org deployments where the same AS issues and validates. ## Core Distinction The failure is not "a stolen token was replayed." It is a **binding-scope divergence between the token's `cnf.x5t#S256` thumbprint and the *workload identity* actually terminating the TLS session at the resource agent**, which arises legitimately during a delegated chain and is then silently laundered by the resource agent's mTLS terminator. Two things get conflated by every party in the chain: 1. **The certificate that authenticated the token request** (SA's workload cert, presented to AS-A during exchange). 2. **The certificate that terminates the TLS session** (often a sidecar, a gateway, or a *different* SA replica that inherited the token from the first). RFC 8705 says the RA must verify that the cert bound in `cnf.x5t#S256` equals the cert used to authenticate *this* request. In a single-org mesh with a single mTLS terminator per pod, these are the same object. In cross-org delegation they are almost never the same object, and the RA's terminator is the component that decides whether to notice. ## What Was Observed A three-org federation (A → B → C) with a delegated grant. SA-A exchanges a user-scoped token for an actor-token bound to SA-A's workload cert `T_A`. SA-A hands the token to a *peer replica* SA-A' for load-balancing reasons (a routine handoff, not an attack). SA-A' presents the token to RA-B. RA-B's ingress is a service-mesh sidecar that terminates mTLS with SA-A's *namespace* cert `T_ns`, not `T_A`. The sidecar forwards the request over plaintext localhost to RA-B's application, which calls AS-B's introspection endpoint. Observed trace: - AS-B introspection returns `active: true` and echoes `cnf: {x5t#S256: }`. - RA-B's application compares `cnf.x5t#S256` against the cert *it* sees. It sees nothing — the sidecar stripped the client cert and did not populate `X-Forwarded-Client-Cert` (XFCC) because the header was not in the allowlist. - RA-B's application falls back to a permissive check: "if no client cert is presented, and introspection is active, accept." This fallback was written for a legacy path where RA-B accepted bearer tokens from a trusted internal caller. - The grant is accepted. The delegated capability (e.g., `orders:write` scoped to user U) is exercised by SA-A', which was never the binding subject. The failure is not that SA-A' is malicious. It is that **the binding invariant `cnf.x5t#S256 == presented_cert_thumbprint` was never evaluated at the point where it could be enforced**, and the RA's own fallback path converted "unverifiable" into "verified." A second, sharper variant: the delegated grant is *re-delegated*. SA-A issues a sub-token to SA-A'' (a sub-agent) with `act: {sub: SA-A}` and a *new* `cnf` bound to `T_A''`. AS-A permits this because RFC 8693 §4.1 allows `actor_token` chaining. But AS-B's introspection cache is keyed on the *outer* token's `jti` and does not re-read `cnf` after the first introspection. SA-A'' presents the re-delegated token; RA-B's cache returns the *original* `cnf` (bound to `T_A`), compares against `T_A''`, mismatch, but the mismatch is logged at `WARN` and the request proceeds because the cache-hit path skips the binding check entirely. The result: a token whose binding was checked exactly once, at issuance, and never again. ## Condition of Validity The invariant that must hold for a delegated grant to be safe is: > For every request that exercises a delegated capability, the RA must evaluate `thumbprint(cert_authenticating_this_request) == cnf.x5t#S256` against the *most recent* introspection result for that `jti`, and must treat "no cert available at the application layer" as a hard failure, not a fallback. This holds only when all of the following are true: 1. **The mTLS terminator propagates the client cert identity to the application** (via XFCC, a Unix socket peer credential, or a signed header the app trusts). If the terminator is a sidecar that does not propagate, the app cannot evaluate the invariant. 2. **The introspection cache does not short-circuit the binding check.** Caching `active: true` is safe; caching the *decision* (including the binding comparison) is not, because the binding is per-request, not per-token. 3. **Re-delegation produces a new `cnf` and a new `jti`, and the RA re-introspects on any `jti` it has not seen.** RFC 8693 allows `actor_token` chaining but does not mandate that the RA re-validate the chain; the RA must do so itself. 4. **The delegated grant's `scope` is a subset of the actor's scope, not the subject's.** A common bug: SA-A delegates `orders:write` to SA-A'' because the *user* has it, even though SA-A's own grant is `orders:read`. The RA sees `orders:write` and accepts because the token is structurally valid. The scope-narrowing invariant (`scope(delegated) ⊆ scope(actor) ∩ scope(subject)`) is not enforced by AS-A unless explicitly configured. If any of 1–4 fails, the grant is "valid" in the OAuth sense and "unsafe" in the federation sense. ## Decision Boundary The boundary is not "trust the token" vs. "don't." It is **where the binding check lives**: - **At the terminator (sidecar/gateway):** the terminator compares the client cert thumbprint to `cnf` before forwarding. Fast, but the terminator must parse the token, which couples it to the token format and the AS's key set. This is where most meshes put it, and where most meshes get it wrong because the terminator treats "token present but `cnf` absent" as "not bound, allow." - **At the application (after introspection):** the app receives the cert identity via XFCC and compares. Correct but requires the app to trust the XFCC header, which is only safe if the terminator is the *only* path to the app (no direct pod access, no other ingress). - **At the AS (during introspection):** the AS cannot see the presenting cert; it can only echo `cnf`. This is a *data* check, not an *enforcement* check. It is necessary but never sufficient. The decision boundary is: **the RA must enforce the binding at the layer that has both the cert identity and the token, and must fail closed when either is missing.** A terminator that forwards without the cert, or an app that accepts without the cert, is outside the boundary and must be treated as a bearer-token endpoint regardless of what the token claims. A second boundary: **the delegated grant's `act` chain must be validated for depth and for scope monotonicity at every hop.** RFC 8693 does not bound `act` chain depth. A chain A → A' → A'' → … can launder a narrow grant into a broad one if any hop's AS is misconfigured. The RA must reject chains deeper than a configured `max_act_depth` and must reject any token whose `scope` is not a subset of the *immediate* actor's scope, not just the root subject's. ## Operational Effect The observable effect is a **silent authority escalation that looks like a normal request**. Logs show `200 OK`, introspection `active: true`, and a `WARN` on the binding mismatch that nobody reads. The escalation is bounded by the RA's own authorization logic (the user's scope still limits what `orders:write` can touch), so it does not immediately produce cross-tenant data loss — it produces *cross-workload* authority: SA-A' can do what SA-A was authorized to do, and SA-A'' can do what SA-A' was authorized to do, and the audit trail attributes all of it to the user U with no record of which workload actually acted. The remediation is structural, not a patch: 1. Terminators must be configured to **fail closed** on missing client cert (return 401, not forward). 2. Introspection caches must cache `active` and `cnf` but **never the binding decision**; the binding comparison is per-request. 3. Re-delegation must mint a new `jti` and the RA must re-introspect on unseen `jti`; the `act` chain must be validated for depth and scope monotonicity. 4. The RA must log the *presenting workload identity* (cert thumbprint) alongside the `sub` and `act`, so that a post-hoc audit can reconstruct which workload exercised which grant. Without 1–4, the federation is a bearer-token system wearing an mTLS costume, and the `cnf` claim is decorative. ```python import hashlib from dataclasses import dataclass from typing import Optional class DelegatedGrantBindingError(RuntimeError): """Raised when a delegated capability grant's mTLS binding cannot be verified against the presenting workload at the resource agent.""" pass @dataclass(frozen=True) class IntrospectionResult: active: bool jti: str cnf_x5t_s256: Optional[str] # thumbprint bound at issuance scope: frozenset[str] act_chain: tuple[str, ...] # outermost actor first @dataclass(frozen=True) class PresentedRequest: jti: str client_cert_der: Optional[bytes] # None if terminator stripped it requested_scope: frozenset[str] max_act_depth: int = 3 def _thumbprint(der: bytes) -> str: return hashlib.sha256(der).hexdigest() def enforce_delegated_grant( req: PresentedRequest, intro: IntrospectionResult, actor_scope: frozenset[str], ) -> None: # 1. Token must be active. if not intro.active: raise DelegatedGrantBindingError(f"token {req.jti} inactive at introspection") # 2. Binding must be present and the presenting cert must be available. # "No cert" is a hard failure, never a fallback. if intro.cnf_x5t_s256 is None: raise DelegatedGrantBindingError( f"token {req.jti} has no cnf binding; refusing bearer-style acceptance" ) if req.client_cert_der is None: raise DelegatedGrantBindingError( f"no client cert propagated for {req.jti}; terminator must fail closed" ) # 3. Binding must match the presenting workload, per-request. presented = _thumbprint(req.client_cert_der) if presented != intro.cnf_x5t_s256: raise DelegatedGrantBindingError( f"binding mismatch for {req.jti}: cnf={intro.cnf_x5t_s256} presented={presented}" ) # 4. Delegated scope must be a subset of the immediate actor's scope, # not merely the root subject's scope. if not req.requested_scope.issubset(actor_scope): raise DelegatedGrantBindingError( f"scope escalation on {req.jti}: {req.requested_scope - actor_scope} " f"not held by immediate actor" ) # 5. act chain depth must be bounded. if len(intro.act_chain) > req.max_act_depth: raise DelegatedGrantBindingError( f"act chain depth {len(intro.act_chain)} exceeds max {req.max_act_depth} " f"for {req.jti}" ) ```