wolfSSL — Predictable DRBG Seed from the RTC Millisecond Field in Telit M2MB Builds
On Telit M2MB builds, wolfSSL's seed function seeds the C library generator from the millisecond field of the module's real-time clock and returns rand() output as the DRBG seed. Each clock read has at most 1000 possible values, so the seed, and everything drawn from the DRBG, can be recomputed by search.
- Advisory
- BYTERAY-2026-0331
- 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_TELIT_M2MB 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. It takes its entropy from wc_GenerateSeed(), which has one implementation per platform. The implementation selected by WOLFSSL_TELIT_M2MB has no entropy source. It opens the module's real-time clock, keeps only the millisecond field, passes it to srand(), and copies rand() output into the seed buffer. It reads the clock again after every eight bytes.
The millisecond field has 1000 possible values. If the clock device cannot be opened the value is 0. Nothing else goes into the seed, so the DRBG state after initialisation is a function of a few small numbers. Someone who sees a value the DRBG produced, such as a TLS hello random, can search for the clock readings that reproduce it and then compute every other value the generator gave out: key shares, nonces, IVs and generated keys.
Only builds for Telit M2MB modules take this branch. A default ./configure build does not. The branch emits no build warning.
Affected Products and Versions
- Component:
wolfcrypt/src/random.c,wc_GenerateSeed()and its helperget_timestamp(), theWOLFSSL_TELIT_M2MBbranch. - Required build:
WOLFSSL_TELIT_M2MBdefined, and none of the custom seed macros tested earlier in the same chain (wolfcrypt/src/random.c:7743-7769,wolfcrypt/src/random.c:9190). The tree has no other seed implementation for this platform. - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- The
v5.9.2-stableandv5.9.4-stabletags contain the same branch, unguarded. - 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:9300-9325. The helper returns the millisecond field of the RTC time value:
static long get_timestamp(void) {
long myTime = 0;
INT32 fd = m2mb_rtc_open("/dev/rtc0", 0);
if (fd >= 0) {
M2MB_RTC_TIMEVAL_T timeval;
m2mb_rtc_ioctl(fd, M2MB_RTC_IOCTL_GET_TIMEVAL, &timeval);
myTime = timeval.msec;
m2mb_rtc_close(fd);
}
return myTime;
}
timeval.sec is not used. The port's own benchmark timer treats msec as the fraction of the current second: it divides it by 1000 and adds it to sec (wolfcrypt/src/wc_port.c:5041). When m2mb_rtc_open() fails, the helper returns 0 and reports nothing. The seed function is:
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
{
int i;
srand(get_timestamp());
for (i = 0; i < sz; i++ ) {
output[i] = rand() % 256;
if ((i % 8) == 7) {
srand(get_timestamp());
}
}
return 0;
}
Each block of eight bytes is the start of the rand() sequence for one clock reading. If the reading has not changed between two blocks, the blocks are identical. The function always returns 0. 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 clock 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). Repeated eight-byte blocks ofrand()output pass 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).
Reachability and Preconditions
- The library is built with
WOLFSSL_TELIT_M2MBand uses the stock seed function. A build that definesCUSTOM_RAND_GENERATE_SEED,CUSTOM_RAND_GENERATE_SEED_OS,CUSTOM_RAND_GENERATEorCUSTOM_RAND_GENERATE_BLOCKdoes 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 does not need to know the time. The millisecond field is searched exhaustively.
- 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 RTC millisecond readings taken during one call, at most 1000 values per reading, and by nothing else. Successive readings come from the same running clock a few statements apart, so they are not independent. Every value drawn from the generator follows from the seed. That covers 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_TELIT_M2MB on a Linux host, with the Telit RTC calls replaced by a stand-in device. Two separate processes started with the same clock reading produced identical seeds and, from wc_InitRng() onward, identical AES-GCM key, IV, ciphertext and tag; trying all 1000 millisecond values through the same library path reproduced them. A control build without the macro, seeded from the host's /dev/urandom, differed on every run.
Not verified: behaviour on a Telit module. How far the millisecond field advances between the readings of one call on real hardware, and so the exact size of the search, was 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. A Telit M2MB build on master therefore stops until the integrator provides a seed source or explicitly accepts the weak one. 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 that reads a hardware or system entropy source on the module. 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.