wolfSSL — Missing Zeroization of DTLS Fragment Bucket on Reassembly Growth
When DTLS handshake fragments overlap or bridge two reassembly buckets, DtlsMsgCombineFragBuckets grows a bucket with a realloc. The old bucket is released without being wiped, in both the realloc and the no-realloc builds, and its handshake fragment bytes stay in freed heap memory.
- Advisory
- BYTERAY-2026-0509
- 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)
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
DTLS handshake messages can arrive split across datagrams. wolfSSL stores the pieces in small heap buckets and merges buckets when a new fragment overlaps one or bridges two. DtlsMsgCombineFragBuckets() grows the surviving bucket to hold the merged data.
The growth uses XREALLOC. When the reallocation moves the block, the old bucket is freed by the allocator and the code has no chance to overwrite it. Builds without XREALLOC allocate a new bucket, copy, and free the old one with a plain XFREE. Neither path wipes the old bucket, so the handshake fragment bytes it held remain in freed heap memory.
A remote DTLS peer can cause the release at will by sending overlapping fragments. Turning the residue into a disclosure needs heap reuse and a read primitive in the same process. Most DTLS 1.2 handshake bytes are visible on the wire in any case. The exception is material received after ChangeCipherSpec, notably fragments of the Finished message. DTLS is not part of a default build.
Affected Products and Versions
- Component:
src/internal.c,DtlsMsgCombineFragBuckets(), in the DTLS 1.2 fragment reassembly code. - Required build:
WOLFSSL_DTLS(src/internal.c:10690). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- DTLS is off in a default
./configurebuild (configure.ac:2642-2643), so a default build does not include this code. - Other releases were not checked.
Technical Details
Both growth variants are in one block (src/internal.c:10842-10865):
#ifdef XREALLOC
DtlsFragBucket* tmp = (DtlsFragBucket*)XREALLOC(*chosenBucket,
sizeof(DtlsFragBucket) + newSz, heap, DYNAMIC_TYPE_DTLS_FRAG);
#else
DtlsFragBucket* tmp = (DtlsFragBucket*)XMALLOC(
sizeof(DtlsFragBucket) + newSz, heap, DYNAMIC_TYPE_DTLS_FRAG);
#endif
A DtlsFragBucket carries its payload inline, so the block that is released contains the fragment data. With XREALLOC, a successful call that moves the block frees the previous one implicitly. Without it, WOLFSSL_NO_REALLOC undefines XREALLOC (wolfssl/wolfcrypt/settings.h:5479-5482) and the fallback copies the bucket and frees the old one at src/internal.c:10863. There is no ForceZero on either path. Other buffers in the same file are wiped before release, for example at src/internal.c:9965 and src/internal.c:10014.
Data flow:
- A DTLS peer sends handshake fragments. Reassembly stores them through
DtlsMsgInsertFragment(). - A fragment overlaps an existing bucket or bridges two. The merge walker calls
DtlsMsgCombineFragBuckets()(src/internal.c:11080). - The chosen bucket is grown to the merged size (
src/internal.c:10843-10844, orsrc/internal.c:10846-10847in the fallback). - The previous bucket is released unwiped, by the allocator inside the reallocation or by the
XFREEatsrc/internal.c:10863. The freed block keeps the fragment bytes until it is reused.
Reachability and Preconditions
- Build with DTLS.
- A remote peer in a DTLS handshake that sends overlapping fragments. No authentication is needed to reach reassembly. The sensitive case needs fragments received after ChangeCipherSpec, such as Finished fragments.
- To learn the residue, an attacker additionally needs a memory-disclosure primitive in the same process. This issue does not provide one.
Impact
Handshake fragment bytes are left in freed heap memory each time buckets are merged with growth. Most of that data is public handshake content. Fragments of the Finished message, which is sent under the negotiated keys, are the sensitive part. Disclosure depends on heap reuse and a second defect that reads the reused block.
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 stop growing these buckets with a realloc, because the old block cannot be wiped after the call. Allocate a new bucket, copy the payload, wipe the old bucket over its header and current payload size, and then free it. The existing fallback needs the same wipe before its free. A single bucket-free helper that always wipes would keep the growth and delete paths consistent. 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.