wolfSSL — Externally Linkable Global File Descriptor in QNX CAAM Port
The QNX CAAM port keeps the descriptor for its kernel crypto driver in caamFd, a non-static global int. Any code linked into the process can overwrite or close it, and the port's own teardown closes it without taking the lock that serializes driver requests. The result is failed or misdirected hardware crypto requests.
- Advisory
- BYTERAY-2026-0483
- 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), QNX builds with the CAAM port enabled (WOLFSSL_QNX_CAAM)
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
wolfSSL's QNX CAAM port talks to the kernel-side CAAM driver through one file descriptor for /dev/wolfCrypt. Every hardware-backed operation in the port, including AES, ECDSA, the TRNG and key storage, sends its request through that descriptor.
The descriptor is stored in caamFd, a file-scope int declared without static. It therefore has external linkage. No header declares it and no accessor manages it, but any translation unit in the process can bind to the symbol and read, overwrite or close it. The mutex defined on the next line serializes individual driver requests. It does not protect the variable, and the teardown function closes the descriptor without taking it.
Changing the descriptor from outside the port needs code in the process or an existing write primitive. The consequence is hardware crypto requests that fail or go to a different descriptor. CAAM-protected key material is not exposed by this. The port is not part of a default build.
Affected Products and Versions
- Component:
wolfcrypt/src/port/caam/wolfcaam_qnx.c, thecaamFdglobal. - Required build:
WOLFSSL_QNX_CAAMon QNX (__QNX__or__QNXNTO__), per the guard atwolfcrypt/src/port/caam/wolfcaam_qnx.c:28. - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default build does not compile this file.
- Other releases were not checked.
Technical Details
The definition and its neighbour (wolfcrypt/src/port/caam/wolfcaam_qnx.c:40-41):
int caamFd = -1;
static wolfSSL_Mutex caamMutex;
The mutex is static. The descriptor is not.
Lifecycle of the descriptor:
wc_CAAMInitInterface()initializes the mutex and opens/dev/wolfCrypt, storing the result incaamFd(wolfcrypt/src/port/caam/wolfcaam_qnx.c:44-52).- Each hardware operation locks
caamMutex, callsdevctlv(caamFd, ...)and unlocks (wolfcrypt/src/port/caam/wolfcaam_qnx.c:448-451). wc_CAAMFreeInterface()frees the mutex and closes the descriptor (wolfcrypt/src/port/caam/wolfcaam_qnx.c:61-65). It does not acquire the lock first, does not check the result ofclose(), and does not reset the variable.
Two consequences follow. Code outside the file can change caamFd at any time, between or during operations, because the lock covers only the devctlv() call. And a legitimate teardown can run while a request on another thread is in flight.
Reachability and Preconditions
- QNX build with the CAAM port.
- To change the descriptor from outside the port: code linked into the same process that defines or references a symbol of the same name, or an attacker with an in-process write primitive.
- To race the teardown: the application calls the CAAM free function while another thread performs a hardware crypto operation.
- No remote path reaches the variable.
Impact
A changed or closed descriptor makes CAAM requests fail, or sends them to whatever file the new descriptor number refers to. AES, ECDSA and TRNG operations that depend on the driver break. This is a loss of availability and of integrity of the crypto operations, not a disclosure of CAAM-wrapped keys and not a privilege escalation.
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 declare caamFd static, and to expose a small accessor if another module needs it. The teardown should take caamMutex before closing, check the result of close(), and reset the variable to -1 under the lock so requests in flight cannot use a closed descriptor.
Applications can avoid the teardown race by not calling the CAAM free function while other threads are using hardware crypto.
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.