← ALL ADVISORIES

LOW BYTERAY-2026-0511Disclosed

wolfSSL — Missing Zeroization of TCP Reassembly Buffers on Sniffer Session Teardown

The wolfSSL sniffer frees its per-flow TCP reassembly buffers without clearing them when a monitored session is torn down. Captured TLS records, with their headers and ciphertext, remain in freed heap memory of the sniffing process.

Advisory
BYTERAY-2026-0511
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 WOLFSSL_SNIFFER (--enable-sniffer)
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

The wolfSSL sniffer keeps two TCP reassembly lists for each monitored flow, one per direction. Captured segments are held in heap packet buffers until the stream can be reassembled into complete TLS records.

When the flow is torn down, FreeSnifferSession() releases both lists. Each packet buffer goes back to the allocator with its contents intact. The same file clears its decode buffer before freeing it, in ssl_FreeZeroDecodeBuffer(). The reassembly buffers get no such step.

What stays behind is captured wire data: TLS record headers and ciphertext, not decrypted plaintext. Reading it requires a separate way to read reused heap memory in the sniffer process. The sniffer is not part of a default build.

Affected Products and Versions

  • Component: src/sniffer.c, FreePacketBuffer(), FreePacketList() and FreeSnifferSession().
  • Required build: WOLFSSL_SNIFFER (--enable-sniffer). The file is compiled only under that macro (src/sniffer.c:78), and the option is off by default (configure.ac:3162-3164).
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • A default ./configure build does not include this code. Other releases were not checked.

Technical Details

FreePacketBuffer() (src/sniffer.c:917-923) releases the segment data and then the list node:

static void FreePacketBuffer(PacketBuffer* del)
{
    if (del) {
        XFREE(del->data, NULL, DYNAMIC_TYPE_SNIFFER_PB_BUFFER);
        XFREE(del, NULL, DYNAMIC_TYPE_SNIFFER_PB);
    }
}

Nothing overwrites del->data before the free. The path to it:

  1. While a flow is monitored, captured TCP segments are stored in packet buffers on the session's cliReassemblyList and srvReassemblyList.
  2. On teardown, FreeSnifferSession() calls FreePacketList() on both lists (src/sniffer.c:949-950).
  3. FreePacketList() walks the list and passes every node to FreePacketBuffer() (src/sniffer.c:927-939).
  4. FreePacketBuffer() frees the data buffer as it is.

The decode buffer in the same file is handled differently. ssl_FreeZeroDecodeBuffer() calls ForceZero() on the buffer and then frees it (src/sniffer.c:7388-7399). The reassembly buffers hold record data from the same monitored connections and are released without that step.

Reachability and Preconditions

  • The library is built with WOLFSSL_SNIFFER, and an application uses the sniffer API to monitor TLS flows.
  • A monitored flow has segments on a reassembly list when its session is removed. Removal happens on flow teardown and when the sniffer itself is freed with ssl_FreeSniffer().
  • The buffered bytes come from the monitored connection. Its endpoints need no authentication to the sniffer.
  • Disclosure needs a second condition outside this issue: the freed block is reused in the same process and something exposes the reused memory.

Impact

Captured TLS record data of monitored third parties persists in freed heap memory after the flow is gone. The residue is record headers and ciphertext. It does not include keys or decrypted plaintext. The consequence is a limited confidentiality exposure that depends on a separate memory-disclosure primitive in the sniffing process.

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 clear each packet's data over its recorded length with ForceZero() in FreePacketBuffer() before the buffer is freed, as ssl_FreeZeroDecodeBuffer() already does for the decode buffer. Routing every sniffer buffer release through one helper that clears before it frees would keep new buffer types from missing the step. There is no configuration workaround short of not building the sniffer. Builds without --enable-sniffer are not affected.

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