wolfSSL — Missing Zeroization of Replaced TLS 1.3 Ticket Nonce in SessionTicketNoncePopulate
In builds with dynamic ticket nonces, SessionTicketNoncePopulate frees the previous TLS 1.3 ticket nonce without clearing it before it stores a new one. The old nonce stays in freed heap memory on every ticket renewal and on session deserialization.
- Advisory
- BYTERAY-2026-0514
- 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 and WOLFSSL_TICKET_NONCE_MALLOC (--enable-ticket-nonce-malloc)
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
A TLS 1.3 client stores the nonce from each NewSessionTicket message in its session object. With WOLFSSL_TICKET_NONCE_MALLOC, a nonce that does not fit the inline buffer is kept in a heap buffer. SessionTicketNoncePopulate() installs the new nonce.
Before it does, it frees the previous dynamic nonce with XFREE() and does not clear it. The old bytes stay in freed heap memory. This happens for every ticket the server issues and when a session is parsed from its serialized form.
The option is off by default. Without it the nonce lives in a fixed array inside the session and is never freed, so default builds are not affected. The nonce is one input to the resumption key derivation and is also sent in the clear in NewSessionTicket, so recovering it does not by itself allow resumption.
Affected Products and Versions
- Component:
src/tls13.c,SessionTicketNoncePopulate(). - Required build:
HAVE_SESSION_TICKETandWOLFSSL_TICKET_NONCE_MALLOC(src/tls13.c:14404-14405). The option--enable-ticket-nonce-mallocis off by default (configure.ac:9485-9488). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default
./configurebuild does not include this function. Other releases were not checked.
Technical Details
The function starts by releasing the old nonce (src/tls13.c:14409-14415):
if (session->ticketNonce.data
!= session->ticketNonce.dataStatic) {
XFREE(session->ticketNonce.data, session->heap,
DYNAMIC_TYPE_SESSION_TICK);
session->ticketNonce.data = session->ticketNonce.dataStatic;
session->ticketNonce.len = 0;
}
It then allocates a buffer if the new nonce is larger than the inline one and copies the new nonce in (src/tls13.c:14417-14425). Nothing overwrites the old buffer before the free.
The function is reached two ways:
DoTls13NewSessionTicket()calls it for each NewSessionTicket the client receives (src/tls13.c:14535).wolfSSL_d2i_SSL_SESSION()calls it while parsing a serialized session (src/ssl_sess.c:3156).
The same nonce buffer is freed without clearing in wolfSSL_FreeSession() (src/ssl_sess.c:4336-4341) and in the cache eviction path (src/ssl_sess.c:101). In wolfSSL_FreeSession() the master secret and session id next to it are cleared with ForceZero() (src/ssl_sess.c:4350-4352). Those sites are covered in BYTERAY-2026-0518.
Reachability and Preconditions
- Build with
HAVE_SESSION_TICKET,WOLFSSL_TLS13andWOLFSSL_TICKET_NONCE_MALLOC. - The session already holds a dynamic nonce, which means a previous nonce was longer than the inline buffer.
- A TLS 1.3 server the client connects to chooses the nonce length and how many tickets it sends. The d2i path is driven by the application.
- Disclosure needs a second condition outside this issue: the freed block is reused in the same process and something exposes the reused memory.
Impact
Stale ticket nonces persist in freed heap memory. A nonce is a derivation input, not a bearer credential, and it is also visible in the NewSessionTicket message. The practical effect is a memory hygiene gap with 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 the old nonce over its recorded length immediately before the XFREE() in SessionTicketNoncePopulate(), and to do the same at the other nonce release sites. A single helper that clears and then frees the nonce would keep new call sites from missing the step. Building without WOLFSSL_TICKET_NONCE_MALLOC avoids the issue. Nonces then have to fit the inline buffer.
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.