wolfSSL — Unbounded Blocking I/O in wolfSSL_OCSP_REQ_CTX_nbio on a Blocking BIO
The OpenSSL-compatible OCSP request API has no timeout of its own and is non-blocking only if the caller's BIO is. With a blocking socket BIO, wolfSSL_OCSP_REQ_CTX_nbio blocks in the write and then in the HTTP response loops. A responder that sends a partial header and goes silent holds the calling thread indefinitely.
- Advisory
- BYTERAY-2026-0522
- 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 and OCSP, applications that call OCSP_sendreq_new/OCSP_sendreq_nbio with a blocking socket BIO
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
The OpenSSL compatibility layer offers an OCSP fetch API: wolfSSL_OCSP_sendreq_new() and wolfSSL_OCSP_sendreq_nbio() run an HTTP request and response over a BIO that the application supplies. The work is done in wolfSSL_OCSP_REQ_CTX_nbio().
The function is non-blocking only when the BIO is non-blocking. The request context has no timeout field. With a blocking socket BIO, such as the one wolfSSL_BIO_new_connect() and wolfSSL_BIO_do_connect() produce, the write blocks until the peer takes every byte, and the read runs wolfSSL's generic HTTP response loops over a blocking recv(). A responder that accepts the connection, sends part of a header and then stops keeps the thread inside the call.
This matches the contract OpenSSL documents for its equivalent function, and nothing inside wolfSSL calls the API. The risk is for applications that use it with a blocking BIO and a responder that is attacker-influenced or unreliable. The compatibility layer is not part of a default build.
Affected Products and Versions
- Component:
src/ocsp.c,wolfSSL_OCSP_REQ_CTX_nbio(), reached throughwolfSSL_OCSP_sendreq_nbio(). - Required build: the OpenSSL compatibility layer with OCSP support. Both are off by default (
configure.ac:3315-3317,configure.ac:9058). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default
./configurebuild does not include this API. No code inside the library calls it; the built-in OCSP lookup uses a different path. - Other releases were not checked.
Technical Details
wolfSSL_OCSP_sendreq_new() (src/ocsp.c:1753) creates the context with wolfSSL_OCSP_REQ_CTX_new(), which stores the caller's BIO (src/ocsp.c:1713-1739, assignment at src/ocsp.c:1731). The context holds a buffer, the request, lengths, the BIO and an I/O state. It has nothing that bounds the exchange in time.
wolfSSL_OCSP_sendreq_nbio() calls wolfSSL_OCSP_REQ_CTX_nbio() (src/ocsp.c:2026, src/ocsp.c:1913), which has a write phase and a read phase:
- Write: the function loops on
wolfSSL_BIO_write(ctx->bio, ...)until the request is sent (src/ocsp.c:1959-1970). It returns early for a retry only whenwolfSSL_BIO_should_retry()is true. A blocking socket BIO never reports a retry, so the write blocks. - Read: the function calls
wolfIO_HttpProcessResponseOcspGenericIO()withOCSP_REQ_CTX_bio_cbas the receive callback (src/ocsp.c:1985). That enterswolfIO_HttpProcessResponseGenericIO()(src/wolfio.c:1898), whose header loop (src/wolfio.c:1918-2059) and body loop leave only on data, end of stream, an error or a want-read condition. - Each receive goes through the callback (
src/ocsp.c:1908-1911) toBioReceiveInternal()andwolfSSL_BIO_read()(src/wolfio.c:295-345). For a socket BIO that iswolfIO_Recv()(src/bio.c:367), a plainrecv()(src/wolfio.c:1256-1267) with no receive timeout and noselect(). - The want-read exit that returns to the caller (
src/ocsp.c:1990-1993) is taken only when the BIO reports a retry (src/wolfio.c:334-338). On a blocking BIO it is never taken.
With a BIO placed in non-blocking mode by wolfSSL_BIO_set_nbio() (src/bio.c:2078-2100), the retry convention works as designed and the function returns promptly.
Reachability and Preconditions
- Build with the OpenSSL compatibility layer and OCSP.
- The application calls the OCSP request API with a blocking socket BIO.
- The responder stalls. For a remote party to choose the responder, the application must take the destination from peer-influenced data, such as the responder URL in a certificate under verification. With an operator-configured responder, the same stall occurs if that responder misbehaves.
- No path inside wolfSSL feeds peer-controlled data into this API.
Impact
The calling thread blocks in the call for as long as the responder keeps the connection open without completing the response, despite the function's name. Each stalled fetch holds one thread and one socket, and repeated fetches can exhaust an application's threads. The effect is on availability only and depends on how the application wires the API.
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 an optional timeout on the request context, enforced around the write phase and the shared HTTP read loops, that returns an error when it expires. The alternative is to enforce the non-blocking contract: detect a blocking socket BIO in wolfSSL_OCSP_sendreq_new() and refuse it or warn, and document wolfSSL_BIO_set_nbio() with a retry loop as the required usage.
Applications can put the BIO in non-blocking mode and run the retry loop with their own deadline, or run the fetch on a worker with an external time limit.
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.