← ALL ADVISORIES

LOW BYTERAY-2026-0521Disclosed

wolfSSL — Missing Timeout on Connect and Read in the OpenSSL-Compatible BIO Connect API

wolfSSL_BIO_do_connect passes a literal timeout of zero to the TCP connect helper, so the library's connect timeout and wolfIO_SetTimeout have no effect on this call. Reads on the resulting socket BIO use a blocking recv with no receive timeout. A destination that accepts and then stays silent holds the calling thread.

Advisory
BYTERAY-2026-0521
CWE
CWE-389
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), builds with the OpenSSL compatibility layer (--enable-opensslextra), applications that use BIO_new_connect/BIO_do_connect in the default blocking mode
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

The OpenSSL compatibility layer provides connect BIOs: an application creates one with wolfSSL_BIO_new_connect() and dials it with wolfSSL_BIO_do_connect(). The dial passes a hard-coded timeout of zero to wolfIO_TcpConnect().

wolfSSL's network timeout for connects is a select() wait inside that helper, fed by the global value set with wolfIO_SetTimeout(). The wait runs only for a positive timeout. Because this call site passes a literal zero, an application that has set a global timeout still gets a blocking connect from this API. After the connection is made, reads on the BIO go to a blocking recv() with no receive timeout.

The exposure is narrow. Nothing inside wolfSSL calls this API, the operating system bounds the connect phase, and wolfSSL_BIO_set_nbio() is the supported way to make the BIO non-blocking. The issue matters for applications that pass a peer-influenced host to this API and leave the BIO blocking. The compatibility layer is not part of a default build.

Affected Products and Versions

  • Component: src/bio.c, wolfSSL_BIO_do_connect(), and the socket branch of wolfSSL_BIO_read().
  • Required build: the OpenSSL compatibility layer. --enable-opensslextra is off by default (configure.ac:3315-3317).
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • A default ./configure build does not include this API. No code inside the library calls it.
  • Other releases were not checked.

Technical Details

wolfSSL_BIO_do_connect() walks the BIO chain to the socket BIO and connects (src/bio.c:2695-2708):

        if (wolfIO_TcpConnect(&sfd, b->ip, b->port, 0) < 0 ) {

The fourth argument is the timeout in seconds. In wolfIO_TcpConnect() (src/wolfio.c:1434), the socket is made non-blocking and the select() wait is used only when to_sec > 0, and only in builds with HAVE_IO_TIMEOUT (src/wolfio.c:1557-1566). wolfIO_SetTimeout() sets the global io_timeout_sec (src/wolfio.c:1321-1336), which other callers pass in. This call site passes a literal, so the global value is not used.

The path:

  1. wolfSSL_BIO_new_connect() stores the destination host and port in the BIO (src/bio.c:2564-2612).
  2. wolfSSL_BIO_do_connect() calls wolfIO_TcpConnect() with a zero timeout (src/bio.c:2703). Name resolution and connect() run in blocking mode. The operating system's TCP connect timeout is the only bound.
  3. On success the descriptor is stored in bio->num.fd (src/bio.c:2708).
  4. wolfSSL_BIO_read() on a socket BIO calls wolfIO_Recv() (src/bio.c:367), a plain recv() (src/wolfio.c:1256-1267). No receive timeout is set on the socket and no select() precedes the read.

wolfSSL_BIO_set_nbio() (src/bio.c:2078-2100) switches the BIO to non-blocking mode, and these waits then return a retry condition instead.

Reachability and Preconditions

  • Build with the OpenSSL compatibility layer.
  • The application uses BIO_new_connect and BIO_do_connect and leaves the BIO in blocking mode.
  • For a remote party to choose the destination, the application must take the host from peer-influenced data. An example is OCSP-over-BIO code ported from OpenSSL that connects to the responder URL found in a certificate under verification. wolfSSL's own OCSP and CRL lookups do not use this API.
  • The destination accepts the TCP connection and then sends nothing.

Impact

The calling thread and one socket stay blocked in recv() until data, end of stream or a transport error arrives. Repeated triggers can use up an application's worker threads. This is a limited availability effect inside the application, and it depends on how the application wires the API. There is no confidentiality or integrity impact.

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 pass the configured io_timeout_sec instead of the literal zero in wolfSSL_BIO_do_connect(), so that wolfIO_SetTimeout() applies to this API, and to bound socket BIO reads with a receive timeout or a select() wait that returns a retry status on expiry.

Applications that connect to destinations they do not fully trust can call wolfSSL_BIO_set_nbio() before BIO_do_connect and enforce their own deadline around the retry loop, or use operator-configured hosts instead of peer-supplied ones.

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