← ALL ADVISORIES

LOW BYTERAY-2026-0510Disclosed

wolfSSL — Missing Zeroization of DTLS Retransmit and Fragment Buffers on Free

wolfSSL keeps plaintext copies of DTLS handshake messages for retransmission and reassembly. DtlsMsgDelete, DtlsMsgDestroyFragBucket and the DTLS 1.3 retransmit and fragment buffer releases free these copies without wiping them, so handshake bytes including Finished verify_data stay in freed heap memory.

Advisory
BYTERAY-2026-0510
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_DTLS (--enable-dtls); the DTLS 1.3 buffers additionally require WOLFSSL_DTLS13
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

DTLS runs over an unreliable transport, so wolfSSL keeps a copy of each handshake message that it may have to send again. DTLS 1.2 holds these in a retransmit pool and holds received fragments in buckets. DTLS 1.3 holds retransmit records and a buffer for the message that is being fragmented.

When these copies are released, the buffers go straight to the allocator. This happens when the handshake completes and the pool is reset, when individual messages are cleaned up, and when the connection is torn down. A remote peer can force teardown by aborting the handshake or letting it time out. The buffers are not overwritten first, so their bytes survive in freed heap memory.

Most of the residue was visible on the wire or is ciphertext. The sensitive parts are the Finished message's verify_data, a value derived from the master secret, and the plaintext handshake message in the DTLS 1.3 fragment buffer. The issue gives no read primitive. Recovering the data needs heap reuse and a separate read of that memory in the same process. DTLS is not part of a default build.

Affected Products and Versions

  • Component: src/internal.c, DtlsMsgDelete() and DtlsMsgDestroyFragBucket(); src/dtls13.c, Dtls13FreeRtxBufferRecord() and Dtls13FreeFragmentsBuffer().
  • Required build: WOLFSSL_DTLS (src/internal.c:10690). The src/dtls13.c sites also need WOLFSSL_DTLS13.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • DTLS is off in a default ./configure build (configure.ac:2642-2643), so a default build does not include this code.
  • Other releases were not checked.

Technical Details

DtlsMsgNew() allocates msg->raw for each stored transmit message (src/internal.c:10705-10720). DtlsMsgDelete() destroys the message's fragment buckets and then releases it (src/internal.c:10731-10739):

        XFREE(item->raw, heap, DYNAMIC_TYPE_DTLS_FRAG);
        XFREE(item, heap, DYNAMIC_TYPE_DTLS_MSG);

DtlsMsgDestroyFragBucket() is a single XFREE of the bucket, which carries its payload inline (src/internal.c:10797-10801). Neither function calls ForceZero. The same file wipes other sensitive buffers before release, for example at src/internal.c:9965 and src/internal.c:10014.

The paths that reach these frees:

  1. Handshake completion: DtlsMsgPoolReset() deletes the transmit list (src/internal.c:11282) and flushes the DTLS 1.3 buffer (src/internal.c:11289).
  2. Per-message cleanup: DtlsTxMsgListClean() deletes messages that will not be retransmitted (src/internal.c:10767).
  3. List deletion: DtlsMsgListDelete() (src/internal.c:10743-10752).
  4. Teardown: FreeSSL_DtlsResources() resets the pool and deletes the receive list (src/internal.c:9685, src/internal.c:9687).
  5. DTLS 1.3: Dtls13FreeRtxBufferRecord() frees the record copy r->data (src/dtls13.c:622-623), which Dtls13RtxNewRecord() filled with XMEMCPY (src/dtls13.c:643-649). Dtls13FreeFragmentsBuffer() frees the fragment buffer (src/dtls13.c:610-611).

The stored messages include ServerKeyExchange, Certificate and cookie material on the server, and ClientKeyExchange, the client Certificate and Finished on the client.

Reachability and Preconditions

  • Build with DTLS.
  • The frees run in normal operation of a DTLS connection: at the end of the handshake, during message cleanup and at teardown. A remote peer can trigger teardown by aborting or stalling the handshake.
  • To learn the residue, an attacker additionally needs same-process heap reuse and a read of the freed memory, for example through a separate information-disclosure defect or a memory dump. This issue does not provide one.

Impact

Plaintext handshake messages are left in freed heap memory. Most of the content is public handshake data or ciphertext, such as the encrypted premaster secret in a ClientKeyExchange. The sensitive residue is the outgoing Finished verify_data and the DTLS 1.3 plaintext held for fragmentation. Where it can be read, leaked verify_data weakens the authentication proof of the affected session.

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 each buffer immediately before it is freed. In DtlsMsgDelete(), wipe item->raw over the stored message length. In DtlsMsgDestroyFragBucket(), wipe the inline payload. In src/dtls13.c, wipe the record copy in Dtls13FreeRtxBufferRecord() and the fragment buffer in its cleanup function. All deletion paths should go through the wiping delete. A zeroizing free helper for DTLS retransmit and staging buffers would cover future call sites. Builds without WOLFSSL_DTLS 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