wolfSSL — Missing Session Context Check in TLS 1.2 Session Ticket Resumption
A TLS 1.2 or DTLS 1.2 session ticket carries the session ID context of the connection that issued it, but the server never compares that context when the ticket is presented. A ticket issued under one context resumes under another that shares the ticket-encryption key, with peer authentication taken as done.
- Advisory
- BYTERAY-2026-0401
- CWE
- CWE-1217
- CVSS
- 6.5 (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/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), OPENSSL_EXTRA builds with session tickets, where session ID contexts are set and ticket-encryption keys are shared across them
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
wolfSSL writes the issuing connection's session ID context into every stateless session ticket. The context is the value an application sets with wolfSSL_set_session_id_context to keep sessions from one logical service out of another.
On the TLS 1.2 and DTLS 1.2 ticket path the server never reads that field back. It decrypts the ticket, checks the protocol version, and grants resumption. The session cache lookup, the TLS 1.3 ticket check and the session import API all compare the context. This path does not.
Where one WOLFSSL_CTX, and so one ticket-encryption key, serves connections with different contexts, a client that completed a handshake under context A can present its ticket to context B and resume there. The server skips its CertificateRequest and treats the client as authenticated. Deployments that never set a session ID context are not affected. The feature exists only in OPENSSL_EXTRA builds.
Affected Products and Versions
- Component:
src/internal.c,DoClientTicket(), server-side ticket resumption for TLS 1.2 and DTLS 1.2 and earlier. - Required build:
OPENSSL_EXTRA, which definesWOLFSSL_SESSION_ID_CTX(wolfssl/wolfcrypt/settings.h:4749-4754), and session tickets. - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default
./configurebuild does not defineOPENSSL_EXTRA. With it, only deployments that set session ID contexts and share ticket keys across them are exposed. - Other releases were not checked.
Technical Details
CreateTicket() stores the context in the ticket (src/internal.c:43410-43413). DoClientTicket() (src/internal.c:44200-44309) accepts a ticket through three calls, and none of them looks at it:
DoDecryptTicket()(src/internal.c:43599) authenticates and decrypts with the key behindticketEncCb.DoClientTicketCheckVersion()(src/internal.c:43673) applies version rules.DoClientTicketFinalize()(src/internal.c:43871) copies the ticket's contents into the session.
The only comparison of the ticket's context is in DoClientTicketCheck() (src/internal.c:43795-43801), which is called from the TLS 1.3 pre-shared-key path alone.
The path from ticket to authenticated resumption:
- A client completes a normal handshake under context A and receives a NewSessionTicket with context A inside.
- The client sends the same ticket bytes in the SessionTicket extension of a ClientHello to context B.
TLSX_SessionTicket_Parse()passes it toDoClientTicket()(src/tls.c:6618). - The ticket decrypts under the shared key (
src/internal.c:44262), passes the version check (src/internal.c:44279) and is finalized (src/internal.c:44288). - The parser sets
useTicket,resumingandpeerAuthGood(src/tls.c:6621-6624). HandleTlsResumption()uses the ticket session directly (src/internal.c:41659-41661). It does not go throughwolfSSL_GetSession()(src/internal.c:41665), the route on whichCheckSessionMatch()compares contexts (src/ssl_sess.c:1216-1228).- Because
resumingis set, the server sends no CertificateRequest (src/ssl_api_hs.c:1037-1049). The check that client authentication took place passes onpeerAuthGood(src/ssl_api_hs.c:1112-1117).
VerifyTicketBinding() (src/internal.c:43276) compares SNI and ALPN hashes only. The hashes are written when the ticket is created (src/internal.c:43414-43425). ByteRay's analysis is that a ticket issued on a connection that used neither SNI nor ALPN carries zero hashes and passes. It is not a context check in any case. The sniffer also calls DoClientTicket() (src/sniffer.c:4617).
Reachability and Preconditions
- Build with
OPENSSL_EXTRAand session tickets; TLS 1.2 or DTLS 1.2 negotiated. - The application sets session ID contexts, and endpoints with different contexts share a ticket-encryption key. Per-connection contexts under one
WOLFSSL_CTX, or a shared ticket callback key, both qualify. - SNI or ALPN does not separate the contexts, or the ticket was issued without them.
- The attacker is a remote client holding a ticket legitimately issued under context A. That takes one completed handshake, with a valid client certificate if A requires one. The ticket is replayed unchanged; nothing is forged.
Impact
A connection under context B is accepted as a resumption of a session that was established under context A. The server performs no client-certificate verification for B and records the peer as authenticated. A client admitted by one context is admitted by another whose requirements it may not meet, which is what the session ID context exists to prevent.
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 compare the ticket's sessionCtx and sessionCtxSz with the receiving connection's after decryption in DoClientTicket(), as DoClientTicketCheck() does for TLS 1.3, and to fall back to a full handshake on any mismatch.
Workarounds: give each context its own ticket-encryption key, for example a separate WOLFSSL_CTX or a ticket callback that selects a key per context, so that a ticket from one context does not decrypt in another. Disabling session tickets for the affected contexts also closes the path. The SNI and ALPN binding should not be relied on for this.
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.