← ALL ADVISORIES

LOW BYTERAY-2026-0517Disclosed

wolfSSL — Missing Zeroization of Replaced Session Ticket in Session Duplication

When wolfSSL_DupSessionEx copies a session over one that already holds a heap-allocated ticket, the old ticket buffer is freed or reallocated without being cleared on every path. The previous ticket remains in freed heap memory.

Advisory
BYTERAY-2026-0517
CWE
CWE-226
CVSS
3.7 (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N)
Vendor
wolfSSL
Product
wolfSSL
Reported
2026-09-28
Disclosure
2026-12-03
Affected
wolfSSL 5.9.2 (tested at master commit d95483f), builds with HAVE_SESSION_TICKET (--enable-session-ticket)
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

wolfSSL_DupSessionEx() copies one WOLFSSL_SESSION into another. It is the routine behind wolfSSL_set_session(), session cache updates and wolfSSL_SESSION_dup().

If the destination already holds a session ticket in a heap buffer, the routine keeps a pointer to that buffer and later either reuses it, reallocates it, or frees it. None of the release paths clears the old ticket first. The destination's previous TLS 1.3 ticket nonce is freed the same way in builds with dynamic nonces.

The freed block holds only the ticket. The master secret needed to resume with it is not in that block and is cleared on its own free path. Session ticket support is off by default in this tree, so default builds are not affected.

Affected Products and Versions

  • Component: src/ssl_sess.c, wolfSSL_DupSessionEx().
  • Required build: HAVE_SESSION_TICKET (src/ssl_sess.c:4020, src/ssl_sess.c:4092). --enable-session-ticket is off by default (configure.ac:9469-9473). The nonce release also needs WOLFSSL_TICKET_NONCE_MALLOC (configure.ac:9485-9488).
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • A default ./configure build does not include this code.
  • Other releases were not checked.

Technical Details

Before the copy, the routine saves the destination's dynamic ticket buffer as ticBuff (src/ssl_sess.c:4021-4024). After the copy it decides what to do with it. The old bytes are discarded on four paths:

  1. WOLFSSL_NO_REALLOC builds allocate a new buffer for the incoming ticket and then free ticBuff (src/ssl_sess.c:4107-4111).
  2. Other builds call XREALLOC() on ticBuff (src/ssl_sess.c:4113-4114). When the allocator moves the block, the old one is released with the previous ticket in it.
  3. If that reallocation fails, ticBuff is freed (src/ssl_sess.c:4116-4120).
  4. If the incoming ticket fits the inline buffer, ticBuff is freed (src/ssl_sess.c:4163-4166).

No path calls ForceZero(). With WOLFSSL_TLS13 and WOLFSSL_TICKET_NONCE_MALLOC, the destination's dynamic ticket nonce is also freed without clearing (src/ssl_sess.c:4030-4043).

The routine is reached from wolfSSL_DupSession() (src/ssl_sess.c:4253-4258), which the set-session path calls (src/ssl_sess.c:1588), and from the cache insert in AddSessionToCache() (src/ssl_sess.c:2127-2135).

In the same file, wolfSSL_FreeSession() clears the master secret and session id with ForceZero() before it frees a session (src/ssl_sess.c:4350-4352). Ticket buffers are not given the same treatment here or there; the free path is covered in BYTERAY-2026-0518.

Reachability and Preconditions

  • Build with HAVE_SESSION_TICKET.
  • The destination session already holds a ticket in a heap buffer, and the incoming session's ticket either fits the inline buffer or needs a larger heap buffer than the existing one.
  • The copy is triggered by the application setting a session, by duplication, or by cache updates during handshakes. A TLS peer influences ticket sizes and how often sessions are stored.
  • Disclosure needs a second condition outside this issue: the freed block is reused in the same process and something exposes the reused memory.

Impact

A copy of a previous session ticket persists in freed heap memory after each such duplication. The ticket may still be accepted by the server, but it is not sufficient for resumption without the matching secret. The consequence is a limited confidentiality exposure that depends on a separate memory-disclosure primitive. It does not by itself allow session impersonation.

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 call ForceZero() on ticBuff over the previous allocation length before each XFREE(). The reallocation path cannot be cleared after the fact. Since the old contents are not needed there, the buffer can be cleared before the resize, or the resize can be replaced by allocate, copy, clear and free. The previous ticket nonce should be cleared before its free as well.

Builds without session ticket support are not affected. There is no runtime workaround for builds that need tickets.

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