← ALL ADVISORIES

LOW BYTERAY-2026-0476Disclosed

wolfSSL — Unchecked Record Cursor Advance in Async Crypto Pend-Resume Paths of Record Processing

In asynchronous-crypto builds, two pend-resume blocks in the TLS 1.3 record receiver add the record padding length to the input cursor without checking the cursor against the buffer length. No current input reaches these blocks with an over-advanced cursor; the gap matters for fixes that guard only the normal record-done path.

Advisory
BYTERAY-2026-0476
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), TLS 1.3 in builds with WOLFSSL_ASYNC_CRYPT; the second site also needs WOLFSSL_POST_HANDSHAKE_AUTH
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

When the TLS 1.3 receive loop in DoProcessReplyEx() (src/internal.c) finishes a record, it skips the record's padding by adding ssl->keys.padSz to the read index of the input buffer. Builds with WOLFSSL_ASYNC_CRYPT contain two more copies of that advance. They run when a handshake handler returns WC_PENDING_E: one for a pending key-schedule operation, one for pending post-handshake authentication.

Neither copy checks that the index is still inside the input buffer before it adds padSz. If the index had already moved past the end of the record, the addition would push it further, and the function would return WC_PENDING_E with that index for the next call to inherit.

On the tested code no input produces that state. The only known code that over-advances the record index returns synchronously and never pends, and every handler that pends consumes its message exactly. This is a latent defect. Its weight is in remediation: a bounds check added only on the normal record-done path leaves these two build-conditional copies unguarded. Default builds do not define WOLFSSL_ASYNC_CRYPT.

Affected Products and Versions

  • Component: src/internal.c, DoProcessReplyEx(), the two pend-resume record-finish blocks after DoTls13HandShakeMsg().
  • Required build: WOLFSSL_ASYNC_CRYPT with TLS 1.3. The second block also requires WOLFSSL_POST_HANDSHAKE_AUTH. Asynchronous crypto is disabled by default (configure.ac:11989).
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • A default build does not include these blocks and runs the synchronous record-done path.
  • Other releases were not checked.

Technical Details

The first block is at src/internal.c:26306-26318, inside #if defined(WOLFSSL_ASYNC_CRYPT) (src/internal.c:26302). It runs when a handler returned WC_PENDING_E with ssl->kdfMsgStep > 0, and its last branch is:

                            else if (IsEncryptionOn(ssl, 0)) {
                                ssl->buffers.inputBuffer.idx +=
                                    ssl->keys.padSz;
                            }

The second block has the same shape at src/internal.c:26333-26345, guarded by WOLFSSL_ASYNC_CRYPT and WOLFSSL_POST_HANDSHAKE_AUTH (src/internal.c:26320). The test (idx - curStartIdx) < curSize is relative to the record. It is not a comparison with inputBuffer.length.

  1. The peer's record content is dispatched through DoTls13HandShakeMsg() with the live index (src/internal.c:26298-26301).
  2. A handler returns WC_PENDING_E. One of the two blocks adds padSz to the index with no length check.
  3. The shared error gate returns WC_PENDING_E for a non-DTLS connection (src/internal.c:26367-26383). The advanced index carries over to the next ProcessReply() call.
  4. On that call, the only containment is the negative-length check in GetInputData_ex() for non-DTLS connections (src/internal.c:24669).

The synchronous record-done advance is at src/internal.c:26446. It is not executed on the pend-resume path. The known source of an over-advanced index is the branch in DoTls13NewSessionTicket() that skips a ticket when ECH was rejected (src/tls13.c:14462-14465), described in BYTERAY-2026-0315. That branch returns 0 and does not pend, so it does not feed these blocks.

Reachability and Preconditions

  • Build: WOLFSSL_ASYNC_CRYPT, on a path where a TLS 1.3 handler actually returns WC_PENDING_E.
  • Runtime: a TLS 1.3 connection over TCP receiving a padded record.
  • Attacker position: the TLS session peer.
  • Missing precondition: a handler that both over-advances the index and pends. None exists in the tested code, so the blocks cannot be reached with a corrupt index.

Impact

None is realized on the tested code. With the precondition met, the index would be advanced past the record a second time and handed to the next read, the same index corruption described in BYTERAY-2026-0315, in asynchronous builds only. The practical risk is a partial fix: guarding the synchronous record-done site alone leaves the same class of defect present in one build configuration while it appears closed in default builds.

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 the index against the buffer length before the padSz advance in both pend-finish blocks and to fail with a buffer error when it is out of range. A single shared helper for the record-finish logic, called from the synchronous path and from both pend-resume blocks, would prevent an unguarded copy in any build. Extending the negative-length check to the DTLS branch, and adding regression tests built with WOLFSSL_ASYNC_CRYPT, are further steps.

No configuration workaround is needed for the tested code. Builds without WOLFSSL_ASYNC_CRYPT do not contain these blocks.

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