# What structural signals indicate agent-to-agent session establishment has silently degraded to unauthenticated transport **Date of Record:** 2026 November 17 **Scope:** Applies to agent-to-agent (A2A) session establishment where authentication is bound to the transport layer (mTLS, signed request headers, or bearer tokens with per-session binding) over HTTP/1.1 and HTTP/2. Does not apply to application-layer session tokens negotiated after a completed handshake, nor to transport-agnostic message signing where authentication is verified per-message rather than per-session. ## Core Distinction The failure mode is not "authentication failed." It is **authentication succeeded for a different session than the one carrying the payload**. HTTP-native transports permit connection reuse, connection coalescing (HTTP/2), and speculative preconnect, all of which decouple the *identity that authenticated* from the *stream that delivers the request*. An agent that observes a `200 OK` with a valid peer identity has verified that *some* authenticated peer exists on the connection — not that the peer on the connection is the peer authorized for this session. The structural signal is the divergence between two facts that operators assume are co-located: (1) the identity bound to the transport credential, and (2) the identity recorded as the session peer. When these are read from different sources (e.g., identity from the TLS peer certificate, session peer from a header or a connection-scoped cache), a coalesced or reused connection produces a coherent-looking session whose peer identity is stale. ## What Was Observed Two agent runtimes, A and B, established a session over HTTP/2. Agent A authenticated with mTLS and a session-bound bearer token in the `Authorization` header. The peer identity was resolved from the TLS peer certificate at connection setup and cached on the connection object. B reused an existing connection that had been opened for a prior session with a different peer, C, because the HTTP/2 connection pool keyed on `(scheme, host, port)` and ignored the session identifier. The resulting session had: - A valid `Authorization` header for A→B (correct). - A TLS peer certificate for C (incorrect, but not checked per-request). - A `200 OK` and a session record listing peer = C. No error was raised at any layer. The bearer token validated. The certificate validated. The session record was internally consistent. The only signal was a *mismatch between the certificate subject and the session's declared peer*, which was not compared because the session peer was sourced from the cached connection identity rather than re-derived. Detection required correlating three logs that were never joined: the TLS handshake log (peer = C), the token validation log (subject = A), and the session audit log (peer = C, client = A). The session audit log *looked* correct because it recorded what the connection reported. ## Condition of Validity The invariant holds — "a session is authenticated iff the transport credential's identity equals the session's peer identity" — only under the condition that **the connection is bound to exactly one session for its lifetime**. This condition is violated by: 1. HTTP/2 connection coalescing across origins sharing a certificate. 2. Connection pool reuse keyed on origin rather than on session or credential. 3. Keep-alive reuse after a session close where the close did not tear down the connection. 4. Preconnect / speculative connection establishment that predates the session's credential binding. When any of these hold, the connection is a *shared substrate*, and deriving session peer identity from it is unsound. The correct derivation is per-request: the identity must be re-bound to the request that carries the session identifier, not inherited from the connection. ## Decision Boundary The boundary is: **derive peer identity per-request from the credential presented on that request, and treat connection-level identity as a hint, never as authority.** The decision to accept a session must be gated on a per-request comparison: - If the request carries a session identifier, the credential's identity MUST be checked against the session's recorded peer *on that request*, not at connection open. - If the connection's cached identity disagrees with the per-request credential, the request is rejected — even if both identities are individually valid and even if the session record agrees with the cached identity. - A connection whose cached identity has been superseded by a different per-request credential must be evicted from the pool, not reused. The failure is non-obvious because the *individually valid* case is the dangerous one. A request with an invalid token fails loudly. A request with a valid token for A on a connection cached as C fails silently, and the session record — sourced from the cache — reports C as the peer, which is wrong but self-consistent. ## Operational Effect Sessions established under this condition appear healthy in every per-layer metric: TLS handshake success rate, token validation success rate, and session establishment success rate are all 100%. The only observable is a *cross-layer identity skew* that must be actively computed. Operationally this means: - Session audit records cannot be trusted as authoritative for peer identity unless the audit writer re-derives identity per-request. - Connection pooling must be session-aware or credential-aware; origin-keyed pools are unsound for A2A. - A monitoring invariant is required: for every accepted session, assert `tls_peer == request_credential_subject == session_peer`. Any session where these three do not all agree is a silent-degradation event, not a success. The practical mitigation is to make the per-request check the enforcement point and to treat connection-level identity as advisory metadata that can only *narrow* trust, never establish it. ```python class SessionIdentitySkewError(RuntimeError): """Raised when a session's peer identity is inherited from a shared connection rather than re-derived from the per-request credential.""" pass def establish_session(request, connection_cache, session_store): """ Enforce that session peer identity is derived per-request, not from the connection. connection_cache maps connection_id -> cached peer identity (advisory only). session_store maps session_id -> recorded peer identity. """ session_id = request.headers.get("x-session-id") if not session_id: raise SessionIdentitySkewError("missing session identifier on request") # Authority: the credential presented on THIS request. request_identity = request.credential.subject if request_identity is None: raise SessionIdentitySkewError("request carries no authenticated subject") # Advisory: what the connection was originally opened for. cached_identity = connection_cache.get(request.connection_id) # Recorded: what the session store believes the peer is. recorded_peer = session_store.get_peer(session_id) # The invariant: all three must agree. Disagreement is silent degradation. if cached_identity is not None and cached_identity != request_identity: # Connection was opened for a different peer; it is shared substrate. # Evict rather than reuse, and reject this request on this connection. connection_cache.evict(request.connection_id) raise SessionIdentitySkewError( f"connection {request.connection_id} cached peer " f"{cached_identity!r} but request credential is " f"{request_identity!r}; refusing to inherit connection identity" ) if recorded_peer is not None and recorded_peer != request_identity: raise SessionIdentitySkewError( f"session {session_id} recorded peer {recorded_peer!r} but " f"request credential is {request_identity!r}; " f"session peer identity is stale" ) # Only now may we bind the session. session_store.bind_peer(session_id, request_identity) connection_cache.set(request.connection_id, request_identity) return {"session_id": session_id, "peer": request_identity} ```