wolfSSL — CryptoCell RNG State and Generator Function Pointer Exposed as Writable Globals
The CryptoCell port keeps its RNG state, RNG work buffer and the function pointer used to generate random vectors as non-const globals declared in a public header. Code in the same image that overwrites them controls the randomness used for RSA and ECC key generation and signing on that device.
- Advisory
- BYTERAY-2026-0387
- CWE
- CWE-500
- CVSS
- 6.0 (CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:H/I:H/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 WOLFSSL_CRYPTOCELL (ARM CryptoCell CC310 port for nRF5x)
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
The ARM CryptoCell port drives the CC310 hardware accelerator found on nRF5x parts. Its random number generator has three pieces of global state: the RNG state, a work buffer, and a function pointer, wc_rndGenVectFunc, that the hardware key generation and signing calls use to obtain random vectors.
All three are plain writable globals, and the port's public header declares them extern. cc310_Init() seeds the state once and the pointer starts out as CRYS_RND_GenerateVector. After that nothing checks that either is intact, and no accessor stands between them and the rest of the image.
Code linked into the same firmware that assigns to the function pointer, or overwrites the state, decides the random input of every later RSA and ECC key generation and signature made through this port. The port is not part of a default build, and there is no remote path to these variables in the library.
Affected Products and Versions
- Component:
wolfcrypt/src/port/arm/cryptoCell.c, globalswc_rndState,wc_rndWorkBuffandwc_rndGenVectFunc, and their users inwolfcrypt/src/rsa.candwolfcrypt/src/ecc.c. - Required build:
WOLFSSL_CRYPTOCELL. - 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 definitions are at wolfcrypt/src/port/arm/cryptoCell.c:42-44:
CRYS_RND_State_t wc_rndState;
CRYS_RND_WorkBuff_t wc_rndWorkBuff;
SaSiRndGenerateVectWorkFunc_t wc_rndGenVectFunc = CRYS_RND_GenerateVector;
The public header repeats them as extern declarations under the comment "RNG Global variables" (wolfssl/wolfcrypt/port/arm/cryptoCell.h:63-66). None is const or static.
How they are used:
cc310_Init()callsCRYS_RndInit(&wc_rndState, &wc_rndWorkBuff)once, behind a one-shot flag (wolfcrypt/src/port/arm/cryptoCell.c:78).cc310_RSA_GenerateKeyPair()passes&wc_rndStateandwc_rndGenVectFunctoCRYS_RSA_KG_GenerateKeyPair(wolfcrypt/src/rsa.c:585-586).- RSA PKCS#1 v1.5 encryption and signing pass the same pair (
wolfcrypt/src/rsa.c:3535-3536,wolfcrypt/src/rsa.c:3578-3579). - The CryptoCell branch of ECC key generation passes them to
CRYS_ECPKI_GenKeyPair(wolfcrypt/src/ecc.c:6004-6005), and ECDSA signing passes them toCRYS_ECDSA_Sign(wolfcrypt/src/ecc.c:6787-6788). cc310_random_generate()reads from the state directly (wolfcrypt/src/port/arm/cryptoCell.c:111).
The repository never reassigns wc_rndGenVectFunc after its initializer. It could be constant and file-local with no loss of function. As written, a single assignment from anywhere in the image replaces the generator for steps 2 to 4, and a write to wc_rndState changes the output of every step.
Reachability and Preconditions
- The library is built with
WOLFSSL_CRYPTOCELL. - The attacker already runs code in the same firmware image, for example an untrusted component linked against these symbols, or holds a memory-write primitive that reaches them.
- There is no remote trigger. No input to the library changes these variables.
- No authentication state is involved.
Impact
With the function pointer replaced, RSA and ECC private keys generated on the device, and the randomness used in signing and encryption padding, come from values the attacker chose. Keys produced that way can be predicted or known outright. A corrupted state has the same effect on everything derived from it. The precondition is in-process code execution or an equivalent write. On a single-image embedded target that already implies wide access, and the exposed globals make the randomness source an easy target for it.
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 give the three objects internal linkage and drop the extern declarations from the public header. The function pointer can become a constant, or the call can move into a private helper. If applications need to reseed or replace the generator, that belongs behind an accessor that validates its input and re-runs the initialization. Until then, firmware for these targets should link only trusted code into the image that contains wolfSSL.
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.