wolfSSL — Out-of-Bounds Read of PSK Identity Length in Sniffer TLS 1.3 ClientHello Parsing
The wolfSSL sniffer reads the two-byte PSK identity length from a ClientHello pre-shared-key extension before it checks that those bytes lie inside the extension. A truncated extension of 2 or 3 bytes causes a read of up to two bytes past the extension and, at the end of an exactly sized input buffer, past the heap allocation.
- Advisory
- BYTERAY-2026-0439
- CWE
- CWE-125
- CVSS
- 3.7 (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L)
- Vendor
- wolfSSL
- Product
- wolfSSL
- Reported
- 2026-09-28
- Disclosure
- 2026-12-03
- Affected
- wolfSSL 5.9.2 (tested at master commit d95483f), sniffer builds (WOLFSSL_SNIFFER) with TLS 1.3 and HAVE_SESSION_TICKET
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
The wolfSSL sniffer decodes captured TLS traffic passively. For each ClientHello it walks the extension list in ProcessClientHello(). In builds with session-ticket support, that walk parses the TLS 1.3 pre-shared-key extension.
The parser reads the two-byte PSK identity length before it checks that those two bytes are inside the extension. A pre-shared-key extension of 2 or 3 bytes with an identities length of zero passes the earlier checks. The read then takes one or two bytes from beyond the extension. When the ClientHello ends an exactly sized input buffer, those bytes are outside the heap allocation.
The value read is rejected by the check that follows it, so it is not disclosed and nothing is written. The consequence is limited to a crash of the sniffer process when the allocation ends at an unmapped page. The code is present only in sniffer builds that also enable session tickets. Default builds are not affected.
Affected Products and Versions
- Component:
src/sniffer.c,ProcessClientHello(), theEXT_PRE_SHARED_KEYcase. - Required build:
WOLFSSL_SNIFFER(--enable-sniffer),WOLFSSL_TLS13andHAVE_SESSION_TICKET. TLS 1.3 is on by default. Session tickets are off by default (configure.ac:9469-9483), and--enable-snifferdoes not turn them on (configure.ac:4007-4015). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default
./configurebuild does not include the sniffer or this branch. - Other releases were not checked.
Technical Details
The extension loop checks each extension length against the whole remaining input only (src/sniffer.c:4482). It does not bound reads inside an extension. The pre-shared-key case then reads the identity length and checks it afterwards (src/sniffer.c:4573-4577):
idx += OPAQUE16_LEN;
/* PSK identity */
idLen = (word16)((input[idx] << 8) | input[idx+1]);
if ((word32)idLen + OPAQUE16_LEN + idx > (word32)extLen) {
Before this point the case checks only extLen < OPAQUE16_LEN (src/sniffer.c:4563) and the identities length. That guarantees two bytes, not four. The data flow for a truncated extension is:
- The client sends a ClientHello whose last extension is pre-shared-key (type 41) with
extLen2 or 3 and an identities length of zero. extLen < OPAQUE16_LENis false. The identities check atsrc/sniffer.c:4569passes because0 + 2 + 0is not greater thanextLen.idxbecomes 2.- The read at
src/sniffer.c:4576takesinput[2]andinput[3]. WithextLen2 both bytes are past the extension. WithextLen3 one is. - The check at
src/sniffer.c:4577is always true for these lengths. The parser returns an error and the value is discarded.
Whether the read leaves the allocation depends on the input buffer. On the reassembly path the sniffer grows the input buffer to the exact record size and copies the record into it (src/sniffer.c:6325-6339). The allocation has no padding for TCP (src/internal.c:12800). A ClientHello that ends that buffer puts the read up to two bytes past the heap block.
Reachability and Preconditions
- Sniffer build with TLS 1.3 and
HAVE_SESSION_TICKET. - The attacker is the TLS client of a session that the sniffer monitors, or controls that client's traffic. The sniffer applies no authentication to captured handshake bytes.
- For the read to leave the heap block, the crafted ClientHello must be the last bytes of an exactly sized input buffer. The client can arrange this with TCP segmentation.
- No interaction by the sniffer operator is needed.
Impact
A remote, unauthenticated heap over-read of one or two bytes in the sniffer process. The bytes are not returned to anyone and no memory is modified. The process can crash if the allocation ends at an unmapped page boundary, which stops monitoring. The outcome depends on heap layout.
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 check, before the identity length is read, that the two length bytes fit inside the extension, and to keep the existing check on the identity body after the read. This is the order already used for the identities length. Padding the sniffer input buffer would add a margin but is not needed once the order is corrected. Sniffer builds without HAVE_SESSION_TICKET do not compile this branch.
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
- Pre-shared-key case in
ProcessClientHelloat the tested commit - BYTERAY-2026-0438, heap out-of-bounds read in the sniffer reassembly record scanner
- BYTERAY-2026-0440, out-of-bounds read in the sniffer static-RSA key exchange
- BYTERAY-2026-0441, one-byte over-read in the sniffer static-ECC key exchange