wolfSSL — Cross-Context Session Resumption via Shared Session Cache in TLS 1.2 and DTLS 1.2
The TLS 1.2 and DTLS 1.2 session cache is shared by every WOLFSSL_CTX in a process and is searched by session ID and side only. A client holding a session from one context can resume it on another context in the same process, which then skips its own client authentication.
- Advisory
- BYTERAY-2026-0402
- 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), server processes with 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
wolfSSL keeps resumable TLS 1.2 and DTLS 1.2 sessions in one cache for the whole process. Every WOLFSSL_CTX in the application reads and writes it. When a client offers a session ID, the lookup matches on the ID and the connection side.
The one check that could tie a cached session to the context about to reuse it is CheckSessionMatch(). Its context comparison is compiled only with OPENSSL_EXTRA, and even then it is skipped unless the application has set a session ID context. Without OPENSSL_EXTRA the session has no context field at all.
In a process that hosts several contexts with different policies, a client with a session issued by context A can offer its ID to context B. B adopts the session, derives keys from its master secret and marks the peer as authenticated without applying its own client-certificate or CA requirements. The client must hold the session's secret, so this is open to legitimate clients of A, not to someone who only saw the session ID. Processes with a single context are not affected. Default builds are, when they host several contexts.
Affected Products and Versions
- Component:
src/ssl_sess.c,CheckSessionMatch()and the session cache lookup, as used byHandleTlsResumption()insrc/internal.c. - Required build: session cache enabled (no
NO_SESSION_CACHE). Builds withoutOPENSSL_EXTRAhave no context binding. Builds with it are affected while no session ID context is set. - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default
./configurebuild is in the first group. The issue applies only when one process hosts more than one serverWOLFSSL_CTX. - Other releases were not checked.
Technical Details
The cache is a static table (src/ssl_sess.c:33). The server adds sessions with AddSession() (src/internal.c:27767, src/internal.c:38944). The row match compares sessionIDSz, side and sessionID (src/ssl_sess.c:1199-1200). It consults no context identity.
CheckSessionMatch() (src/ssl_sess.c:1216-1228) runs after it (src/ssl_sess.c:1408-1412). Its context comparison sits inside #ifdef OPENSSL_EXTRA and behind ssl->sessionCtxSz > 0 (src/ssl_sess.c:1220-1223). WOLFSSL_SESSION_ID_CTX is defined only with OPENSSL_EXTRA (wolfssl/wolfcrypt/settings.h:4749-4750), so without it the sessionCtx fields in the session (wolfssl/internal.h:5111-5114) and the context (wolfssl/internal.h:4381-4384) do not exist.
The path from ClientHello to an authenticated state:
- The server copies the ClientHello session ID and sets
resuming(src/internal.c:41504-41508). DoClientHello()callsHandleTlsResumption()(src/internal.c:42489-42490), which callswolfSSL_GetSession()(src/internal.c:41665) and sowolfSSL_GetSessionFromCache()(src/ssl_sess.c:1243).- The row match returns a session created by any context in the process.
CheckSessionMatch()passes it. - The remaining test is that the client offered the session's cipher suite (
src/internal.c:41751-41768). The client chooses what it offers. - The session's master secret is copied out (
src/ssl_sess.c:1539-1540), keys are derived from it, and the server setspeerAuthGoodandCLIENT_KEYEXCHANGE_COMPLETE(src/internal.c:41792-41805). DoClientHello()leaves the full-handshake path (src/internal.c:42512-42517). No CertificateRequest is sent and no peer certificate is verified.
The other checks on this path do not concern context. Expiry bounds the session's age (src/internal.c:41699-41707). The extended master secret test is independent of policy (src/internal.c:41714). The SNI and ALPN binding is compiled only with session tickets and HAVE_SNI or HAVE_ALPN (src/internal.c:41672-41673).
Reachability and Preconditions
- One server process hosts two or more
WOLFSSL_CTXobjects with different admission policies, and they share the default session cache. - No session ID context is set, or the build lacks
OPENSSL_EXTRA. - The attacker holds a valid session from context A: its session ID and its master secret. In practice that is a legitimate client of A. The client's Finished message has to verify under keys derived from that secret, so an observed session ID alone is not enough.
- Context B enforces something the attacker cannot satisfy directly, such as a client certificate from a particular CA.
Impact
Context B accepts the client as authenticated on the strength of a session created under context A. B's CertificateRequest and certificate verification are skipped, and the service behind B is reached with a credential issued under A's weaker policy. In a multi-tenant or multi-virtual-host process this is an admission bypass between contexts. It is not a pre-authentication bypass.
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 record the owning context's identity in every cached session, independent of build options, and to reject a cache hit whose owner is not the receiving WOLFSSL_CTX. The check should not depend on OPENSSL_EXTRA, and a session with no recorded identity should count as a mismatch.
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 turn the session cache off for contexts that must not accept each other's sessions, with wolfSSL_CTX_set_session_cache_mode(ctx, WOLFSSL_SESS_CACHE_OFF).
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.