← ALL ADVISORIES

LOW BYTERAY-2026-0441Disclosed

wolfSSL — One-Byte Heap Over-Read in Sniffer Static-ECC ClientKeyExchange Handling

In the sniffer's static-ECC key setup, SetupKeys skips the one-byte length prefix of the ClientKeyExchange body and then checks the encoded point length against the byte count from before the skip. A body of exactly the expected point size makes the ECC point import read one byte past the heap buffer that holds the message.

Advisory
BYTERAY-2026-0441
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 a static ECC server key loaded, for sessions below TLS 1.3 that negotiate static ECDH
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

When the wolfSSL sniffer holds a static ECC private key for the monitored server, it imports the client's public point from the ClientKeyExchange in SetupKeys(). The expected point length is fixed by the operator's key, 65 bytes for P-256. Below TLS 1.3 the body starts with a one-byte length, which the code skips before the import.

The length check that follows still counts the skipped byte. A ClientKeyExchange body of exactly the expected point size passes the check although one byte less is available at the advanced pointer. The point import then reads one byte past the end of the message. The point is malformed by construction and is rejected after the read. The byte is not used or disclosed. The consequence is limited to a crash of the sniffer process when the heap buffer ends at an unmapped page. The sniffer is not part of a default build.

Affected Products and Versions

  • Component: src/sniffer.c, SetupKeys(), the static-ECC block.
  • Required build: WOLFSSL_SNIFFER (--enable-sniffer) with ECC.
  • 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 static-ECC block sets the expected length, skips the prefix and then validates (src/sniffer.c:3007-3019):

                args->length = wc_ecc_size(&args->key->priv.ecc) * 2 + 1;
                if (!IsAtLeastTLSv1_3(session->sslServer->version)) {
                    input += 1; /* Don't include the TLS length for the key. */
                }

                if (args->length > *sslBytes) {

*sslBytes is not reduced when input advances. The consumer is wc_ecc_import_x963_ex(input, args->length, ...) at src/sniffer.c:3034.

  1. The client's ClientKeyExchange reaches ProcessClientKeyExchange(), which calls SetupKeys() on the static-key path (src/sniffer.c:3523).
  2. With a P-256 key, args->length is 65 (src/sniffer.c:3008).
  3. input advances by one (src/sniffer.c:3012).
  4. With a 65-byte body, *sslBytes is 65 and the check at src/sniffer.c:3015 passes, because 65 is not greater than 65.
  5. The import reads 65 bytes from the advanced pointer. Only 64 are valid. The last byte read is one past the end of the message.

The sniffer's input buffer is allocated to the exact size of the data it holds, with no padding for TCP (src/internal.c:12800). When the ClientKeyExchange is the last message of the last record in that buffer, the read leaves the heap block. The Curve25519 and Curve448 branches of the same function do not skip a prefix, and their checks match their reads (src/sniffer.c:3115, src/sniffer.c:3198).

Reachability and Preconditions

  • Sniffer build, configured with a static ECC key for the monitored server. With an RSA keyfile the RSA branch is taken instead.
  • The monitored session negotiates TLS 1.2 or earlier with a static-ECDH cipher suite, so the one-byte skip applies.
  • The attacker is the TLS client of the monitored session, or controls that client's traffic. The sniffer applies no authentication to captured handshake bytes.
  • The crafted ClientKeyExchange must be the last message in an exactly sized input buffer.

Impact

A remote, unauthenticated heap over-read of one byte in the sniffer process. The byte is parsed by the point import and dropped when the import fails. Nothing is disclosed 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 account for the skipped byte in the same step as the skip: reduce the remaining count when input advances, or keep a local count of remaining bytes, and compare the point length with that. The static-RSA branch has the same skip-then-check shape and is described in BYTERAY-2026-0440. A sniffer that does not load a static ECC key does not take 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