← ALL ADVISORIES

LOW BYTERAY-2026-0534Disclosed

wolfSSL — Session Context Check Skipped When the Receiving Endpoint Has No Session ID Context

wolfSSL compares a ticket's or cached session's session ID context with the receiving endpoint's only when the receiver has one configured. An endpoint with no context, the default, accepts sessions created under any other context that shares its ticket keys or session cache.

Advisory
BYTERAY-2026-0534
CWE
CWE-1217
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 where an endpoint with no session ID context shares ticket keys or a session cache with endpoints that set one
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

wolfSSL records the session ID context of the endpoint that created a session in every session ticket and cached session. At resumption it is meant to reject a session created under a different context.

The comparison runs only when the receiving endpoint has a context of its own. A new WOLFSSL object has none unless the application sets one, so on such an endpoint the comparison is skipped entirely. A ticket that carries another endpoint's non-empty context is accepted as a valid resumption.

This matters where ticket-encryption keys or the session cache are shared between endpoints with different contexts and one of them was left without a context. That endpoint completes an abbreviated handshake for sessions from all the others and treats the peer as authenticated. The comparison exists only in OPENSSL_EXTRA builds, which a default build is not.

Affected Products and Versions

  • Component: src/internal.c, DoClientTicketCheck(), the TLS 1.3 and DTLS 1.3 ticket check. The same guard is in CheckSessionMatch() and wolfSSL_SetSession() in src/ssl_sess.c.
  • Required build: OPENSSL_EXTRA, which defines WOLFSSL_SESSION_ID_CTX (wolfssl/wolfcrypt/settings.h:4749-4750), with session resumption enabled.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • A default ./configure build does not define OPENSSL_EXTRA and has no session ID context to compare.
  • Other releases were not checked.

Technical Details

The check in DoClientTicketCheck() (src/internal.c:43795-43801):

        if (ssl->sessionCtxSz > 0 &&
               (psk->it->sessionCtxSz != ssl->sessionCtxSz ||
                XMEMCMP(psk->it->sessionCtx, ssl->sessionCtx,
                        ssl->sessionCtxSz) != 0))
            return WOLFSSL_FATAL_ERROR;

The block is inside #ifdef OPENSSL_EXTRA. When ssl->sessionCtxSz is 0 the whole expression is false, including the length comparison. "The receiver has no context" becomes "accept every context".

How a foreign ticket gets through:

  1. CreateTicket() copies the issuing connection's context into the ticket (src/internal.c:43410-43413). Tickets from a configured endpoint carry a non-empty context.
  2. A WOLFSSL object inherits its context from the WOLFSSL_CTX (src/internal.c:8903-8907, src/ssl.c:9189-9193). If the application never calls wolfSSL_CTX_set_session_id_context or wolfSSL_set_session_id_context, the size stays 0.
  3. A client presents the ticket in the TLS 1.3 pre_shared_key extension. DoPreSharedKeys() calls DoClientTicketCheck() (src/tls13.c:6851). The DTLS 1.3 path calls it at src/dtls.c:604.
  4. The guard is false, the contexts are never compared and the ticket is accepted. The server then sets peerAuthGood (src/tls13.c:6896-6897).

The same guard appears in CheckSessionMatch() for cached sessions (src/ssl_sess.c:1220-1223, used at src/ssl_sess.c:1304 and src/ssl_sess.c:1408) and in wolfSSL_SetSession() for imported sessions (src/ssl_sess.c:1612-1622). The library's own comments state the intended rule: "Any session that is imported with a different session context id will be rejected" (src/ssl_sess.c:3833-3835, src/ssl_sess.c:3861-3862). For that to hold, an empty context on one side and a set context on the other has to count as a mismatch.

Reachability and Preconditions

  • Build with OPENSSL_EXTRA and resumption enabled.
  • Ticket-encryption keys or the session cache are shared between endpoints that use different session ID contexts. One WOLFSSL_CTX whose connections each call wolfSSL_set_session_id_context is such a deployment.
  • At least one receiving endpoint has no context set. One connection handler that omits the call is enough.
  • The attacker is a remote client that completed a handshake with a configured endpoint and holds the ticket or session it issued.

Impact

The unconfigured endpoint accepts a session that was created under another context. It resumes with an abbreviated handshake, takes peer authentication from the ticket and skips the client-certificate exchange. The session isolation that the session ID context is meant to provide does not apply to that endpoint. Exposure is limited to the deployment shape above together with an application-side omission. Where every endpoint sets a context, or none does, the check behaves as documented.

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 drop the ssl->sessionCtxSz > 0 condition at all three sites so that the comparison always runs and an empty context does not match a set one. Rejecting, or at least documenting, resumption on endpoints with no session ID context would make a forgotten call fail visibly. Workaround: set a session ID context on every WOLFSSL_CTX and every connection that shares ticket keys or a session cache with others.

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