# What happens when an instance refreshes its mTLS session mid-task and silently drops per-task capability scope **Date of Record:** 2026 November 30 **Scope:** Applies to multi-agent systems where peer identity is established via mutual TLS and authorization is carried by short-lived, per-task capability tokens bound to the current session. Does not apply to long-lived service-account credential models or to systems where capability tokens are bound to a stable workload identity rather than a transport session. ## Core Distinction Zero-trust agent meshes commonly conflate two independent security predicates: *channel authenticity* (this peer is who its certificate says it is) and *task authorization* (this peer may perform this specific operation on this specific resource right now). mTLS answers only the first. Per-task capability tokens answer the second. The non-obvious boundary is that **capability scope is frequently bound to the TLS session that carried it** — either explicitly (the token is bound to the session's exporter or channel binding) or implicitly (the token is cached in a per-connection authorization context that is discarded on renegotiation). The distinction that matters operationally: a *session refresh* is not a *re-authentication event* in the agent's reasoning loop. The agent's planner believes it holds capability C for task T. The transport layer, on refresh, has produced a new session with a fresh authorization context that contains no capability for T. The agent's belief state and the transport's authorization state have diverged, and nothing in the protocol surfaces the divergence until the next privileged call. ## What Was Observed A three-agent pipeline (planner → executor → verifier) ran a long-horizon task. The executor held a capability token `cap:write:artifact:7f3a` scoped to a specific artifact handle, minted at task start with a 15-minute TTL and channel-bound to the executor↔store mTLS session. Mid-task, the executor's connection to the artifact store was recycled by the load balancer after 300 seconds of idle keep-alive expiry during a long model call. The client library transparently re-established the TLS session — new session ID, new exporter secret, new connection-scoped auth context — and **replayed the cached capability token onto the new session**. The store's authorization layer validated the token's signature, expiry, and audience, then checked the channel binding. The binding failed, because the token was bound to the old session's exporter. The store returned `403 binding_mismatch`. The executor's retry wrapper classified `403` as a transient transport fault (it was in the same retry class as `503`), and re-sent the request. Three retries exhausted, the executor marked the tool call as failed, and — critically — **the planner received a generic `tool_error` with no indication that the capability was now unusable**. The planner's recovery policy for `tool_error` was "retry with a different tool." It routed the write through a fallback path that used a *broader* capability `cap:write:artifact:*` that had been minted earlier for a different subtask and was still cached in the executor's process memory. That token was not channel-bound (it predated the binding requirement). The write succeeded. The verifier, checking only final artifact state, passed the task. The task completed. The audit log showed a privilege escalation from a task-scoped capability to a wildcard capability, executed by an agent that believed it was recovering from a transient network error. ## Condition of Validity The failure requires the conjunction of four conditions, and it is *only* bounded when all four are addressed: 1. **Channel binding is enforced on some tokens but not all.** If every capability token is channel-bound, the fallback path also fails and the divergence surfaces as a hard error. If none are, the refresh is genuinely transparent. The hazard lives in the mixed case. 2. **Session refresh is transparent to the agent's reasoning layer.** The client library re-establishes the session without emitting a state-change event the planner can observe. The planner's world model still contains "I hold cap:write:artifact:7f3a." 3. **The error taxonomy collapses authorization failures into the retryable class.** `403 binding_mismatch` is not transient; treating it as transient both burns the retry budget and, worse, triggers the fallback policy. 4. **A broader cached capability exists in process memory.** This is the escalation vector. Without it, the task simply fails — a clean failure. With it, the task *succeeds incorrectly*, which is strictly worse for a verifier that only inspects outcomes. The invariant that must hold: **for any agent action, the capability actually exercised must be identical to the capability the planner believed it was exercising, and this identity must be verifiable after the fact.** Session refresh breaks the "identical" clause silently; the fallback path breaks it observably but the planner never learns. ## Decision Boundary The boundary is not "should we use mTLS" or "should we use capability tokens." It is: **at what layer does capability scope get re-established after a transport discontinuity, and who is authorized to make that decision?** Two defensible architectures exist: - **Token survives session; binding is to workload identity.** Capabilities are bound to a stable agent identity (SPIFFE ID, workload attestation) rather than to a TLS session. Session refresh is then genuinely transparent and the planner's belief state remains correct. This is the correct choice when sessions are expected to churn faster than tasks run. - **Token dies with session; refresh is an explicit re-authorization.** The transport emits a `session_reestablished` event into the agent's event stream. The planner must re-request the capability from the minting authority, which re-evaluates scope against current task state. This is the correct choice when capability scope must track task progression. The anti-pattern is the middle: tokens that are channel-bound but whose failure is not surfaced to the reasoning layer, combined with a client library that silently replays them. This produces the escalation above. The guardrail is a **capability ledger**: every capability the agent holds is recorded with its binding mode, and every tool invocation records which capability it actually consumed. A post-task audit asserts that for each action, `consumed_capability == believed_capability`. A mismatch on a *narrower* consumed capability is a task failure; a mismatch on a *broader* consumed capability is a security incident, regardless of task outcome. ## Operational Effect Without the ledger and the explicit refresh event, the observable effects are: - **Silent privilege escalation on retry.** The fallback path is selected by a recovery policy that cannot distinguish "network flaked" from "capability invalidated." The agent's error-handling logic becomes an escalation oracle. - **Verifier false-pass.** Outcome-only verification cannot detect that the task was completed under a different authorization than intended. The task's provenance is corrupted while its result is correct. - **Non-reproducible audit.** The audit log records a `403` and a subsequent `200` on a different capability, but without the planner's belief state at each step, the escalation is indistinguishable from legitimate fallback. - **Stale capability accumulation.** Cached broader capabilities persist in process memory across subtasks precisely because the agent has no model of capability lifetime. The longer the process lives, the wider the effective privilege. The remediation that held under replay: emit `session_reestablished` as a first-class event; on receipt, the planner must *drop* all channel-bound capabilities from its belief state and re-mint before the next privileged call. Classify `binding_mismatch` as a terminal authorization error, never retryable. And assert the capability ledger invariant before the verifier is allowed to pass a task. ```python from dataclasses import dataclass, field from typing import Optional class CapabilityDivergenceError(RuntimeError): """Raised when the capability an agent actually exercised differs from the capability its planner believed it held. Narrower-than-believed is a task failure; broader-than-believed is a security incident.""" pass @dataclass class Capability: name: str scope: str # e.g. "artifact:7f3a" or "artifact:*" channel_bound: bool session_id: str @dataclass class CapabilityLedger: believed: dict[str, Capability] = field(default_factory=dict) consumed: list[tuple[str, Capability]] = field(default_factory=list) def believe(self, cap: Capability) -> None: self.believed[cap.name] = cap def consume(self, action: str, cap: Capability) -> None: self.consumed.append((action, cap)) def on_session_reestablished(self, old_session: str) -> None: # Channel-bound capabilities die with their session. The planner's # belief state must be purged, not silently replayed. for name, cap in list(self.believed.items()): if cap.channel_bound and cap.session_id == old_session: del self.believed[name] def assert_consistency(self) -> None: for action, cap in self.consumed: believed = self.believed.get(cap.name) if believed is None: raise CapabilityDivergenceError( f"action {action!r} consumed capability {cap.name!r} " f"absent from planner belief state" ) if believed.scope != cap.scope: raise CapabilityDivergenceError( f"action {action!r}: believed scope {believed.scope!r} " f"but exercised {cap.scope!r}" ) if cap.scope.endswith(":*") and not believed.scope.endswith(":*"): raise CapabilityDivergenceError( f"SECURITY: action {action!r} escalated from " f"{believed.scope!r} to wildcard {cap.scope!r}" ) def handle_tool_error(status: int, ledger: CapabilityLedger) -> None: # 403 binding_mismatch is terminal authorization failure, not transient. if status == 403: raise CapabilityDivergenceError( "capability invalidated by session refresh; re-mint required" ) # transient path may retry, but only within the believed capability return None ```