← ALL ADVISORIES

LOW BYTERAY-2026-0478Disclosed

wolfSSL — Missing Exact-Consumption Check in TLS 1.3 Handshake Dispatcher

DoTls13HandShakeMsgType checks that a handshake message fits in the buffer before dispatch but never checks afterwards that the handler consumed exactly the message. The TLS 1.2 dispatcher has that check. A TLS 1.3 handler that over-advances the record cursor and returns success is therefore not caught at the dispatcher.

Advisory
BYTERAY-2026-0478
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), all builds with TLS 1.3 or DTLS 1.3, including the default configuration; the one known handler that over-advances the cursor requires ECH, which is off by default
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

Every TLS 1.3 handshake message passes through one dispatcher, DoTls13HandShakeMsgType(). It routes the message to a handler, and the handler advances the shared record cursor past the bytes it parsed.

The TLS 1.2 dispatcher, DoHandShakeMsgType(), records where the cursor should end up and fails the handshake with DECODE_E if the handler left it anywhere else. The TLS 1.3 dispatcher has no such check. It tests only that the message fits before dispatch and returns whatever cursor position the handler left.

The missing check does nothing by itself. It matters when a handler over-advances the cursor and still returns success. One such handler exists in the tested tree and is described in BYTERAY-2026-0315; the dispatcher does not stop it. The dispatcher is in default builds. The known over-advancing handler needs ECH, which is not.

Affected Products and Versions

  • Component: src/tls13.c, DoTls13HandShakeMsgType().
  • Required build: TLS 1.3 or DTLS 1.3. No other option is needed for the check to be absent.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • The dispatcher is compiled into a default build. The known handler that over-advances the cursor requires ECH (--enable-ech) and session tickets, and the memory-safety consequence requires DTLS 1.3; none of these is enabled by default.
  • Other releases were not checked.

Technical Details

On entry the dispatcher makes one bounds check (src/tls13.c:15830-15832):

    /* make sure we can read the message */
    if (*inOutIdx + size > totalSz)
        return INCOMPLETE_DATA;

It then dispatches on the message type and returns from the function tail (src/tls13.c:16251-16261) without looking at *inOutIdx again.

The TLS 1.2 dispatcher sets expectedIdx = *inOutIdx + size before the switch (src/internal.c:20659) and rejects any drift after it (src/internal.c:20944-20950). That check does not cover messages handled by the TLS 1.3 code:

  1. DoHandShakeMsgType() hands hello_retry_request to DoTls13HandShakeMsgType() and returns its result directly, before expectedIdx is computed (src/internal.c:20645-20650).
  2. Under WOLFSSL_NO_TLS12, DoDtlsHandShakeMsg() calls the TLS 1.3 dispatcher on the shared cursor with no check of its own (src/internal.c:21819-21821, src/internal.c:21905-21907).
  3. The stream path DoTls13HandShakeMsg() (src/tls13.c:16341-16342) and the DTLS 1.3 receive path (src/dtls13.c:2041-2043, src/dtls13.c:2066-2071) take the returned index as it is.
  4. The buffered paths (src/dtls13.c:392, src/internal.c:21667) pass a local index that is not stored back. They are contained by that structure and not by a check.

The known producer is the ECH-skip branch of the post-handshake NewSessionTicket handler, which executes *inOutIdx += size + ssl->keys.padSz; return 0; (src/tls13.c:14462-14465). The dispatcher returns that as success. DoProcessReplyEx() then adds padSz a second time (src/internal.c:26443-26446) and the cursor ends up past the buffered length.

Reachability and Preconditions

  • Any build with TLS 1.3 contains the dispatcher without the check.
  • For the missing check to have an effect, a TLS 1.3 handler must over-advance the cursor and return 0.
  • The known case needs a client built with ECH and session tickets, ECH configured, and a server that did not accept ECH. The attacker is the TLS peer, who holds the traffic keys. An on-path attacker cannot forge the record.

Impact

On its own this issue has no effect. As the place where an over-advance should be rejected, its absence lets the cursor corruption described in BYTERAY-2026-0315 reach the record layer: out-of-bounds heap reads and writes on the DTLS 1.3 receive path, and a terminated connection on the stream TLS 1.3 path. Considered separately from that producer, the consequence is limited to availability.

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 port the TLS 1.2 check: record the expected end index before the handler switch in DoTls13HandShakeMsgType() and return DECODE_E when a successful handler left the cursor anywhere else. That covers the stream, DTLS 1.3, buffered and WOLFSSL_NO_TLS12 paths, since all of them go through this dispatcher. The hello_retry_request delegation and the direct calls in DoDtlsHandShakeMsg() should also be covered. Building without ECH removes the known over-advancing 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