wolfSSL — Shared Global Socket Error Variable in the Nucleus Network I/O Layer
On Nucleus PLUS 2.3 builds, wolfSSL stores the last socket error in one writable global, Nucleus_Net_Errno, shared by every session and thread. Concurrent I/O on two connections can make one connection's error translation read the other's status code, so a would-block condition can be reported as a hard failure or the reverse.
- Advisory
- BYTERAY-2026-0488
- CWE
- CWE-500
- CVSS
- 3.0 (CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:N/I:L/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 NUCLEUS_PLUS_2_3 that run TLS I/O on more than one thread
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
On the Nucleus PLUS 2.3 platform, wolfSSL's network glue keeps the last Nucleus socket status in a single global integer, Nucleus_Net_Errno. Each receive, send and select wrapper writes it. The platform branch of wolfSSL_LastError() reads it back, and the result decides whether an I/O failure is treated as want-read, want-write, a reset connection or a fatal error.
The variable is one value for the whole process. It is not thread-local, it has external linkage, and nothing guards access to it. Two TLS connections doing I/O at the same time can overwrite each other's status between the socket call and the translation. Other code linked into the image can write it as well.
The result is a misclassified socket error on that platform. There is no remote trigger. Default builds do not define NUCLEUS_PLUS_2_3.
Affected Products and Versions
- Component:
src/wolfio.c, globalNucleus_Net_Errno, the Nucleus socket wrappers and the Nucleus branch ofwolfSSL_LastError(). - Required build:
NUCLEUS_PLUS_2_3with wolfSSL's built-in I/O callbacks. - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default
./configurebuild does not include this code. - Other releases were not checked.
Technical Details
The definition is at src/wolfio.c:46-49:
#ifdef NUCLEUS_PLUS_2_3
/* Holds last Nucleus networking error number */
int Nucleus_Net_Errno;
#endif
It is neither static nor thread-local. No public header declares it, but any translation unit can declare the symbol and use it. How the value is used:
- The receive wrapper stores the Nucleus status on failure and zero on success (
src/wolfio.c:488,src/wolfio.c:492). The send wrapper does the same (src/wolfio.c:507,src/wolfio.c:510). - The select wrapper stores a negative status (
src/wolfio.c:532). The datagram receive and send wrappers store theirs (src/wolfio.c:552,src/wolfio.c:555,src/wolfio.c:571,src/wolfio.c:574). - Each wrapper returns a generic failure code, so the caller has to recover the real status from the global.
wolfSSL_LastError()returns the global on this platform (src/wolfio.c:179-180).TranslateIoReturnCode()calls it (src/wolfio.c:217) and maps the value to results such asWOLFSSL_CBIO_ERR_WANT_READ,WOLFSSL_CBIO_ERR_WANT_WRITEandWOLFSSL_CBIO_ERR_CONN_RST.
Between step 1 and step 4 another thread can run its own wrapper and replace the value. Thread A then translates the status that thread B stored.
Reachability and Preconditions
- The library is built for
NUCLEUS_PLUS_2_3and uses the built-in socket wrappers. - At least two threads perform wolfSSL I/O on different
WOLFSSLobjects at the same time, or other code in the same image writes the symbol. - The attacker cannot set the variable from the network. Influence is limited to causing socket errors on one connection while another is active, and the outcome depends on thread timing. No authentication state is involved.
Impact
A recoverable condition on one connection can be reported as fatal, which drops that connection. A real failure can be reported as recoverable, which causes a needless retry. The effect is confined to error handling on this platform. No data is disclosed.
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 remove the shared slot: translate the Nucleus status inside the call that produced it, or return it through the wrapper. If a module-level value has to stay, it should be static and thread-local, and set only on failure.
Until then, applications can avoid the shared state by registering their own receive and send callbacks with wolfSSL_CTX_SetIORecv and wolfSSL_CTX_SetIOSend and translating Nucleus errors there. Running all wolfSSL I/O on one thread also avoids the race.
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.