Zephyr CVE-2026-19742: How One API Call Broke Randomness

Randomness has an inconvenient property; it looks exactly the same whether it’s doing its job or not.

Bytes from a cryptographically secure generator and bytes from a fast, predictable one are indistinguishable to the eye. Both look like noise, but only one of them can keep a secret.

This is the story of a single function call in Zephyr RTOS’s IPv6 stack, the 128-bit secret it was quietly responsible for, and how following that call all the way down into Kconfig turned into CVE-2026-19742.

If you read my Zed post, you might remember me talking about findings that were still sitting behind an embargo. One of them is public now, which means I finally get to talk about it.

The short version: I found it through source-level analysis, reported it privately, and was credited as reporter. The Zephyr maintainers validated it, took the analysis further, and fixed it across four branches.

It all started with a search

I stumbled upon Zephyr while exploring Real Time Operating Systems (RTOS) to use for my project. While skimming through the code and reading its networking stack, I wanted to answer a deceptively simple question: who calls sys_rand_get(), and does every caller actually get what it thinks it’s getting?

rg "sys_rand_get" subsys/

The results came back from everywhere. Identifiers, protocol fields, crypto glue, odds and ends. A whole list. But that’s alright because randomness has many jobs. A retransmission delay just needs to not collide with its neighbour. A secret key needs to stay unguessable for its entire lifetime, against someone actively trying. Same bytes, very different promises.

So the real thing wasn’t where randomness was used. It was what each caller did with it.

That question led me from the sea of ripgrep results to two files:

  • gen_stable_iid() in subsys/net/ip/ipv6.c, which implements RFC 7217 stable interface identifiers
  • gen_temporary_iid() in subsys/net/ip/ipv6_pe.c, which implements RFC 8981 temporary interface identifiers (IPv6 privacy extensions)

Both generated a persistent 128-bit secret with sys_rand_get().

At that point I had an observation. I didn’t know whether it was exploitable, whether it was intentional, or whether it mattered on any real configuration. First, I needed to understand what that secret was guarding.

What the secret is actually guarding

An IPv6 address is 128 bits, usually split in two: a 64-bit network prefix and a 64-bit interface identifier (IID).

The old way to build an IID was to derive it from the device’s MAC address. Convenient, and terrible for privacy; your hardware identity rides along in every packet and follows you from network to network. RFC 7217 and RFC 8981 both exist to fix that, and both lean on a secret to do it.

RFC 7217: stable doesn’t mean predictable

RFC 7217 gives a device an IID that stays the same on a given network but looks unrelated across networks. Conceptually:

network prefix
interface index
interface name
DAD counter
persistent secret key (128-bit)
        │
        ▼
      HMAC
        │
        ▼
  stable IPv6 IID

The stability comes from reusing the secret, not from the secret being weak.

And here’s the catch: every other input on that list is guessable. The secret is the only thing standing between an attacker and the answer. If they know it, the IID stops being an unknown output and becomes a calculation they can run for any candidate network.

RFC 8981: rotating isn’t the same as unlinkable

RFC 8981 temporary addresses rotate over time, so that one long-lived address can’t be used to track you. Zephyr derives them using HMAC-SHA-256:

persistent secret key
network + interface info
generation-related inputs
        │
        ▼
   HMAC-SHA-256
        │
        ▼
  temporary IPv6 IID  (rotates)

Rotation looks like privacy. But a rotating address derived from a recoverable secret is a disguise that falls apart the moment someone knows the tailor.

Both mechanisms rest on one assumption: the secret is unpredictable. Everything after that is arithmetic.

Which narrowed my question down to something very specific: Was Zephyr generating these secrets with an API that actually guaranteed cryptographically secure randomness?

The Two APIs

Both the implementations I was looking at followed the same pattern:

static uint8_t secret_key[16];

if (!once) {
    sys_rand_get(secret_key, sizeof(secret_key));
    once = true;
}

Generated once. Reused for the life of the device.

I went through Zephyr’s docs and figured that Zephyr gives you two ways to ask for random bytes, and it’s explicit about the difference in include/zephyr/random/random.h and doc/services/crypto/random/index.rst:

API What it promises If it fails
sys_rand_get() General-purpose random data. Not guaranteed to be cryptographically secure. No error reported to the caller
sys_csrand_get() Cryptographically secure random data Returns an error the caller must handle

The problem wasn’t that sys_rand_get() returned bad bytes. It’s that its contract never promised what these callers needed.

A precedent hiding in the same stack

Then I looked at subsys/net/ip/tcp.c. In tcpv6_init_isn(), Zephyr generates the persistent secret used for RFC 6528 TCP Initial Sequence Numbers, another long-lived secret protecting a protocol security property.

That one used sys_csrand_get(). Same networking stack and same class of secret mind you.

That didn’t prove anything was exploitable. But it told me the stack already knew what the right call looked like for this kind of value.

