wolfSSL — Missing Zeroization of Freed TLS 1.3 Ticket Nonce in Session Ticket Restore
When a server restores TLS 1.3 session state from a client ticket and the session's ticket nonce is in a heap buffer, the old nonce buffer is freed without being wiped. The path exists only in builds with WOLFSSL_TICKET_NONCE_MALLOC.
- Advisory
- BYTERAY-2026-0508
- 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), server builds with TLS 1.3, HAVE_SESSION_TICKET and WOLFSSL_TICKET_NONCE_MALLOC (--enable-ticket-nonce-malloc)
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
When a wolfSSL server accepts a session ticket from a client, a restore helper copies the state held in the decrypted ticket into the session. For TLS 1.3 that includes the resumption master secret and the ticket nonce.
In builds with WOLFSSL_TICKET_NONCE_MALLOC, the session's nonce can live in a heap buffer in place of the fixed array inside the session structure. If it does when the restore runs, the helper frees the heap buffer and switches back to the fixed array. The buffer is not overwritten before the free. The previous nonce remains in freed heap memory until the block is reused.
The ticket nonce is an input to TLS 1.3 PSK derivation, together with the resumption master secret. It is not a usable credential by itself, and reading the residue needs a separate memory-disclosure primitive in the same process. In a default build the nonce is always in the fixed array and the branch that contains the free is compiled out.
Affected Products and Versions
- Component:
src/internal.c,DoClientTicketFinalize(), the session restore helper used when the server processes a client ticket (DoClientTicket). - Required build:
WOLFSSL_TLS13,HAVE_SESSION_TICKETandWOLFSSL_TICKET_NONCE_MALLOC(src/internal.c:43957-43958). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
--enable-ticket-nonce-mallocis off in a default./configurebuild (configure.ac:9485-9488), so a default build does not include the free.- Other releases were not checked.
Technical Details
The TLS 1.3 branch of the helper copies the resumption master secret and then handles the nonce (src/internal.c:43955-43969). The release is:
if (ssl->session->ticketNonce.data
!= ssl->session->ticketNonce.dataStatic) {
XFREE(ssl->session->ticketNonce.data, ssl->heap,
DYNAMIC_TYPE_SESSION_TICK);
ssl->session->ticketNonce.data =
ssl->session->ticketNonce.dataStatic;
}
Data flow:
- A client presents a session ticket. The server decrypts it and calls the restore helper (
src/internal.c:43871). - The helper copies the resumption master secret from the ticket into the session (
src/internal.c:43956). - If
ticketNonce.datadoes not point atticketNonce.dataStatic, the nonce buffer was allocated earlier on the same session. The helper releases it withXFREEand noForceZero(src/internal.c:43959-43965). - The nonce from the ticket is copied into the static array (
src/internal.c:43967-43969). The freed block keeps the previous nonce until the allocator reuses it.
Reachability and Preconditions
- Server build with TLS 1.3, session tickets and
WOLFSSL_TICKET_NONCE_MALLOC. - The session already holds a dynamically allocated ticket nonce when a client ticket is restored into it. This requires an earlier operation on the same session that allocated the nonce.
- A client triggers the restore by presenting a ticket the server can decrypt.
- To learn the residue, an attacker additionally needs a memory-disclosure primitive in the same process. This issue does not provide one.
Impact
A previous ticket nonce is left in freed heap memory. The nonce is one of two inputs to PSK derivation. The other, the resumption master secret, is not in the freed block. The realistic impact is a partial loss of confidentiality that depends on heap reuse and a second defect.
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 wipe the nonce buffer over its current length before the free in the restore helper, and to reset the stored length when the pointer is switched back to the static array. The same wipe-before-free rule should apply at every site that releases ticket or nonce material. Builds without WOLFSSL_TICKET_NONCE_MALLOC keep the nonce in the session structure and do not reach the free.
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.