← ALL ADVISORIES

HIGH BYTERAY-2026-0336Disclosed

wolfSSL — DRBG Seeded from Non-Cryptographic sys_rand_get() in Zephyr Builds Without an Entropy Driver

On Zephyr configurations without an entropy driver and a zephyr,entropy chosen node, wc_GenerateSeed() fills the DRBG seed from sys_rand_get(), a general-purpose generator, and returns success. On boards where that generator is deterministic, an observer who can model it can recompute the DRBG state.

Advisory
BYTERAY-2026-0336
CWE
CWE-1213
CVSS
8.1 (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H)
Vendor
wolfSSL
Product
wolfSSL
Reported
2026-09-27
Disclosure
2026-12-03
Affected
wolfSSL 5.9.2 (tested at master commit d95483f), builds with WOLFSSL_ZEPHYR on a Zephyr configuration that lacks CONFIG_ENTROPY_HAS_DRIVER or a zephyr,entropy chosen node
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(). The Zephyr implementation has two legs chosen at compile time. When the configuration has an entropy driver and the device tree names a zephyr,entropy chosen node, the seed comes from that driver and the function returns an error if the driver fails.

In every other Zephyr configuration the function calls sys_rand_get() and returns 0. Zephyr describes sys_rand_get() as a general-purpose generator that is not cryptographically secure. On a board with no entropy driver it is a deterministic software generator. The DRBG is then keyed entirely from that generator, and the unconditional success return means that nothing downstream can tell that no entropy was collected.

Someone who can model or recover the state of the board's random backend, and who sees a value the DRBG produced, such as a TLS hello random, can recompute the generator state. Only WOLFSSL_ZEPHYR builds on configurations that fail the compile-time gate are affected. A default ./configure build is not.

Affected Products and Versions

  • Component: wolfCrypt, wolfcrypt/src/random.c, wc_GenerateSeed(), the WOLFSSL_ZEPHYR implementation, fallback leg.
  • Required build: WOLFSSL_ZEPHYR defined, no seed override (CUSTOM_RAND_GENERATE_SEED, CUSTOM_RAND_GENERATE_SEED_OS or a seed callback), and a Zephyr configuration for which defined(CONFIG_ENTROPY_HAS_DRIVER) && DT_HAS_CHOSEN(zephyr_entropy) is false.
  • Not affected: Zephyr configurations that satisfy that condition. They use the entropy driver and fail closed.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • A default ./configure build does not include this code.
  • Other releases were not checked.

Technical Details

The Zephyr function is at wolfcrypt/src/random.c:9263-9298. The compile-time gate is at wolfcrypt/src/random.c:9272. The driver leg (wolfcrypt/src/random.c:9273-9291) returns RNG_FAILURE_E when the device is not ready or entropy_get_entropy() fails. The other leg is:

    #else
        (void)os;
        sys_rand_get(output, sz);
        return 0;
    #endif

The comment above the gate states the design choice: boards that set CONFIG_ENTROPY_HAS_DRIVER without a chosen entropy node "fall back to sys_rand_get() rather than failing the build" (wolfcrypt/src/random.c:9264-9271). The same comment calls sys_rand_get() general-purpose. The fail-closed behaviour therefore covers one side of the gate only.

How the seed is used:

  1. wc_InitRng() calls the common initialiser (wolfcrypt/src/random.c:3400), directly from the application or from the TLS layer when it sets up a session.
  2. The initialiser requests the seed from wc_GenerateSeed() (wolfcrypt/src/random.c:3135).
  3. The fallback leg fills the buffer from sys_rand_get() and returns 0 (wolfcrypt/src/random.c:9295-9296).
  4. The Hash_DRBG is instantiated from that seed (wolfcrypt/src/random.c:3178). The callers act on the return value only, so the missing entropy is not detected.
  5. Reseeding calls the same function (wolfcrypt/src/random.c:4685-4686).
  6. A TLS endpoint sends DRBG output in the clear as the hello random: the client random (src/internal.c:34895) and the server random, in TLS 1.3 at src/tls13.c:8762.

Reachability and Preconditions

  • The firmware is built with WOLFSSL_ZEPHYR, the Zephyr configuration fails the gate above, and no custom seed source is defined. The wolfSSL Zephyr module defines WOLFSSL_ZEPHYR for its users (zephyr/CMakeLists.txt:180-181).
  • The board's sys_rand_get() backend is one the attacker can model: a timer-based, linear congruential or test generator with a small or recoverable state. This depends on the board and is the main limit on the attack.
  • The attacker observes at least one value derived from the DRBG. A passive observer of one TLS handshake gets the hello random. No authentication and no active position are needed.

Impact

On affected configurations the DRBG seed comes entirely from a generator that is not meant for cryptographic use. An attacker who reproduces that generator's output recovers the DRBG state from one recorded handshake, and with it session keys, IVs, session ticket material and nonces drawn from the same generator. Boards brought up without a zephyr,entropy chosen node, which is common during porting and on parts without a hardware random number generator, take this leg without a build error or a warning.

ByteRay compiled the unmodified wolfCrypt sources with WOLFSSL_ZEPHYR on a Linux host, with stand-ins for the Zephyr headers that describe a board without a chosen entropy node and a linear congruential sys_rand_get(). wc_GenerateSeed() returned 0 with identical output on two boots, wolfCrypt's seed health test accepted it, both boots produced the same AES-GCM key, IV, ciphertext and tag, and a search of 2001 candidate generator states through wc_InitRng() reproduced them; the driver leg and a host build seeded from /dev/urandom did not repeat.

This was not run on a Zephyr target or through a Zephyr build. How hard the search is on a given board depends on its random backend and 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 silent fallback. Either the build requires a zephyr,entropy chosen node when WOLFSSL_ZEPHYR is defined, or the fallback leg returns RNG_FAILURE_E so that initialisation and reseeding stop without real entropy. If a software generator has to be allowed on particular boards, it should sit behind an explicit opt-in macro and an integrator-supplied cryptographic generator.

Workaround for affected builds: enable an entropy driver and set the zephyr,entropy chosen node in the device tree, or define CUSTOM_RAND_GENERATE_SEED to a function backed by a hardware entropy source. Treat keys generated on a board that took the fallback leg 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