← ALL ADVISORIES

MEDIUM BYTERAY-2026-0403Disclosed

wolfSSL — Cross-Context Resumption of TLS 1.3 Stateful Tickets via Shared Session Cache

A TLS 1.3 stateful ticket is a 32-byte identity that indexes the process-wide session cache. The lookup matches on identity and side only, so a ticket issued by one WOLFSSL_CTX resumes on another in the same process, which then skips its own client authentication.

Advisory
BYTERAY-2026-0403
CWE
CWE-639
CVSS
6.8 (CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:N)
Vendor
wolfSSL
Product
wolfSSL
Reported
2026-09-28
Disclosure
2026-12-03
Affected
wolfSSL 5.9.2 (tested at master commit d95483f), TLS 1.3 servers using stateful tickets where one process has more than one WOLFSSL_CTX sharing the default session cache, with no session ID context set or built without OPENSSL_EXTRA
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

In TLS 1.3, wolfSSL treats a pre-shared-key identity of exactly 32 bytes as a stateful ticket: an index into the session cache. That cache is shared by every WOLFSSL_CTX in the process.

On the stateful-ticket path the cache is searched by identity and connection side. Nothing checks that the session was created by the context now receiving the connection. The only context comparison further along is compiled with OPENSSL_EXTRA alone and is skipped unless a session ID context has been set.

In a process that hosts several server contexts with different client-certificate or CA requirements, a client that authenticated to context A can present its ticket identity to context B. B takes A's session from the cache, adopts its resumption secret, completes an abbreviated handshake and marks the peer as authenticated. The client must hold the matching resumption secret, because the TLS 1.3 binder is checked against it before the handshake continues. This is an admission bypass between contexts for a legitimate client of one of them. Default builds are affected when one process hosts several contexts and stateful tickets are in use.

Affected Products and Versions

  • Component: src/internal.c, GetSesionFromCacheOrExt(), called from DoClientTicket_ex() for TLS 1.3 and DTLS 1.3.
  • Required build: TLS 1.3 with the session cache enabled (no NO_SESSION_CACHE). Builds without OPENSSL_EXTRA have no context comparison. Builds with it are affected while no session ID context is set.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • A default ./configure build has no context comparison. The issue applies only when one process hosts more than one server WOLFSSL_CTX and stateful tickets are in use.
  • Other releases were not checked.

Technical Details

DoClientTicket_ex() decides that an identity is a stateful ticket by its length: psk->identityLen == ID_LEN under TLS 1.3 or later (src/internal.c:44116-44121). It then fetches the session with GetSesionFromCacheOrExt().

GetSesionFromCacheOrExt() (src/internal.c:44050-44084) calls TlsSessionCacheGetAndRdLock() directly (src/internal.c:44077). The cache row match compares sessionIDSz, side and sessionID (src/ssl_sess.c:1199-1200). It has no reference to the receiving WOLFSSL_CTX.

What happens to a hit:

  1. PopulateInternalTicketFromSession() copies the cached session's secret and context fields into an internal ticket (src/internal.c:44147, src/internal.c:44020-44022), and the lookup reports success.
  2. DoPreSharedKeys() calls DoClientTicketCheck() (src/tls13.c:6851). Its context comparison is inside #ifdef OPENSSL_EXTRA and behind ssl->sessionCtxSz > 0 (src/internal.c:43795-43801).
  3. DoClientTicketFinalize() adopts the session (src/tls13.c:6884): it duplicates it into ssl->session (src/internal.c:43885) and copies the resumption master secret (src/internal.c:43956).
  4. The server sets ssl->options.peerAuthGood = 1 (src/tls13.c:6896-6897).
  5. The binder is derived from the adopted session's secret and compared with the one the client sent (src/tls13.c:7016-7027). This is the effective barrier. It requires the client to hold the resumption secret, not just the 32-byte identity.

CheckSessionMatch() is called only from src/ssl_sess.c:1304 and src/ssl_sess.c:1408, on the TLS 1.2 session-ID lookup. This path does not reach it. The stateless-ticket branch does, through wolfSSL_GetSession() (src/internal.c:43890-43900).

The DTLS 1.3 stateless ClientHello code reaches the same lookup before the cookie exchange (src/dtls.c:590). It only selects a cipher suite there and adopts no session.

Reachability and Preconditions

  • One server process hosts two or more WOLFSSL_CTX objects with different admission policies, and they share the default session cache.
  • No session ID context is set, or the build lacks OPENSSL_EXTRA.
  • TLS 1.3 stateful tickets are in use.
  • The attacker holds a stateful-ticket identity issued by context A and its resumption secret. In practice that is a legitimate client of A.
  • Context B enforces something the attacker cannot satisfy directly.

Impact

Context B treats the client as authenticated on the strength of a session created under context A. B's client-certificate, CA and policy checks are not applied. The service behind B is reached with a credential issued under A's policy. Processes with a single context are not affected, and a party that knows only the ticket identity cannot pass the binder check.

ByteRay did not build a proof of concept for this issue. The analysis is from source review.

Remediation and Mitigation

ByteRay has not confirmed a fixed wolfSSL release for this issue as of 2026-12-03, and has not checked it against wolfSSL changes made after the tested commit.

The fix direction is to verify, after a cache hit in GetSesionFromCacheOrExt() or DoClientTicket_ex(), that the cached session belongs to the receiving WOLFSSL_CTX, and to fall back to a full handshake when it does not. The context comparison in DoClientTicketCheck() should not depend on OPENSSL_EXTRA, and an unset context should not match everything. Binding the ticket to its issuing context when it is created, and applying the same check to the DTLS 1.3 lookup, complete the change.

Workarounds for a process with several contexts: build with OPENSSL_EXTRA and set a distinct session ID context on each WOLFSSL_CTX with wolfSSL_CTX_set_session_id_context, or arrange that differently configured contexts do not share a session cache.

Timeline

  • 2026-09-28 — Reported to wolfSSL.
  • 2026-12-03 — Public disclosure.

Credits

Discovered and reported by Mehrun P. Hunter and Shahriyar Jalayeri of ByteRay Ltd.

References