I also went digging through the history. The two keys arrived separately: the RFC 8981 temporary-IID key came in with the initial privacy-extension support, and the RFC 7217 stable-IID key later on with stable IID support. The randomness docs had their own timeline. Nothing showed a deliberate reason for the API choice. History is evidence, but here it was silent, so I treated it as context rather than proof.

So far, I had three things:

  1. RFC 7217 and RFC 8981 depend on an unpredictable secret.
  2. Zephyr documents sys_rand_get() as not cryptographically secure, and provides sys_csrand_get() for exactly that purpose.
  3. TCP ISN generation, in the same stack, already uses the secure API for an analogous secret.

That’s a mismatch. Whether it’s a vulnerability depends on what’s actually behind sys_rand_get() on real builds.

Following the call down into Kconfig

In an RTOS, a function call is a promise with many possible implementations.

Zephyr runs on a huge range of architectures and boards, and Kconfig decides at build time what actually sits behind an API. Looking at a call to sys_rand_get() tells you nothing about whether the bytes come straight from an entropy device or from a deterministic PRNG.

So I went into the random subsystem:

  • subsys/random/Kconfig
  • subsys/random/random_xoshiro128.c
  • subsys/random/random_entropy_device.c
  • drivers/entropy/Kconfig.mcux

The question: on a supported configuration with the IPv6 features enabled, can sys_rand_get() resolve to a non-cryptographic generator?

Turns out it can.

Meet xoshiro128++

One backend is xoshiro128++, enabled by CONFIG_XOSHIRO_RANDOM_GENERATOR. The Kconfig logic selects it by default when an entropy driver is present and selects CONFIG_ENTROPY_NEEDS_PRNG. The NXP MCUX TRNG driver selects CONFIG_ENTROPY_NEEDS_PRNG in drivers/entropy/Kconfig.mcux, which means real, shipping hardware where sys_rand_get() was the weak PRNG.

The Kconfig had one more detail worth noticing: in that exact same case, the default cryptographic generator is PSA_CSPRNG_GENERATOR. The secure option was sitting right there on the affected platforms. The IPv6 code simply wasn’t asking for it.

xoshiro128++ is a general-purpose PRNG, designed for speed rather than for cryptography. The advisory names it as a non-cryptographic generator.

hardware entropy source
        │
        ▼
      seed
        │
        ▼
 non-cryptographic PRNG  (xoshiro128++)
        │
        ▼
  "random" outputs

This is the part that’s easy to miss. A strong seed doesn’t make a weak generator strong. It just means the generator starts somewhere unpredictable. After that, every output is fully determined by the internal state and the transition function. A CSPRNG is built to resist someone inferring that state from what it outputs. A general-purpose PRNG makes no such promise.

So checking where the seed comes from isn’t enough. The algorithm, the state size, the transition function, and who else can see its outputs all matter.

One well, many buckets

The xoshiro implementation keeps a single global 128-bit state (state[4] in random_xoshiro128.c), shared by every consumer of sys_rand_get().

And many of those consumers put their output straight on the wire.

                xoshiro128++ state  (128-bit, global, shared)
                              │
   ┌─────────┬─────────┬──────┼───────┬──────────┬
   ▼         ▼         ▼      ▼       ▼          ▼          
 source    DNS      CoAP IDs  DHCPv6  WebSocket  IPv6 IID
 ports     query    & tokens  xids    masks      secret key
           IDs

 └──────────── observable on the network ───────┘└ meant to
                                                  stay secret ┘

The advisory lists the ones that leak: ephemeral source ports (net_context.c), DNS query IDs (dns/resolve.c), CoAP message IDs and tokens (coap.c), DHCPv6 transaction IDs, and WebSocket masking keys (websocket.c).

Every one of those is a little postcard from the generator’s internal state. And the IID secret was drawn from the same well.

By now, this had stopped being about one line in ipv6.c. It was a system-level question about the relationship between:

  • the selected PRNG backend
  • its shared internal state
  • every other consumer of that state
  • how observable their outputs are
  • the secret drawn from the very same generator

The quieter failure

While I was in the backend code, subsys/random/random_entropy_device.c showed me a second problem, and honestly a sneakier one.

If the entropy driver fails, the general-purpose path can quietly fall back to samples from k_cycle_get_32(), the CPU cycle counter. The caller gets no error. Nothing tells it that the bytes it’s holding aren’t what it asked for.

caller requests random bytes
        │
        ▼
entropy driver fails
        │
        ▼
fallback to cycle-counter samples
        │
        ▼
caller carries on, none the wiser

For jitter on a retry timer, that’s graceful degradation. For a key you’ll use for the life of the device, it’s a counterfeit that passes inspection. The secure path behaves differently though: sys_csrand_get() reports failure, so the caller can decide not to proceed.

So what can an attacker actually do?

Given the secret, two things change.

Stable IIDs become computable. For RFC 7217, every other HMAC input (prefix, interface index, interface name, DAD counter) is guessable. With the secret, the attacker can compute the device’s address for any prefix. Instead of scanning 2^64 possibilities inside a /64, they can predict the host’s address directly, which removes the usual barrier to targeting it at all.

