News for hackers. Stuff that matters.
Re:Should random() be banned? by FalconSensei on Thursday February 11, 2021 @04:27PM (#26107511)
Also: if someone is working on crypto and doesn't know that random() isn't true random, should they be working on that?
Re:Should random() be banned? by aaomidi on Thursday February 11, 2021 @07:29PM (#26109443)
There isn't a threshold where you become capable of working on crypto problems and code.

Making this safer makes mistakes far less likely and makes all of us safer.

Re:Should random() be banned? by bigiain on Thursday February 11, 2021 @10:18PM (#26110404)
I disagree.

Making one specific aspect of incompetent crypto coding “safer” doesn’t solve any of the problems.

We can argue about what threshold you need to reach to be considered “capable” of writing crypto code (that’s not just a learning exercise), but not knowing the deficiencies of random() is clearly well below that bar. Even knowing that is barely past the “don’t eat your crayons” level of skill.

If anything, a hook in your CI pipeline that automatically fires anybody who checks in code using random() in a cryptographic context is a better way to “make all of us safer”.

Re:Should random() be banned? by aaomidi on Thursday February 11, 2021 @11:55PM (#26110867)
You could be a great mathematician and not realize what kind of random you're picking. It's not as simple as you put it.

This discussion goes for other stuff too. Rust is getting popular because even amazing C and C++ devs make terrible mistakes that cause severe security and privacy problems down the line.

Re:Should random() be banned? by thekyle on Friday February 12, 2021 @10:16AM (#26114512)
Just because someone is a great mathematician does not mean they would be a great cryptographer. Mathematics and cryptography are about as related as computer science and cryptography (not that much).
Re:Should random() be banned? by lucideer on Friday February 12, 2021 @10:22AM (#26114592)
> should they be

This is the point of people suggesting things like bans or explicit warnings. They "shouldn't", but what's stopping them.

Re:Should random() be banned? by JauntyHatAngle on Thursday February 11, 2021 @06:50PM (#26109140)
The level of expertise far outstrips the demand in my experience, so the "should" often becomes moot.
Re:Should random() be banned? by adrr on Thursday February 11, 2021 @09:12PM (#26110060)
I’ve seen guids used as secrets on APIs/cookies. Those are easily guessable and also not random.
Re:Should random() be banned? by hombre_fatal on Thursday February 11, 2021 @09:27PM (#26110137)
Not sure what you have in mind when you say guids, but the word guid doesn't confer any info here. Most people are referring to uuids when they say guid, and a v4 uuid has 122 bits of randomness. A random 122 bit number can certainly be sufficient for most applications like api keys over the network.
Re:Should random() be banned? by matthewdgreen on Thursday February 11, 2021 @09:42PM (#26110198)
Some standard uuid libraries have weird not-very-random fallbacks when the RNG fails to initialize. It’s rare, but you can get strange stuff without realizing it. Better to use a real RNG and check error codes.
Re:Should random() be banned? by hombre_fatal on Friday February 12, 2021 @05:07AM (#26112085)
Yep, there's no rule of thumb that can spare you from reading the docs and knowing basic things about the code you're about to pull in.
Re:Should random() be banned? by adrr on Thursday February 11, 2021 @09:51PM (#26110252)
Guids is uuid and they can be interchanged but they all have same concept of creating unique identifiers that won’t ever collide.

It isn’t random is the problem and they are are used everywhere as a secret. People think they are random 122bit value.

Re:Should random() be banned? by Dylan16807 on Thursday February 11, 2021 @09:57PM (#26110286)
No, that's why you need to be specific. v4 is random, other versions aren't.
Re:Should random() be banned? by adrr on Thursday February 11, 2021 @09:59PM (#26110304)
You’re right I’d just looked at the rail implementation. I was basing it on my past knowledge of windows GUID implementation.