← ALL ADVISORIES

HIGH BYTERAY-2026-0307Disclosed

wolfSSL — Stale Session Ticket State on Reused Server Objects Allows Forged TLS 1.2 Resumption

A wolfSSL server sets options.useTicket when a ClientHello carries a session ticket extension and no reset path clears it. On an object reused with wolfSSL_clear(), a later ClientHello with any session ID resumes the retained session and derives keys from a master secret that wolfSSL_clear() zeroed.

Advisory
BYTERAY-2026-0307
CWE
CWE-1271
CVSS
7.4 (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N)
Vendor
wolfSSL
Product
wolfSSL
Reported
2026-09-27
Disclosure
2026-12-03
Affected
wolfSSL 5.9.2 (tested at master commit d95483f), TLS 1.2 and earlier servers built with HAVE_SESSION_TICKET (--enable-session-ticket) that reuse a WOLFSSL object through wolfSSL_clear()
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

A wolfSSL server records in ssl->options.useTicket that the current handshake involves a session ticket. During resumption the flag has two effects. The server takes the session to resume from ssl->session instead of looking up the session ID sent by the client, and it skips the SNI and ALPN binding checks, because a ticket that decrypted is taken to carry its own binding.

The flag is set on every path that sees the ticket extension, including an empty extension and a rejected ticket. Nothing clears it. wolfSSL_clear(), the documented way to reuse a WOLFSSL object for another connection, leaves it set. After a completed handshake wolfSSL_clear() also keeps ssl->session and zeroes the master secret in the handshake arrays.

On a reused object the next ClientHello needs no ticket. A TLS 1.2 ClientHello with an arbitrary session ID enters the ticket branch, resumes the session left by the previous client, and derives its keys from the zeroed master secret. Those keys can be computed by anyone who sees the handshake, so the client can produce a valid Finished message, and the server marks the peer as authenticated. The issue needs session tickets enabled and an application that reuses server objects with wolfSSL_clear().

Affected Products and Versions

  • Component: src/internal.c, HandleTlsResumption(), and the reset paths that leave its inputs in place: wolfSSL_clear(), ReinitSSL() and ResetHandshakeStateForReneg().
  • Required build: HAVE_SESSION_TICKET (--enable-session-ticket). The report states that no other non-default option is needed.
  • Required usage: a TLS server reuses a WOLFSSL object for a new connection with wolfSSL_clear() after a completed handshake in which the client sent the ticket extension.
  • Protocol: the report limits the issue to a ClientHello for TLS 1.2 or earlier.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • A server that creates a new object for each connection is not affected.
  • Other releases were not checked.

Technical Details

HandleTlsResumption() chooses where the session comes from (src/internal.c:41659-41666):

        if (ssl->options.useTicket == 1) {
            session = ssl->session;
        }
        else
    #endif
        {
            session = wolfSSL_GetSession(ssl, ssl->arrays->masterSecret, 1);
        }

In the cache branch wolfSSL_GetSession() loads the master secret of the session it finds. In the ticket branch nothing is loaded. The code relies on the ticket parser having installed the secret earlier in the same handshake.

TLSX_SessionTicket_Parse() sets useTicket for an empty ticket extension (src/tls.c:6612), for an accepted ticket (src/tls.c:6621, src/tls.c:6633) and for a rejected ticket that leads to a new one (src/tls.c:6654). No reset path clears it: not wolfSSL_clear() (src/ssl.c:5774), not ReinitSSL() (src/internal.c:8354), not ResetHandshakeStateForReneg() (src/internal.c:20620). The reset at the start of DoClientHello() covers resuming and the stored session ID length only (src/internal.c:41872).

The sequence on a reused server object:

  1. A first client completes a handshake that sent the ticket extension. useTicket is 1 and ssl->session holds that client's session.
  2. The application calls wolfSSL_clear(). Because the handshake completed, the session is kept (src/ssl.c:5782-5789). The master secret in ssl->arrays is zeroed (src/ssl.c:6048). useTicket is unchanged.
  3. A second client sends a TLS 1.2 ClientHello with a 32-byte session ID of its choice and no ticket. DoClientHello() sets resuming because a session ID is present (src/internal.c:42124-42125) and later calls HandleTlsResumption() (src/internal.c:42490).
  4. The stale flag selects ssl->session, the first client's session. The session ID in the ClientHello is not looked up.
  5. The SNI and ALPN comparison is skipped, since it runs only when useTicket is clear (src/internal.c:41675). The expiry check passes for a recent session (src/internal.c:41701). The extended master secret check passes when the second client offers the same mode as the first (src/internal.c:41714).
  6. Keys are derived from the zeroed master secret (src/internal.c:41792-41802). The server sets peerAuthGood from the result of that derivation and marks the client key exchange as complete (src/internal.c:41804-41805).
  7. The message-order checks accept a ChangeCipherSpec without a ClientKeyExchange when resuming is set (src/internal.c:20554-20555). The client computes the Finished verify data from the all-zero master secret and the handshake transcript, both of which it knows.

Reachability and Preconditions

  • Build: session tickets enabled.
  • The server application reuses WOLFSSL objects across connections with wolfSSL_clear().
  • The previous handshake on the object completed and its ClientHello carried the ticket extension. An empty extension is enough to set the flag.
  • The attacker is a remote TLS client that is served by the reused object next. No credentials and no ticket are needed. The attacker offers TLS 1.2 or earlier, a cipher suite compatible with the retained session, and the same extended master secret mode.
  • The master secret is zeroed by wolfSSL_clear() unless the application asked wolfSSL to keep the handshake arrays.
  • The retained session must still be within its lifetime.

Impact

According to the report's analysis, an unauthenticated client completes a resumed handshake that the server treats as peer-authenticated, on a session that belonged to the previous client of the same object. Where the application relies on client certificates, or treats resumption as proof of an earlier authorisation, the new client takes the place of the previous one. This is an authentication bypass. The attacker never learns the previous client's real master secret; the handshake succeeds because the server used a zeroed one.

The traffic keys of that connection are derived from an all-zero master secret and the two public random values. Any party that can observe the connection can compute them, so the connection has no confidentiality or integrity against a network observer.

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 reset the whole per-connection resumption state wherever an object is reset. wolfSSL_clear(), ReinitSSL() and ResetHandshakeStateForReneg() should clear options.useTicket together with options.resuming, and drop the retained session and the stored session ID. The reset at the start of DoClientHello() should cover useTicket, so that the ticket branch is entered only when the current handshake processed a ticket. As further protection, the SNI and ALPN binding checks should not be skipped in the ticket branch, and key derivation should be refused unless the master secret was loaded from a ticket or from the session store during the current handshake.

Workarounds: create a new WOLFSSL object for each connection instead of calling wolfSSL_clear(). Where tickets are not needed, a build without HAVE_SESSION_TICKET does not compile the ticket branch of HandleTlsResumption().

Timeline

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

Credits

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

References