Temporary IIDs become linkable. For RFC 8981, the advisory explains that once the secret is known, a cheap search over the k_uptime_get_32() value mixed into generation is enough to link them. That lets an attacker connect temporary addresses that were supposed to look unrelated, and follow a device across network prefixes.

And what it isn’t

A few things worth keeping in perspective:

  • It’s not memory corruption, code execution, or an integrity or availability issue.
  • CONFIG_NET_IPV6_IID_STABLE and CONFIG_NET_IPV6_PE are both experimental and disabled by default.
  • Impact depends on the affected versions and on which random backend a build actually selects.
  • Builds using CONFIG_TEST_RANDOM_GENERATOR stay predictable by design, because that configuration deliberately routes sys_csrand_get() back to the test generator.

The published rating is CVSS 3.7. High attack complexity, limited confidentiality impact.

CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N

Where the advisory took over

My report stopped at the source code. I didn’t have hardware set up to test state recovery on a real device, so I reported the mismatch, the backend concern and the in-tree precedent, and left validation to the maintainers.

They did. The published advisory goes further than my report. It states that the xoshiro state transition is invertible: an observer of the device’s traffic can recover the generator state from the values above, then step it backwards to the moment the IID key was drawn. That’s the maintainers’ assessment, and the credit for that part of the analysis is theirs.

The fix

Maintainers opened PR #115807, “net: Fix generation of IPv6 IID and TCP ISN secret keys.” For the two files in my report, the change is small and exactly right:

/* before */
sys_rand_get(secret_key, sizeof(secret_key));

/* after */
if (sys_csrand_get(secret_key, sizeof(secret_key)) < 0) {
    return -EIO;
}

Both IID keys now come from the cryptographic API. If it fails, address generation stops instead of carrying on with a weak key.

The same PR also carried the maintainers’ own related hardening beyond what I reported:

  • IID callers that used to just log a warning on failure, then install :: or uninitialized stack memory as an address, now skip address configuration entirely.
  • TCP ISN key generation, which I’d only used as the good example, turned out to leave its key zeroed on failure. That’s now checked, and its initialization folded into one guarded helper.

The v3.7 LTS backport needed one more tweak. That branch has no PSA-based CSPRNG, so sys_csrand_get() didn’t work on every test platform. The answer there: NET_IPV6_PE now depends on CSPRNG_ENABLED. Where the secret can’t be generated securely, the feature refuses to exist rather than keep a promise it can’t.

The disclosure

I filed it as a private GitHub security advisory and worked through it with the maintainers in its comments. Once accepted, it was assigned a CVE ID and an embargo date. The fix landed days later as an ordinary public PR, followed by backports. I find it interesting how security vulnerabilities are patched right in the public eye, in innocent-looking PRs without mentioning words like ‘vulnerability’. Then the advisory stayed sealed for two months. The strangest part is knowing a commit’s real story and not being allowed to tell it!

Looking back

This started as a small question about a randomness API. It ended up running through IPv6 privacy mechanisms, cryptographic requirements, Kconfig selection logic, PRNG state, entropy failure handling, and a full coordinated disclosure across four branches.

And at the end of it, a CVE with my name on it as reporter.

A huge thank you to the Zephyr maintainers who took the report seriously, extended the analysis, and fixed not just the bug I pointed at but the failure paths around it.

If I had to compress the whole thing into one line:

Follow the call. Read the contract. Respect the config. Say only what you proved. Let the maintainers carry it home.

Randomness looks the same whether it’s keeping a secret or not. The only way to know is to ask what it promised, and follow it all the way down until it tells you the truth.

TL;DR

What Zephyr’s RFC 7217 stable and RFC 8981 temporary IPv6 interface identifiers (gen_stable_iid(), gen_temporary_iid()) were derived from a long-lived 128-bit secret generated with sys_rand_get(), an API Zephyr documents as not cryptographically secure.
Why it matters On boards whose entropy driver sets CONFIG_ENTROPY_NEEDS_PRNG (for example NXP MCUX TRNG), that API resolves to xoshiro128++: non-cryptographic, invertible, and sharing one global state with values that go straight onto the wire. Recover the state, recover the secret, and the privacy those addresses exist to provide is gone. A silent entropy-failure fallback adds a second weak path.
Severity Low, CVSS 3.7. AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N. Both features are experimental and off by default.
Affected Zephyr 3.7.0 through 4.4.2. Fix projected for 4.5.0.
Fix Maintainer-led PR #115807 moved both secrets to sys_csrand_get(), fails IID generation with -EIO instead of falling back. That covers the two IPv6 files my report was about. In the same PR, the maintainers also hardened related code outside my report’s scope: the IID callers and TCP ISN key generation. Backported to v4.4, v4.3 and v3.7 LTS.
IDs CVE-2026-19742 · GHSA-xfm2-gr93-8mx9 · CWE-338
Timeline Reported late July 2026, fixed and backported in August, published 26 October 2026.
My role Found it through source-level analysis, reported it privately, credited as reporter. The maintainers wrote the fix and extended the attack analysis.