← ALL ADVISORIES

LOW BYTERAY-2026-0466Disclosed

wolfSSL — Missing Error Code Store in wolfSSL_accept Client-Authentication Fail-Safe

The client-authentication fail-safe in wolfSSL_accept returns WOLFSSL_FATAL_ERROR without storing a cause in ssl->error. wolfSSL_get_error then returns whatever the slot held before, which can be zero or a stale WANT_READ, so an application can misread a fatal authentication failure.

Advisory
BYTERAY-2026-0466
CWE
CWE-544
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; TLS 1.2 and earlier servers that require client authentication
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

Near the end of the server handshake, wolfSSL_accept() checks that the client was authenticated. If ssl->options.peerAuthGood is still false in the TICKET_SENT state, the function stops the handshake and returns WOLFSSL_FATAL_ERROR.

That branch does not write a cause to ssl->error first. The matching client-side check stores NO_PEER_VERIFY before it returns, and the neighboring branches in wolfSSL_accept() all store an error code. Applications are told to call wolfSSL_get_error() after a failed handshake call to learn what happened and whether to retry. After this branch that call returns a leftover value: zero on a reused WOLFSSL object, or WANT_READ from an earlier non-blocking round.

The handshake fails closed, so the client is rejected and authentication is not bypassed. The effect is wrong error reporting, which can lead an application to ignore the failure or to retry a handshake that cannot succeed. The missing store is present in every build, default builds included. Reaching the branch needs a less common configuration.

Affected Products and Versions

  • Component: src/ssl_api_hs.c, wolfSSL_accept(), the TICKET_SENT case.
  • Required build: none. The branch is compiled into every TLS 1.2 server build.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • A default ./configure build contains the branch. It is reached only on servers that require client authentication, in the conditions listed below.
  • Other releases were not checked.

Technical Details

The fail-safe in case TICKET_SENT at src/ssl_api_hs.c:1114-1117:

        if (!ssl->options.peerAuthGood) {
            WOLFSSL_MSG("Client authentication did not happen");
            return WOLFSSL_FATAL_ERROR;
        }

The client-side counterpart at src/ssl_api_hs.c:635-638 sets ssl->error = NO_PEER_VERIFY before the same return. The surrounding accept branches assign ssl->error from the failing call (src/ssl_api_hs.c:1070-1074, src/ssl_api_hs.c:1100-1104, src/ssl_api_hs.c:1119-1122, src/ssl_api_hs.c:1129-1132). The unknown-state default: branch of the accept driver has the same gap (src/ssl_api_hs.c:1171-1173).

What the application then sees:

  1. wolfSSL_accept() returns WOLFSSL_FATAL_ERROR from the fail-safe with ssl->error untouched.
  2. The application calls wolfSSL_get_error(), as the function documentation directs (src/ssl_api_hs.c:347-349).
  3. wolfSSL_get_error() converts a few codes such as WANT_READ, WANT_WRITE and ZERO_RETURN, and otherwise returns ssl->error as it is (src/ssl.c:1684-1701).
  4. The slot holds 0 if an earlier handshake on the same object succeeded, because success clears it (src/ssl_api_hs.c:1166). Otherwise it can hold WANT_READ from an earlier non-blocking call.
  5. The application reads "no error" or "retry" for a failure that is final.

Reachability and Preconditions

  • No build flag is required.
  • The server requires client authentication (peer verification with fail-if-no-certificate behavior).
  • The failure has to surface at the TICKET_SENT check. A missing Certificate message and an empty Certificate message are both rejected earlier, inside the ProcessReply() loop, where ssl->error is stored correctly (src/ssl_api_hs.c:1068-1074). The fail-safe is reached only when those earlier checks are not on the path, for example on session resumption, which skips that loop.
  • The application decides what to do from wolfSSL_get_error(), as event-loop and retry-style code does.
  • The attacker is a remote client. No authentication is needed.

Impact

An application can misclassify a fatal client-authentication failure. It may log or treat the failure as "no error", or it may call wolfSSL_accept() again and spin on a state machine that can no longer make progress. The handshake itself fails and the peer is rejected. There is no authentication bypass. The conditions are uncommon, which is why the issue is rated Low.

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 store a specific error in ssl->error before the return in the TICKET_SENT fail-safe, as the client-side check does with NO_PEER_VERIFY, and to do the same in the unknown-state default: branches. The other bare return WOLFSSL_FATAL_ERROR sites in the handshake drivers should be reviewed for the same gap. Application-side mitigation: treat WOLFSSL_FATAL_ERROR from wolfSSL_accept() as final when wolfSSL_get_error() returns zero, and bound the number of handshake retries.

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