← ALL ADVISORIES

LOW BYTERAY-2026-0513Disclosed

wolfSSL — Missing Zeroization of Old Record Buffers on Buffer Growth

When the record layer needs a larger output buffer, wolfSSL copies the queued record bytes to a new block and frees the old one without clearing it. The shrink paths clear the same buffers before freeing them. The input buffer is cleared on growth only while send-side encryption is on.

Advisory
BYTERAY-2026-0513
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), default builds; the threaded-crypt slot path needs WOLFSSL_THREADED_CRYPT
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

The TLS record layer keeps dynamic input and output buffers. When a buffer is too small, wolfSSL allocates a larger block, copies the bytes still in use, and frees the old block.

On the output side the old block is freed with its contents intact. ShrinkOutputBuffer() and ShrinkInputBuffer() both call ForceZero() before they free the same buffers, so the grow paths are the exception. On the input side the old block is cleared only when a flag is set, and the caller derives that flag from the send-direction encryption state.

The freed blocks hold queued record data: cleartext handshake messages before keys are established, and sealed ciphertext afterwards. Reading it requires block reuse in the same process and a separate memory-disclosure primitive. Default builds are affected.

Affected Products and Versions

  • Component: src/internal.c, GrowOutputBuffer(), GrowAnOutputBuffer() and GrowInputBuffer() with ResizeInputBufferStorage().
  • Default builds: the GrowOutputBuffer() and input-buffer paths.
  • WOLFSSL_THREADED_CRYPT builds (off by default): the GrowAnOutputBuffer() slot path.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • Other releases were not checked.

Technical Details

GrowOutputBuffer() copies the pending bytes and releases the previous dynamic block (src/internal.c:12764-12773):

    if (ssl->buffers.outputBuffer.dynamicFlag) {
        XFREE(ssl->buffers.outputBuffer.buffer -
              ssl->buffers.outputBuffer.offset, ssl->heap,
              DYNAMIC_TYPE_OUT_BUFFER);
    }

There is no ForceZero() before the free. The related paths:

  1. A send that does not fit the current output buffer goes through CheckAvailableSize(), which calls GrowOutputBuffer() (src/internal.c:12925-12929). Once the buffer is dynamic, each further growth frees the previous dynamic block uncleared.
  2. GrowAnOutputBuffer() does the same for a threaded-crypt slot buffer: copy, then a bare free (src/internal.c:12684-12690). It is reached from the threaded send path (src/internal.c:29738).
  3. ResizeInputBufferStorage() clears the old input block only when its secureClear argument is set (src/internal.c:12822-12825). GrowInputBuffer() passes IsEncryptionOn(ssl, 1) for it (src/internal.c:12869-12871), which is the send-direction state. While that is off, old input blocks holding received record bytes are freed uncleared.

The shrink paths show the intended handling. ShrinkOutputBuffer() clears the region that still holds record data and then frees (src/internal.c:12451-12456). ShrinkInputBuffer() clears the whole buffer and then frees (src/internal.c:12526-12529).

Reachability and Preconditions

  • No build option is needed for the output and input paths. The slot path needs WOLFSSL_THREADED_CRYPT.
  • The output path runs when a send is large enough to grow a buffer that is already dynamic. Either side of a connection can cause that with ordinary traffic.
  • The input path leaves data behind only while encryption is off for the send direction, for example before keys are established.
  • Disclosure needs a second condition outside this issue: the freed block is reused in the same process and something exposes the reused memory.

Impact

Freed heap blocks keep previously queued record content. Before keys are established this is handshake data that is also visible on the wire. Afterwards it is sealed records with their MAC and padding. Keys and plaintext secrets are not in these blocks. The consequence is a limited exposure of heap content 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 give the grow paths the same treatment as the shrink paths. GrowOutputBuffer() and GrowAnOutputBuffer() should call ForceZero() over the old buffer before freeing it. On the input side, the decision to clear should not depend on the send-direction encryption state: either clear unconditionally in ResizeInputBufferStorage(), or base the flag on whether the input buffer has held sensitive content.

There is no configuration workaround for the default paths.

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