wolfSSL — Missing Zeroization of Replaced Session Ticket in Session Cache Lookup
During a session cache lookup, wolfSSL_GetSessionFromCache frees the destination session's existing heap-allocated ticket without clearing it before it installs a preallocated buffer. The previous ticket remains in freed heap memory on the resumption path.
- Advisory
- BYTERAY-2026-0519
- 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
When a client attempts resumption, wolfSSL looks up the session to reuse with wolfSSL_GetSessionFromCache(). The lookup copies the cached session into a destination session object, usually ssl->session.
Before the copy, the function makes sure the destination has a ticket buffer of a preallocated size. If the destination already holds a smaller heap-allocated ticket, that buffer is freed and replaced. The free is a plain XFREE() and the old ticket is not cleared. The TLS 1.3 ticket nonce of the destination is freed the same way in builds with dynamic nonces.
The freed block contains the ticket only. The master secret or resumption secret needed to use it is stored elsewhere and cleared on its own free paths. 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_GetSessionFromCache(). - Required build:
HAVE_SESSION_TICKET(src/ssl_sess.c:1335).--enable-session-ticketis off by default (configure.ac:9469-9473). The nginx, wpa_supplicant, haproxy and lighttpd options turn it on (configure.ac:9475-9478). - The nonce release also needs
WOLFSSL_TLS13andWOLFSSL_TICKET_NONCE_MALLOC(src/ssl_sess.c:1363-1365). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default
./configurebuild does not include this code. Other releases were not checked.
Technical Details
wolfSSL_GetSessionFromCache() is defined at src/ssl_sess.c:1243. Its preallocation step is (src/ssl_sess.c:1336-1353, abridged):
if (output->ticket == NULL ||
output->ticketLenAlloc < PREALLOC_SESSION_TICKET_LEN) {
if (output->ticketLenAlloc)
XFREE(output->ticket, output->heap, DYNAMIC_TYPE_SESSION_TICK);
output->ticket = tmpTicket;
output->ticketLenAlloc = PREALLOC_SESSION_TICKET_LEN;
}
The sequence that leaves a ticket behind:
- An earlier lookup, or another ticket path, leaves a heap-allocated ticket in the destination session. The lookup itself copies the cached ticket into the destination buffer at
src/ssl_sess.c:1476-1478. - A later lookup finds
ticketLenAllocset and below the preallocation threshold. - The old buffer is freed at
src/ssl_sess.c:1346-1347. NoForceZero()precedes the free. - The destination's dynamic ticket nonce, if any, is freed at
src/ssl_sess.c:1366-1371, also without clearing.
Dynamic tickets at or above the threshold are kept, not freed. The lookup is called from wolfSSL_GetSession() with ssl->session as the destination (src/ssl_sess.c:1532).
Reachability and Preconditions
- Build with
HAVE_SESSION_TICKET. - The destination session holds a heap-allocated ticket smaller than the preallocation size when the lookup runs.
- The lookup runs on resumption attempts in normal operation. A TLS peer influences the size of the tickets involved.
- Disclosure needs a second condition outside this issue: the freed block is reused in the same process and something exposes the reused memory.
Impact
The previous session ticket persists in freed heap memory after the lookup. It is one part of a resumption credential and cannot be used without the matching secret, which is cleared on its own free paths (src/ssl_sess.c:80, src/ssl_sess.c:4350). The consequence is a limited confidentiality exposure that depends on a separate memory-disclosure primitive.
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 output->ticket over output->ticketLenAlloc bytes before the XFREE(), and to clear the nonce buffer before its free. The other ticket replacement and release sites have the same gap, so one helper that clears and then frees a ticket could be used at all of them. 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.