wolfSSL — Predictable DRBG Seed from the XDC Timestamp Counter in TI-RTOS Builds
On TI-RTOS builds, wolfSSL's seed function seeds the C library generator from the 32-bit XDC runtime timestamp and returns rand() output as the DRBG seed. The seed is a function of a few counter readings, so an observer who can bound them can recompute the DRBG state and every value drawn from it.
- Advisory
- BYTERAY-2026-0332
- CWE
- CWE-323
- CVSS
- 7.4 (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N)
- Vendor
- wolfSSL
- Product
- wolfSSL
- Reported
- 2026-09-27
- Disclosure
- 2026-12-03
- Affected
- wolfSSL 5.9.2 through 5.9.4, builds with WOLFSSL_TIRTOS that do not supply their own seed source
- Fixed in
- Master commit 09c1648ad4502e7974cef18d47d14367b85d579c (PR 12065, merged 2026-11-10). Not in a wolfSSL stable release as of 2026-12-03.
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
wolfSSL's random number generator is a Hash_DRBG that takes its entropy from wc_GenerateSeed(). That function has one implementation per platform. The one selected by WOLFSSL_TIRTOS has no entropy source. It passes the 32-bit XDC runtime timestamp to srand(), copies rand() output into the seed buffer, and repeats the srand() call with a fresh timestamp after every eight bytes.
The timestamp is a running counter. Nothing secret enters it. The first eight seed bytes are fixed by one 32-bit value, and each later block by a reading taken a few statements afterwards. Someone who sees a value the DRBG produced, such as a TLS hello random, can search the counter values and recompute the generator state, and with it the key shares, nonces, IVs and keys the device generated.
Only TI-RTOS builds take this branch. The TI-RTOS package build files in the wolfSSL tree select it and set no other seed source. The compiler prints a warning that the code is "currently being used for testing", and the build continues. A default ./configure build is not affected.
Affected Products and Versions
- Component:
wolfcrypt/src/random.c,wc_GenerateSeed(), theWOLFSSL_TIRTOSbranch. - Required build:
WOLFSSL_TIRTOSdefined, and none of the custom seed macros tested earlier in the same chain (wolfcrypt/src/random.c:7743-7769). The in-tree TI-RTOS build script passes-DWOLFSSL_TIRTOSand nothing that changes the seed source, and the settings block for the platform does not either (wolfssl/wolfcrypt/settings.h:1798-1858). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- The
v5.9.2-stableandv5.9.4-stabletags contain the same branch with the warning only. - Fixed on master. No wolfSSL release contains the fix.
- A default
./configurebuild does not include this code. Earlier releases were not checked.
Technical Details
The branch is at wolfcrypt/src/random.c:8537-8554. It opens with a #warning (wolfcrypt/src/random.c:8538) and then defines the seed function, whose body is:
int i;
srand(xdc_runtime_Timestamp_get32());
for (i = 0; i < sz; i++ ) {
output[i] = rand() % 256;
if ((i % 8) == 7) {
srand(xdc_runtime_Timestamp_get32());
}
}
return 0;
Each block of eight bytes is the start of the rand() sequence for one timestamp reading. The function never fails. The warning text is "potential for not enough entropy, currently being used for testing"; it does not stop the build, and there is no other implementation for this platform to fall through to.
How the seed is used:
wc_InitRng()andwc_InitRng_ex()call the common initialiser with no nonce and no personalization string (wolfcrypt/src/random.c:3400-3411).- The initialiser requests the seed from
wc_GenerateSeed()(wolfcrypt/src/random.c:3135). A default non-FIPS SHA-256 build asks for 36 bytes (wolfcrypt/src/random.c:2755), which is five timestamp readings. - The seed health test fails only when one byte value repeats 31 times in a row or fills 325 places of a 512-byte window (
wolfcrypt/src/random.c:2506,wolfcrypt/src/random.c:2522, called atwolfcrypt/src/random.c:3159).rand()output passes it. - The DRBG is instantiated from the seed (
wolfcrypt/src/random.c:3178-3184). - Reseeding calls the same function (
wolfcrypt/src/random.c:4685-4686).
A TLS session creates its generator this way (src/internal.c:8404-8409) and sends DRBG output in the clear as the hello random (src/internal.c:34895). The TI-RTOS notes in the tree describe a TLS echo server as the example application for this port.
Reachability and Preconditions
- The library is built with
WOLFSSL_TIRTOSand uses the stock seed function. A build that definesCUSTOM_RAND_GENERATE_SEED,CUSTOM_RAND_GENERATE_SEED_OSorCUSTOM_RAND_GENERATEdoes not reach this code. - The attacker observes at least one value derived from the DRBG. A passive observer of a TLS handshake gets the hello random. No authentication and no interaction with the device are needed.
- The attacker needs to cover the timestamp values in use when the generator was initialised. The first reading is a 32-bit value. Knowing how the timestamp source runs on the target, and roughly when the generator was initialised, narrows it.
- The attacker needs the
rand()implementation of the C library the firmware was linked with.
Impact
Confirmed from source: on these builds the DRBG seed is determined by the timestamp readings taken during one call and by nothing else. Every value drawn from the generator follows from the seed: ephemeral key shares, signature nonces, AES-GCM IVs, session ticket IVs and long-term keys generated on the device.
ByteRay compiled the unmodified wolfCrypt sources with WOLFSSL_TIRTOS on a Linux host, with the XDC timestamp call replaced by a counter under test control. With the counter at one value, the seed was a single eight-byte block repeated, and it matched an independent replay of the C library generator. Two processes started at that value produced the same DRBG output and the same AES-GCM key, IV, ciphertext and tag; trying 2201 candidate counter values through wc_InitRng() reproduced them, and a control build seeded from the host's /dev/urandom did not repeat.
Not verified: behaviour on TI hardware. In ByteRay's run the counter did not advance between the readings inside one call. On a device it does, so a search has to cover the spacing between readings as well as the first value. That spacing, and the resolution of the timestamp on a given TI-RTOS configuration, were not measured.
Remediation and Mitigation
Fixed on master by commit 09c1648ad4502e7974cef18d47d14367b85d579c, part of PR 12065, merged 2026-11-10. The commit puts a build-time #error in front of this branch unless WOLFSSL_ACCEPT_WEAK_ENTROPY is defined, and adds the configure option --enable-weak-entropy, which defines that macro. The srand()/rand() code is unchanged behind the guard. The TI-RTOS build script in the tree still passes only -DWOLFSSL_TIRTOS, so on master that build stops with the error until a seed source is added. The fix is on master only. No wolfSSL release contains it as of 2026-12-03.
For affected releases, define CUSTOM_RAND_GENERATE_SEED to a function backed by the hardware random number generator of the TI part. Treat keys generated by a build that used the stock function as exposed and replace them. After updating, do not define WOLFSSL_ACCEPT_WEAK_ENTROPY in a build that handles real secrets.
Timeline
- 2026-09-27 — Reported to wolfSSL.
- 2026-11-09 — wolfSSL opened PR 12065.
- 2026-11-10 — PR 12065 merged to master.
- 2026-12-03 — Public disclosure.
Credits
Discovered and reported by Mehrun P. Hunter and Shahriyar Jalayeri of ByteRay Ltd.