← ALL ADVISORIES

LOW BYTERAY-2026-0474Disclosed

wolfSSL — Out-of-Bounds Read in Sniffer SSLv2 Hello Probe

The wolfSSL sniffer probes the first four bytes of a new data segment for an SSLv2-style hello after checking only that one byte is present. A 1 to 3 byte segment is read up to three bytes past its end; with chained input the read can cross the end of an exactly sized heap buffer.

Advisory
BYTERAY-2026-0474
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 (--enable-sniffer); a read past a heap allocation requires WOLFSSL_SNIFFER_CHAIN_INPUT
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

CheckPreRecord() in src/sniffer.c prepares captured data before the sniffer treats it as a TLS record. Before the first ClientHello of a session it runs a legacy probe. The probe builds a 16-bit length from bytes 0 and 1 and compares bytes 2 and 3 with fixed constants, to recognise an SSLv2-style hello.

The only size check before the probe guarantees one readable byte. The guard inside the probe bounds the length declared in the data. It does not check how many bytes are present. A first data segment of 1 to 3 bytes whose first byte is not the TLS handshake type is read up to three bytes past its end.

The extra bytes are compared with constants and discarded, so nothing is disclosed. In builds without WOLFSSL_SNIFFER_CHAIN_INPUT, short segments sit in storage with spare room and the reads stay inside allocated memory. With WOLFSSL_SNIFFER_CHAIN_INPUT, fragments are assembled into an exactly sized heap buffer and the read can cross its end. The sniffer is not part of a default build.

Affected Products and Versions

  • Component: src/sniffer.c, CheckPreRecord(), reached from the ssl_DecodePacket family through ssl_DecodePacketInternal().
  • Required build: the sniffer, which is disabled by default (configure.ac:3161-3162). The probe is compiled in every sniffer build. A read outside an allocation requires WOLFSSL_SNIFFER_CHAIN_INPUT.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • A default ./configure build does not include the sniffer.
  • Other releases were not checked.

Technical Details

The probe is at src/sniffer.c:6588-6593:

    if (session->flags.clientHello == 0 && **sslFrame != handshake) {
        /* Sanity check the packet for an old style client hello. */
        int rhSize = (((*sslFrame)[0] & 0x7f) << 8) | ((*sslFrame)[1]);

        if ((rhSize <= (*sslBytes - 2)) &&
            (*sslFrame)[2] == OLD_HELLO_ID && (*sslFrame)[3] == SSLv3_MAJOR) {

The size check that precedes it is if (*sslBytes <= 0) at src/sniffer.c:6563. Nothing between that check and the probe requires four bytes. The #ifdef OLD_HELLO_ALLOWED guard starts at src/sniffer.c:6594, after the reads, so only the call to DoOldHello() is conditional.

  1. ssl_DecodePacketInternal() (src/sniffer.c:7112) derives the frame pointer and byte count from the captured TCP payload and calls CheckPreRecord() (src/sniffer.c:7223). The remote endpoint controls both the bytes and the segment length.
  2. With one byte present, the read of index 1 at src/sniffer.c:6590 is one byte past the data.
  3. With two bytes present and a declared length of zero, the guard at src/sniffer.c:6592 passes and indexes 2 and 3 are read at src/sniffer.c:6593, one and two bytes past the data.
  4. With three bytes present, index 3 is one byte past the data.

Where the bytes land depends on the storage. In builds without chained input, a short segment at session start is held in the 5-byte static buffer inside the WOLFSSL object, in a heap input buffer of at least 6 bytes, or in the caller's packet buffer. Indexes 1 to 3 stay inside allocated memory in each case. With WOLFSSL_SNIFFER_CHAIN_INPUT, the packet chain is copied into a buffer allocated at exactly the total length (src/sniffer.c:7145). A short segment that ends at that allocation is read 1 to 3 bytes past it.

Reachability and Preconditions

  • Build: sniffer enabled. For a read past a heap allocation, WOLFSSL_SNIFFER_CHAIN_INPUT as well.
  • Runtime: a monitored session that has not yet delivered a ClientHello, and a first data segment, or the first after a partial merge, of 1 to 3 bytes whose first byte is not 0x16.
  • Attacker position: the remote endpoint of a monitored session, or anyone who can inject bytes into it. No privilege on the sniffer host and no authentication are needed.
  • For a crash, the exactly sized buffer must also end on a page boundary.

Impact

A read of 1 to 3 bytes past the data. The values are compared with constants and dropped, so there is no information disclosure. In a chained-input build the read can leave the heap allocation, and the sniffer process can crash if the allocation ends at a page boundary. The consequence is limited to availability of the monitoring process, and it depends on a non-default option and on memory 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 validate the number of bytes present. Require at least two bytes before reading index 1 and at least four before comparing indexes 2 and 3, in place of or in addition to the declared-length condition. Workaround: build the sniffer without WOLFSSL_SNIFFER_CHAIN_INPUT where chained input is not needed. In that configuration the reads stay inside allocated memory.

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