News for hackers. Stuff that matters.
Re:Cracking random number generators (xoroshiro128+) by pbnjay on Tuesday August 22, 2017 @09:37AM (#15072219)
Author's title should be "Cracking PSEUDO-random number generators" - We should all basically assume that any PRNG will be easily cracked like this and not use them for anything important to security!

Always use a cryptographic RNG for important code!

Re:Cracking random number generators (xoroshiro128+) by tptacek on Tuesday August 22, 2017 @09:57AM (#15072414)
This shouldn't have been downvoted because it is exactly correct.

Cryptographic generators don't work like PCG and xoroshiro and Mersenne Twister. They're generally built by taking a cryptographically secure cipher or hash core, "keying" it with secret entropy, and running it in a streaming configuration (like CTR mode).

A properly designed CSPRNG can only be "cracked" in a few specific scenarios:

1. The primitive it's built on (or the streaming construction it's configured in) is broken, in which case the news for cryptography as a field is significantly bigger than the fact that an RNG has a flaw.

2. An attacker has exploited a systems flaw to directly disclose the contents of the memory the CSPRNG is operating out of, in which case you have bigger problems than your CSPRNG.

3. The secrets that key the generator have become predictable. This is in practice the only way CSPRNGs get broken (unintentionally), and, in practice, always means the CSPRNG wasn't initialized properly (the "cold start entropy problem").

You should use the getrandom() system call, or read from /dev/urandom, to the exclusion of all other mechanisms.

Re:Cracking random number generators (xoroshiro128+) by IanCal on Tuesday August 22, 2017 @11:02AM (#15073072)
I'd have called that a PRNG, because to me there were only two main categories. Pseudo-random, where it's designed to be unpredictable, and actually random where it is based on an external hardware source of true random information.

A CSPRNG is surely a type of PRNG. Is that not right?

Their comment doesn't really seem correct to me. The title is "Cracking random number generators (xoroshiro128+)" which seems pretty accurate to me. The article definitely doesn't seem to say it's breaking anything other than a very specific, flawed random number generator.

Re:Cracking random number generators (xoroshiro128+) by tptacek on Tuesday August 22, 2017 @11:47AM (#15073530)
I'd have added "Cryptographically secure" and not capitalized "pseudo", but that's small-stakes stuff. The point he's making is the most important safety point on this topic.
Re:Cracking random number generators (xoroshiro128+) by pbnjay on Tuesday August 22, 2017 @02:16PM (#15075031)
Duly noted!

I'm not in this field, but I know enough to know what not to do (most of the time).

Re:Cracking random number generators (xoroshiro128+) by alphaalpha101 on Tuesday August 22, 2017 @07:32PM (#15077219)
>I'd have called that a PRNG, because to me there were only two main categories. Pseudo-random, where it's designed to be unpredictable, and actually random where it is based on an external hardware source of true random information.

PRNGs produce numbers that seem hard to predict. CSPRNGs product numbers that actually are hard to predict, assuming P != NP (kind of).

Re:Cracking random number generators (xoroshiro128+) by raverbashing on Tuesday August 22, 2017 @03:22PM (#15075551)
> A CSPRNG is surely a type of PRNG. Is that not right?

Yes. In the same way the POTUS limousine is a car

Re:Cracking random number generators (xoroshiro128+) by baby on Tuesday August 22, 2017 @10:01AM (#15072456)
FWIW you rarely hear the term CSPRNG in crypto I find. I always call these PRNGs but I can see how having a naming distinction could help prevent misuse in the applied world.

Edit: thinking a bit more about it. I guess it wouldn't make sense to call anything "crypto" in crypto. It's like calling fries "french fries" in France. There they're just fries. I know this is a bad example because french fries are probably not from France :o)

Re:Cracking random number generators (xoroshiro128+) by gwbas1c on Tuesday August 22, 2017 @11:58AM (#15073649)
But, it's important to make the decision because a "crypto" psudorandom number generator may be significantly slower than an insecure generator.

This is critical for performance-sensitive operations. For example, certain audio and video codecs need to simulate noise. In these cases, high performance is much more important than cryptographic security.

Re:Cracking random number generators (xoroshiro128+) by tptacek on Tuesday August 22, 2017 @12:04PM (#15073722)
In the overwhelming majority of cases, cryptographic random bit generation performs perfectly adequately. Insecure random number generation is wildly overused in our industry. CSPRNGs should be the default application RNGs on most platforms, and should always be the default choice for developers.

Which makes stuff like PCG even weirder! Because in most cases, what you want is a somewhat slower generator that has better failsafe behavior.

Re:Cracking random number generators (xoroshiro128+) by aidenn0 on Tuesday August 22, 2017 @01:07PM (#15074347)
Many microbenchmarks intended to measure other things become benchmarks of your RNG if you use anything slower than an LCG. This biases a lot of places towards using the poorest RNG they can get away with.

This is made worse by many purchasing decisions made based upon microbenchmarks with the requirements of "default settings" so defaulting to insecure is a sound business decision in more cases than you might think.

Re:Cracking random number generators (xoroshiro128+) by sanxiyn on Tuesday August 22, 2017 @03:37PM (#15075670)
This is indeed a tragedy, because it could have been easily avoided by including LCG in microbenchmarks. LCG is less than ten lines, so even for very short microbenchmarks including RNG is very feasible. Alas, I guess such reasonable people don't write microbenchmarks in the first place.
Re:Cracking random number generators (xoroshiro128+) by tptacek on Tuesday August 22, 2017 @04:05PM (#15075902)
I understand the "broken benchmarks" problem and I acknowledge that there are some cases that are so demanding and have such low security sensitivity that it makes sense to have an LCG in the standard library.

But I stand by my argument that the default platform RNG should be a CSPRNG, and that developers should reach for a CSPRNG by default.

Which makes all the attention we've been giving to stuff like xoroshiro128+ and PCG pretty confusing to me. It feels like people arguing very earnestly about non-problems, while ignoring a huge problem in our standard libraries.

Re:Cracking random number generators (xoroshiro128+) by alphaalpha101 on Tuesday August 22, 2017 @07:34PM (#15077233)
>stuff like PCG

PCG is cryptographically secure, though. Or at least, it is as cryptographically secure as any other PRNG in the sense that nobody actually knows how to predict it, many have tried, nobody has succeeded, but nobody has proved it impossible.

Re:Cracking random number generators (xoroshiro128+) by tptacek on Tuesday August 22, 2017 @10:02PM (#15077963)
So, it's "cryptographically secure" in the "sci.crypt proposal" sense.
Re:Cracking random number generators (xoroshiro128+) by anfractuosity on Tuesday August 22, 2017 @09:38AM (#15072230)
Aren't cryptographic random number generators, still PRNGs.

It sounds a fun problem, predicting the future random numbers, going to have to have a play later at trying it.

Re:Cracking random number generators (xoroshiro128+) by hlieberman on Tuesday August 22, 2017 @09:41AM (#15072247)
Yes. GP is mistaken here; this is novel work that is somewhat concerning -- mostly in how it might apply to other similarly state-based RNGs.
Re:Cracking random number generators (xoroshiro128+) by karanlyons on Tuesday August 22, 2017 @11:02AM (#15073078)
I wouldn’t say this work is novel in the general case of “PRNGs are not CSPRNGs”. You can throw a constraint solver at most any PRNG and given sufficient output determine the state fairly easily. As a datapoint, doing this for xoroshiro took me half an hour: https://gist.github.com/karanlyons/805dbcc9e898dbd17e06f2627...
Re:Cracking random number generators (xoroshiro128+) by anfractuosity on Tuesday August 22, 2017 @11:10AM (#15073145)
Heh, that sounds cool. I'll save opening that link for later.
Re:Cracking random number generators (xoroshiro128+) by karanlyons on Tuesday August 22, 2017 @11:13AM (#15073171)
Don’t worry, it’s safe: I didn’t put the actual solver, just proof that I solved it. Wouldn’t want to spoil the fun for anyone else :)
Re:Cracking random number generators (xoroshiro128+) by pbnjay on Tuesday August 22, 2017 @10:08AM (#15072533)
I made no comment on the work done here, it is novel and concerning if you use the outputs for important things. My comment is that non-cryptographic random number generators should not be used for security-critical functions.

These functions are specifically built for speed, not security.

Re:Cracking random number generators (xoroshiro128+) by DiThi on Tuesday August 22, 2017 @09:44AM (#15072273)
Strong crypto RNGs use PRNGs but combines sources of entropy, environmental noise from devices such as the number of CPU cycles between user keystrokes. T̶h̶a̶t̶'̶s̶ ̶t̶h̶e̶ ̶d̶i̶f̶f̶e̶r̶e̶n̶c̶e̶ ̶b̶e̶t̶w̶e̶e̶n̶ ̶/̶d̶e̶v̶/̶r̶a̶n̶d̶o̶m̶ ̶a̶n̶d̶ ̶/̶d̶e̶v̶/̶u̶r̶a̶n̶d̶o̶m̶ ̶i̶n̶ ̶L̶i̶n̶u̶x̶.̶
Re:Cracking random number generators (xoroshiro128+) by yorwba on Tuesday August 22, 2017 @12:57PM (#15074238)
I was wondering how you managed to strike out part of your comment when https://news.ycombinator.com/formatdoc doesn't mention any markup for that, but then I realized you were using the "combining long stroke overlay" Unicode character ( ̶). Nice trick.
Re:Cracking random number generators (xoroshiro128+) by bradleyjg on Tuesday August 22, 2017 @09:56AM (#15072405)
After an initial seeding the only thing additional entropy adds is limiting the damage from a compromise of the internal state of the PRNG. And if the OS's internal PRNG state is compromised, what makes you think your process isn't?
Re:Cracking random number generators (xoroshiro128+) by DiThi on Tuesday August 22, 2017 @08:37PM (#15077561)
What if you're using several PRNGs XORed together and reseeded frequently?
Re:Cracking random number generators (xoroshiro128+) by bradleyjg on Wednesday August 23, 2017 @02:09PM (#15083719)
Why would you want to do that?
Re:Cracking random number generators (xoroshiro128+) by DiThi on Wednesday August 23, 2017 @06:24PM (#15085721)
That would make much more difficult (if not impossible) to guess the internal state of all RNGs.
Re:Cracking random number generators (xoroshiro128+) by bradleyjg on Wednesday August 23, 2017 @06:36PM (#15085796)
You can't guess the internal state of a CSPRNG based on the output. That's what makes it CS. The only way to get the internal state is to break the OS protection and look at the memory directly. And if the attacker can do that, then they can do it for the multiple PRNG version too.
Re:Cracking random number generators (xoroshiro128+) by DiThi on Thursday August 24, 2017 @10:18AM (#15090280)
I misunderstood the context in your replies. We were kind of talking about different topics.
Re:Cracking random number generators (xoroshiro128+) by Tomte on Tuesday August 22, 2017 @09:50AM (#15072338)
No, that difference (between /dev/random and /dev/urandom) does not exist, has never existed and will never exist. Please don't spread those myths.
Re:Cracking random number generators (xoroshiro128+) by andruby on Tuesday August 22, 2017 @09:55AM (#15072392)
As I am uninformed on the subject, could you tell me the difference between /dev/random and /dev/urandom?
Re:Cracking random number generators (xoroshiro128+) by Tomte on Tuesday August 22, 2017 @10:07AM (#15072519)
You're right, that was too short and thus too harsh. Please accept my apologies.

So a short roundup:

/dev/random and /dev/urandom used to be exactly the same (on Linux), except that /dev/random did some voodoo "entropy estimation" that the Linux kernel guys are totally in love with, but everyone else doesn't trust anyway. Even if there was a plausible model how to estimate entropy, which there isn't.

In the meantime things have changed quite a bit. But the main thing to know is the same: /dev/urandom is the device you want to use for cryptographic randomness. /dev/random is an oddity that will be there forever because Linux takes backwards compatibility (for user space) extremely seriously.

(On other Unixoid platforms you also want /dev/urandom)

If you can use syscalls and don't need a device, use getrandom(2) over /dev/urandom. It's better.

Oh, and please note that the Linux man pages have been updated! They now state clearly that /dev/urandom is suitable for cryptographic use. Of course, lots of old man pages floating around on the web.

Re:Cracking random number generators (xoroshiro128+) by filleokus on Tuesday August 22, 2017 @09:57AM (#15072412)
Quite a long read, but I think it explains the situation quite well: https://www.2uo.de/myths-about-urandom/
Re:Cracking random number generators (xoroshiro128+) by Tomte on Tuesday August 22, 2017 @10:03AM (#15072473)
Unfortunately, the article isn't in the best shape right now.

Back when it was written, things were clear: random and urandom are the same. Then came getrandom as a distraction. Now urandom is based on chacha. So it's different (but not worse – still, harder to explain).

The article's structure couldn't easily accomodate those changes, and time was and is in short supply, and so it's not wrong, but much less forceful and clear than it used to be. I hope it shapes up soon, but don't promise anything!

Still, I don't know a more up-to-date article. Maybe Thomas Pornin has something newer on StackOverflow?

Re:Cracking random number generators (xoroshiro128+) by snakeanus on Tuesday August 22, 2017 @10:06AM (#15072503)
> Now urandom is based on chacha

Did Linux follow the example set by OpenBSD?

Re:Cracking random number generators (xoroshiro128+) by Tomte on Tuesday August 22, 2017 @10:08AM (#15072532)
I think so, yes. getrandom(2) is also an OpenBSD thing (getentropy), but of course they had to rename it and add a few options...
Re:Cracking random number generators (xoroshiro128+) by snakeanus on Tuesday August 22, 2017 @10:02AM (#15072468)
Re:Cracking random number generators (xoroshiro128+) by DiThi on Tuesday August 22, 2017 @11:09AM (#15073131)
But there IS a difference. You should correct me by saying "both use entropy sources but /dev/random blocks (or used to block) unnecessarily when the kernel considers there's not enough entropy".

By your answers I don't know if still blocks or not.

Re:Cracking random number generators (xoroshiro128+) by csomar on Tuesday August 22, 2017 @09:57AM (#15072423)
Unless Quantum Uncertainty holds true, and your RNG uses Quantum randomness then all RNG are pseudo.
Re:Cracking random number generators (xoroshiro128+) by imaginenore on Tuesday August 22, 2017 @10:58AM (#15073026)
Can you crack this PRNG without knowing the seed?

    f(1) = 1 // seed

    f(n) = sha512(f(n-1) . f(1))
Re:Cracking random number generators (xoroshiro128+) by mdpopescu on Tuesday August 22, 2017 @03:38PM (#15075682)
This is similar to Yarrow / Fortuna (internal state is a counter, output is the hash of the state) so I'm guessing it's not breakable, at least not trivially.
Re:Cracking random number generators (xoroshiro128+) by sdevlin on Tuesday August 22, 2017 @11:48AM (#15073539)
I guess it depends what you mean by “crack”. Given f(1), which I assume is public, you can predict all future outputs.
Re:Cracking random number generators (xoroshiro128+) by imaginenore on Tuesday August 22, 2017 @01:13PM (#15074423)
I said without knowing the seed, so f(1) is not public, only f(n) formula is.
Re:Cracking random number generators (xoroshiro128+) by benchaney on Tuesday August 22, 2017 @05:34PM (#15076588)
f(1) is the first batch of output.
Re:Cracking random number generators (xoroshiro128+) by IshKebab on Tuesday August 22, 2017 @12:00PM (#15073679)
That is not what we mean by "crack". Read the article.
Re:Cracking random number generators (xoroshiro128+) by VikingCoder on Tuesday August 22, 2017 @01:47PM (#15074766)
"Always use a cryptographic PSUEDO-RNG for important code!"

Just because it's "cryptographic" doesn't mean it's not pseudo-random.