← ALL ADVISORIES

LOW BYTERAY-2026-0506Disclosed

wolfSSL — Missing Zeroization of Replaced Session Ticket in Session Cache Overwrite

When AddSessionToCache overwrites an existing cache entry and the new ticket needs a larger buffer, the previous dynamically allocated ticket is freed without being wiped. The old ticket stays in freed heap memory until the allocator reuses the block.

Advisory
BYTERAY-2026-0506
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) and the internal session cache
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

wolfSSL keeps resumable sessions in a session cache. When a session that is already cached is added again, for example after a server sends a new ticket on a resumed connection, AddSessionToCache() updates the entry in place. If the new ticket is longer than the buffer allocated for the old one, the old ticket buffer is released.

That release is a plain free. The helper that scrubs session material, EvictSessionFromCache(), runs only when the entry is not being overwritten. The overwrite path skips it. The bytes of the previous session ticket remain in freed heap memory until the block is reused.

Reading them requires a separate way to read reused heap memory in the same process. The freed block holds only the ticket and not the master secret, so the exposure is limited to the confidentiality of the ticket. The code is compiled only with session tickets enabled, which is not the default.

Affected Products and Versions

  • Component: src/ssl_sess.c, AddSessionToCache(), overwrite branch.
  • Required build: HAVE_SESSION_TICKET (src/ssl_sess.c:2084, src/ssl_sess.c:2197), with the session cache in use. The nonce variant also needs WOLFSSL_TLS13 and WOLFSSL_TICKET_NONCE_MALLOC.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • Session tickets are off in a default ./configure build (configure.ac:9470-9473). They are enabled by --enable-session-ticket and by the nginx, wpa_supplicant, haproxy and lighttpd configurations (configure.ac:9475-9478).
  • Other releases were not checked.

Technical Details

The overwrite branch saves the old ticket pointer when the new ticket does not fit (src/ssl_sess.c:2088-2095):

    if (ticBuff != NULL && cacheSession->ticketLenAlloc < ticLen) {
        /* Save pointer only if separately allocated */
        if (cacheSession->ticket != cacheSession->staticTicket)
            cacheTicBuff = cacheSession->ticket;

Near the end of the function the saved pointer is freed with XFREE(cacheTicBuff, NULL, DYNAMIC_TYPE_SESSION_TICK) (src/ssl_sess.c:2200). AddSessionToCache() does not call ForceZero on it. The same file wipes masterSecret on its other release paths, in EvictSessionFromCache() (src/ssl_sess.c:80) and in wolfSSL_FreeSession() (src/ssl_sess.c:4350).

Data flow:

  1. A handshake completes and the session is added to the cache through AddSession(). One caller is the TLS 1.3 client on receipt of a NewSessionTicket (src/tls13.c:14566).
  2. AddSessionToCache() finds an existing entry for the session and takes the overwrite path. EvictSessionFromCache() is called only when the entry is not an overwrite (src/ssl_sess.c:2066-2067).
  3. The incoming ticket is longer than the entry's allocation, so the entry's dynamically allocated ticket is saved in cacheTicBuff (src/ssl_sess.c:2088-2095).
  4. The saved buffer is freed without a wipe (src/ssl_sess.c:2200).
  5. With WOLFSSL_TICKET_NONCE_MALLOC, the old ticket nonce is freed the same way (src/ssl_sess.c:2204).

Reachability and Preconditions

  • Build with session tickets and the session cache.
  • A cached session is added again with a ticket longer than the cached entry's ticket allocation, and the cached ticket was in a heap buffer. This is a routine cache update. It occurs, for example, when a server renews its ticket on a resumed connection.
  • To learn the residue, an attacker additionally needs a memory-disclosure primitive in the same process that returns the reused block. This issue does not provide one.

Impact

A previous session ticket, which a server may still accept for resumption until it expires, is left in freed heap memory. Recovery depends on a second defect. The ticket alone is not enough to resume the session, because the master secret is not in the freed block. No integrity impact follows directly.

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 old ticket buffer over its allocated length before the free at the end of AddSessionToCache(), and to wipe the dynamically allocated nonce before its release. A shared wipe-then-free helper used by the eviction, free and overwrite paths would keep them consistent. Builds without HAVE_SESSION_TICKET do not contain this code.

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