wolfSSL — Predictable DRBG Seed from time() in INtime RTOS v5 and Older Builds
On INtime RTOS v5 and older, wolfSSL's seed function calls srand(time(0)) and returns rand() output as the DRBG seed. The only input is the calendar time in whole seconds, so the seed, and everything drawn from the DRBG, can be recomputed by trying the seconds around an observed session.
- Advisory
- BYTERAY-2026-0327
- 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 (tested at master commit d95483f), builds with INTIME_RTOS and without INTIMEVER (INtime RTOS v5 and older) that do not supply their own seed source
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
wolfSSL's random number generator is a Hash_DRBG. It takes its entropy from wc_GenerateSeed(), which has one implementation per platform. The INtime RTOS implementation has two forms. When INTIMEVER is defined, which is the case on INtime v6 and later, it reads arc4random(). On v5 and older it has no entropy source: it calls srand(time(0)) once and fills the seed buffer from rand().
The only input is the calendar time at one-second resolution. rand() expands it deterministically, so the seed, and the DRBG state instantiated from it, is one of a small set of candidates around the time of any observed session. Someone who sees a value the DRBG produced, such as a TLS hello random or an AES-GCM IV, can try those seconds, find the one that reproduces it, and then compute every other value the generator gave out.
Only INtime builds without INTIMEVER take this form. A default ./configure build does not; it seeds from /dev/urandom.
Affected Products and Versions
- Component:
wolfcrypt/src/random.c,wc_GenerateSeed(), theINTIME_RTOSbranch for v5 and older. - Required build:
INTIME_RTOSdefined (wolfcrypt/src/random.c:8755) andINTIMEVERnot defined. WithINTIMEVERthe same function usesarc4random()(wolfcrypt/src/random.c:8765-8768) and is not affected. - No seed override in place.
CUSTOM_RAND_GENERATE_SEEDandCUSTOM_RAND_GENERATE_SEED_OScome first in the same chain (wolfcrypt/src/random.c:7743,wolfcrypt/src/random.c:7756). - 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 function is at wolfcrypt/src/random.c:8756-8787. The version split and the fill loop are:
#ifdef INTIMEVER
/* If INTIMEVER exists then it is INTIME RTOS v6 or later */
#define INTIME_RAND_FUNC arc4random
len = 4;
#else
/* v5 and older */
#define INTIME_RAND_FUNC rand
srand(time(0));
len = 2; /* don't use all 31 returned bits */
#endif
while (sz > 0) {
if (sz < len)
len = sz;
randval = INTIME_RAND_FUNC();
XMEMCPY(output, &randval, len);
output += len;
sz -= len;
}
On v5 and older the generator is seeded once, at wolfcrypt/src/random.c:8772, and the loop at wolfcrypt/src/random.c:8776-8783 copies two bytes of each rand() result into the buffer. The function returns 0. Two generators initialised within the same second receive the same seed. How the seed is used:
wc_InitRng()(wolfcrypt/src/random.c:3400) calls_InitRng()(wolfcrypt/src/random.c:2745)._InitRng()requests the seed fromwc_GenerateSeed()(wolfcrypt/src/random.c:3135). WithWC_RNG_SEED_CBthe default callback is the same function (wolfcrypt/src/random.c:390). Reseeding also calls it (wolfcrypt/src/random.c:4685).- The branch above fills the buffer from one
time(0)reading. Hash_DRBG_Instantiate()takes that buffer as its entropy input (wolfcrypt/src/random.c:3178).wc_RNG_GenerateBlock()hands out DRBG output (wolfcrypt/src/random.c:5605).- That output reaches the wire: per-message AES-GCM IVs from
wc_AesGcmSetIV()(wolfcrypt/src/aes.c:15126), session ticket IVs fromDefTicketEncCb()(src/internal.c:44924), and TLS handshake randoms. Keys generated on the device come from the same stream.
Reachability and Preconditions
- The library is built with
INTIME_RTOS, withoutINTIMEVER, and uses the stock seed function. - Any integration that calls
wc_InitRng(), or lets the TLS layer do so, seeds its DRBG through this branch. No unusual option or call sequence is involved. - The attacker is a passive observer of TLS or DTLS traffic from the device. No authentication and no interaction with the device are needed.
- The attacker can bound
time(0)at seeding to a window of seconds. Wall-clock time follows from when the session was observed. - The attacker observes at least one DRBG-derived value to confirm a candidate, and needs the
rand()implementation of the platform's C library.
Impact
On these builds the DRBG seed is determined by the second in which the generator was initialised. An observer who pins that second recovers the DRBG state and can compute the session keys, GCM IVs, session ticket keys and locally generated keys drawn from it. Predictable per-message IVs also break GCM's integrity guarantee through nonce reuse. The main effect is that secret material on affected builds can be derived from public observations.
ByteRay compiled the unmodified wolfCrypt sources with INTIME_RTOS and no INTIMEVER on a Linux host. Two separate processes started in the same second produced identical AES-GCM key, IV, ciphertext and tag, and trying the 2049 seconds around the session time reproduced all four through wc_InitRng() and wc_AesGcmSetIV(); a control build seeded from the host's /dev/urandom was not reproduced by the same search. Behaviour on an INtime target, with its own C library rand(), was not measured.
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 srand(time(0))/rand() form for builds without INTIMEVER and fail closed: wc_GenerateSeed() returns an entropy error, so the DRBG refuses to instantiate on INtime v5 and older unless the integrator has wired in a real entropy source through the custom seed hooks. The v6 form with arc4random() shows the intended behaviour. At minimum the version gate should be a build-time error, so that a build for an old INtime release cannot ship on a clock-seeded generator without anyone noticing.
Workaround: define CUSTOM_RAND_GENERATE_SEED to a function that reads a hardware or system entropy source. That macro takes precedence over this branch. Treat keys generated by a build that used the stock function as exposed and replace them.
Timeline
- 2026-09-27 — Reported to wolfSSL.
- 2026-12-03 — Public disclosure.
Credits
Discovered and reported by Mehrun P. Hunter and Shahriyar Jalayeri of ByteRay Ltd.
References
- INtime RTOS branch of wc_GenerateSeed at the tested commit
- BYTERAY-2026-0325, the PIC32 branch of the same function
- BYTERAY-2026-0326, the EBSnet RTP branch of the same function
- BYTERAY-2026-0328, the Apache Mynewt branch of the same function
- BYTERAY-2026-0329, the Deos branch of the same function
- BYTERAY-2026-0330, the Nucleus RTOS branch of the same function