← ALL ADVISORIES

LOW BYTERAY-2026-0439Disclosed

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(), the EXT_PRE_SHARED_KEY case.
  • Required build: WOLFSSL_SNIFFER (--enable-sniffer), WOLFSSL_TLS13 and HAVE_SESSION_TICKET. TLS 1.3 is on by default. Session tickets are off by default (configure.ac:9469-9483), and --enable-sniffer does not turn them on (configure.ac:4007-4015).
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • A default ./configure build 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:

  1. The client sends a ClientHello whose last extension is pre-shared-key (type 41) with extLen 2 or 3 and an identities length of zero.
  2. extLen < OPAQUE16_LEN is false. The identities check at src/sniffer.c:4569 passes because 0 + 2 + 0 is not greater than extLen. idx becomes 2.
  3. The read at src/sniffer.c:4576 takes input[2] and input[3]. With extLen 2 both bytes are past the extension. With extLen 3 one is.
  4. The check at src/sniffer.c:4577 is 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