wolfSSL — NULL Pointer Dereference in wolfSSL_BIO_new_accept on Bracketed IPv6 Strings Without a Port
In IPv6 builds of the OpenSSL compatibility layer, wolfSSL_BIO_new_accept searches for a colon after the closing bracket of an IPv6 literal and passes the result to atoi without a NULL check. An accept string such as "[::1]" with no port makes the process read through a NULL pointer.
- Advisory
- BYTERAY-2026-0362
- CWE
- CWE-690
- CVSS
- 5.9 (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H)
- Vendor
- wolfSSL
- Product
- wolfSSL
- Reported
- 2026-09-28
- Disclosure
- 2026-12-03
- Affected
- wolfSSL 5.9.2 through 5.9.4, builds with OPENSSL_EXTRA and WOLFSSL_IPV6 (--enable-opensslextra --enable-ipv6)
- Fixed in
- Master commit 1495a4d6323c46ea8c467f64349c13e219c7f7d7 (PR 11868, merged 2026-11-04). Not in a wolfSSL stable release as of 2026-12-03.
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
wolfSSL_BIO_new_accept() is the OpenSSL-compatible call that creates a listening socket BIO from a string such as "4433" or "[::1]:4433". When wolfSSL is built with IPv6 support, the function looks for ] and then for the : that should follow it, and converts what it found to a port number.
The search for : can fail. The function does not check for that. A string that contains ] with no later colon, for example "[::1]", leaves the port pointer NULL, and the next line passes it to atoi(). That is undefined behaviour; on common C libraries it is a read at address zero and the process stops.
The string is an argument supplied by the application. A remote party can trigger the crash only if the application builds its listen address from input that party controls. The code is compiled only with the OpenSSL compatibility layer and WOLFSSL_IPV6, neither of which is on by default.
Affected Products and Versions
- Component: OpenSSL compatibility layer,
src/bio.c,wolfSSL_BIO_new_accept()(also reachable through theBIO_new_acceptmacro,wolfssl/openssl/ssl.h:959). - Required build:
OPENSSL_EXTRAandWOLFSSL_IPV6.--enable-ipv6defines the second and is off by default (configure.ac:3410-3419). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- The
v5.9.2-stableandv5.9.4-stabletags contain the same unchecked use. Fixed on master by commit 1495a4d6323c46ea8c467f64349c13e219c7f7d7 (PR 11868); no release contains the fix. - A default
./configurebuild does not include this code. Earlier releases were not checked.
Technical Details
From src/bio.c:2631-2638:
const char* portStr = port;
#ifdef WOLFSSL_IPV6
const char* ipv6End = XSTRSTR(port, "]");
if (ipv6End) {
portStr = XSTRSTR(ipv6End, ":");
}
#endif
bio->port = (word16)XATOI(portStr);
XSTRSTR is strstr and XATOI is atoi (wolfssl/wolfcrypt/types.h:1109, wolfssl/wolfcrypt/types.h:1307). The only argument check is port == NULL at src/bio.c:2625.
- The caller passes
"[::1]". XSTRSTR(port, "]")atsrc/bio.c:2633returns a pointer to the last character.XSTRSTR(ipv6End, ":")atsrc/bio.c:2635finds no colon after the bracket and returns NULL.portStris now NULL.XATOI(portStr)atsrc/bio.c:2638isatoi(NULL).
The sibling wolfSSL_BIO_new_connect() does the same search and tests the result before using it (src/bio.c:2582).
Reachability and Preconditions
- Build with
OPENSSL_EXTRAandWOLFSSL_IPV6. The application callswolfSSL_BIO_new_accept()orBIO_new_accept()with a string that contains]and no:after it. - The string comes from the application: a constant, a configuration file, a command-line option, or data the application forwards. wolfSSL itself does not call this function outside its API tests.
- No TLS handshake or authentication is involved. The dereference happens when the BIO is created, before any socket exists.
Impact
The calling process dereferences a NULL pointer inside atoi(). The practical result is a crash at start-up or at the moment the listener is created. There is no memory corruption and no information disclosure. Whether a remote party can cause it depends entirely on how the application obtains its accept string. With a fixed or operator-supplied string the issue is a robustness defect in configuration handling.
ByteRay did not build a proof of concept for this issue. The analysis is from source review.
Remediation and Mitigation
Fixed on master by commit 1495a4d6323c46ea8c467f64349c13e219c7f7d7 (PR 11868, merged 2026-11-04). The function now returns NULL when a ] is not followed by :, starts the port after the separator, and parses it with a digit-only routine that rejects empty strings, non-digits and values above 65535. The bracket handling no longer depends on WOLFSSL_IPV6. The fix is on master only. No release contains it as of 2026-12-03.
Until a release does, applications should validate the accept string before calling the function: if it contains ], require a : and a decimal port after it.
Timeline
- 2026-09-28 — Reported to wolfSSL.
- 2026-10-22 — Pull request 11868 opened upstream.
- 2026-11-04 — Pull request 11868 merged to master.
- 2026-12-03 — Public disclosure.
Credits
Discovered and reported by Mehrun P. Hunter and Shahriyar Jalayeri of ByteRay Ltd.