wolfSSL — Missing Zeroization of Replaced Session Ticket in SetTicket and wolfSSL_set_SessionTicket
When a new session ticket replaces a stored one, SetTicket and wolfSSL_set_SessionTicket free the previous heap-allocated ticket without clearing it. The old ticket, which a server may still accept, remains in freed heap memory after every renewal.
- Advisory
- BYTERAY-2026-0515
- 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
A wolfSSL client keeps the session ticket it received in its session object. Tickets larger than the inline buffer are stored in a heap buffer. When a new ticket arrives, or the application sets one, the old heap buffer is released first.
SetTicket() and both branches of wolfSSL_set_SessionTicket() release that buffer with XFREE() and do not clear it. Servers usually accept a ticket until it expires, so each renewal leaves a copy of a still-valid ticket in freed memory.
The ticket alone is not enough to resume a session. Resumption also needs the master secret, or in TLS 1.3 the resumption secret and nonce, which are stored elsewhere. Session ticket support is off by default in this tree, so default builds are not affected.
Affected Products and Versions
- Component:
src/internal.c,SetTicket();src/ssl_api_ext.c,wolfSSL_set_SessionTicket(). - Required build:
HAVE_SESSION_TICKET.--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). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default
./configurebuild does not include this code. Other releases were not checked.
Technical Details
SetTicket() drops the old ticket before it stores the new one (src/internal.c:38844-38849):
/* Free old dynamic ticket if we already had one */
if (ssl->session->ticketLenAlloc > 0) {
XFREE(ssl->session->ticket, ssl->heap, DYNAMIC_TYPE_SESSION_TICK);
ssl->session->ticket = ssl->session->staticTicket;
ssl->session->ticketLenAlloc = 0;
}
wolfSSL_set_SessionTicket() has the same release in two places. When the new ticket fits the inline buffer, the old dynamic ticket is freed at src/ssl_api_ext.c:1497-1502. When a larger buffer is needed, it is freed at src/ssl_api_ext.c:1507-1510 before the new allocation. None of the three sites calls ForceZero().
The paths that reach them:
- A TLS 1.2 NewSessionTicket is handled by
DoSessionTicket(), which callsSetTicket()(src/internal.c:38937). - A TLS 1.3 NewSessionTicket reaches
SetTicket()atsrc/tls13.c:14515. - In sniffer builds, the sniffer calls
SetTicket()for a monitored flow (src/sniffer.c:3753). - An application, or the ticket parse callback path at
src/internal.c:44230, callswolfSSL_set_SessionTicket()with a new ticket.
The master secret that belongs to the same session is treated differently. wolfSSL_FreeSession() clears it with ForceZero() before the session is released (src/ssl_sess.c:4350).
Reachability and Preconditions
- Build with
HAVE_SESSION_TICKET. The sniffer path also needsWOLFSSL_SNIFFER, and the callback path needsHAVE_SECRET_CALLBACK. - The session already holds a ticket larger than the inline buffer.
- A server the client connects to triggers the release by sending another ticket. No extra authentication state is involved beyond the handshake that delivers the ticket.
- Disclosure needs a second condition outside this issue: the freed block is reused in the same process and something exposes the reused memory.
Impact
Previous session tickets persist in freed heap memory on every renewal. A recovered ticket is one part of a resumption credential. Without the matching secret it cannot be used to resume or impersonate the session. 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 the old ticket over its allocated length before the XFREE() in SetTicket() and in both branches of wolfSSL_set_SessionTicket(). A shared helper that clears and then frees a dynamic ticket would cover the other replacement paths 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.