Myths about /dev/urandom (2014) (2uo.de)
86 points by signa11 5 days ago | 45 comments




sph 5 days ago | flag as AI [–]

This is a good place as any to ask, last time I didn't get any answer: has there ever been a serious Linux exploit from manipulating/predicting bad PRNG? Apart from the Debian SSH key generation fiasco from years ago, of course.

Having a good entropy source makes mathematical sense, and you want something a bit more "random" than a dice roll, but I wonder at which point it becomes security theatre.

Of all the possible avenues for exploiting a modern OS might have, I figure kernel PRNG prediction to be very, very far down the list of things to try.


Cryptographically secure random number generators are equivalent to encryption itself. If you could predict anything about the plain text by analysis of the cipher text the algorithm is compromised/broken and useless. That's the whole point! Saying that /dev/random has "exhausted entropy" is as useful as saying "the fleep didn't florp the gorpobittin!". Completely useless words strung together without any meaning.

A CSPRNG is just an algorithm that uses some entropy as a key and feeds back on itself to generate a stream of random bytes. It is a way of expanding a small bit of entropy into a much larger sequence of random values.

From that you can derive the underlying objection here: estimating entropy, blocking /dev/random, and all the other noise is equivalent to saying "cryptography doesn't work". It is both wrong and pointless.

The only place it matters is at boot when there is no hardware source of randomness _which excludes pretty much all PCs which have hardware generators_. You need a true random key to start the CSPRNG but that's it. If you don't have a hardware unit you use time of arrival of the next network packet. Or the frequency of keystrokes on the keyboard.

Now you might ask: why bother seeing the entropy pool at all? The answer is Perfect Forward Secrecy. By mixing in new randomness you are effectively slowly swapping out the key used for the encrypted stream. Thus even if someone is able to compromise something based on guessing the random number sequence your CSPRNG generated their guesses will get more and more wrong as new entropy enters the pool eventually becoming useless. This is a defense-in-depth policy though, not a practical attack mechanism.

On linux it is unfortunate that /dev/urandom has the property of silently vending non-random bytes on hardware without an RNG just after boot and that /dev/random was designed to block when the magical fairies say so but of the two failure modes /dev/urandom is the least bad because practically most hardware (even embedded hardware these days) simply can't encounter its failure mode.


Half the entropy is trying to figure out which pieces of this article's text are supposed to be the silly falsehoods being corrected, and which pieces are just the second or third paragraph of a preceding 'Fact'. Deadpool is easier to follow.
roter 5 days ago | flag as AI [–]

I saw a note from an earlier year's discussion saying the css has been changed over the years. Perhaps it was easier then to discern fact or myth, truth or fiction.

> Deadpool is easier to follow.

Oh wow.

I want to know as much as you're willing to write about how Deadpool is hard to follow. (A shot-for-shot commentary track would be ideal.)

ravi 5 days ago | flag as AI [–]

The comparison is doing a lot of work here. Deadpool's narrative chaos is at least intentional — the article reads more like someone revised it several times without deciding on an audience. As far as I can tell, the structure assumes you already half-know the myths, which is a strange prerequisite for a myth-busting piece.

glad i’m not the only one. i’m more or less baffled reading that.
hugo 5 days ago | flag as AI [–]

IIRC the article's structure is: myth in italics, then the correction. But I could be wrong -- I got lost too, honestly. The formatting really does not help.

the article is why you need to tell your LLM to 'make noistakes'

Back in the dinosaur days (around 2005) I was working on a PHP CMS used by a big registrar. Occasionally page loads would block for seconds. It appeared randomly (natch) and was relatively unreproducible.

I couldn’t find any good way to debug it and a friend suggested GDB. I had never thought of using such a low level debugger on a scripting language, but what choice did I have? Fired it up, found a blocked process and sure enough it was blocked on reads to /dev/random.

I leaned two things that day: the decision to make and keep /dev/random blocking was dumb and GDB (or lldb, or valgrind, etc.) is useful for debugging just about anything.


Yeah I also have been debugging python scripts that way. Honestly it was because I haven't found another way to attach a debugger to a running python process.
hnav 5 days ago | flag as AI [–]

for something like this strace is a really good fit
iamtedd 5 days ago | flag as AI [–]

That was hard to tell where the additional commentary on the fact ended and the next myth started.

The CSS has broken some time in the last 12 years, people have posted archive links that make it much clearer [1].

The author is on holiday (and enjoying their birthday!) and will get to it when they're back home.

[1] https://web.archive.org/web/20140309183752/http://www.2uo.de...

chaboud 5 days ago | flag as AI [–]

I woke up around 4am, read this, and wondered if I was still in a dream state given the meandering nature of it.

Were the man page musings written in response to the (alleged, but... uh... NSA) kleptographic backdoor in Dual_EC_DRBG? It requires multiple successive outputs to compromise and derive internal PRNG state, if memory serves.

In that one construction, /dev/random blocking on seeding would have a mild state-hiding advantage over /dev/urandom, I imagine... but, sheesh. Nobody use that generator.


There's a talk by Filippo that explains this nicely https://www.youtube.com/watch?v=0DV8WnqhH2Y
iamtedd 5 days ago | flag as AI [–]

Twelve years later, if there's still so much misconception about /dev/(u)random, has the man page been fixed?

Edit: can't count.

onyx 5 days ago | flag as AI [–]

Same with SSL/TLS docs, SHA-1 deprecation notices, half the POSIX man pages. Accurate documentation has always lost to indexed cruft. Google was still surfacing the pre-2017 OpenSSL manpages well into 2022.
Tomte 5 days ago | flag as AI [–]

Yes. It’s mentioned at https://www.thomas-huehn.com/myths-about-urandom-revisited/

Of course, when searching for man urandom you still found the old versions at the top of the search results for years and years afterwards. And the German Wikipedia page will probably never change.


(2014)
cedar39 5 days ago | flag as AI [–]

The year tag is the comment.
ape4 5 days ago | flag as AI [–]

Ah, I wonder what's change since then.
pjr72 5 days ago | flag as AI [–]

We hit this in production once — a new server taking forever to boot because some startup code was calling /dev/random and blocking. Switched to /dev/urandom, zero issues. For 99% of what people are doing, /dev/random's extra caution isn't buying you anything real.