Am I the only one that thinks Math.random should be fixed instead of the hundreds of apps that used it wrong? Why shouldn't we make all random number generators at least somewhat secure?
I think this is a more general question because C's rand() also comes to mind as sucking very hard. There are, across languages and OSes, very bad decisions from the past that we keep dragging on.
I just see this as a natural development of things. Companies have prioritized shipping shit fast. The security industry is snake oil on top of bad software (sorry, guys), and the software industry is even a larger joke. Now we are seeing the consequences. The only way forward is to increase spend on real security and to slow the fuck down.
And yet the trend is to speed up, trust the ai tools and basically operate increasingly complex systems while the people running them have a rapidly dwindling grasp of how everything works.
the objection is something along the lines of how the people who depend on it assume high performance and if every PRNG was made into a CSPRNG there would be performance regressions or something.
frankly, it should be made their problem and if the performance isn't good enough for them they should migrate to custom insecure PRNGs themselves.
I feel like the hardware should have secure and performant true random number generators by now. /dev/urandom with decent throughput should be possible by now.
Maybe but then it would end up being secure only on newer environments (new browsers for client side code, which is something you don’t control), while the same code would be insecure when run on an older environment.
This is what OpenBSD did many years ago with rand(3). Quoting the manpage:
Standards insist that this interface return deterministic results.
Unsafe usage is very common, so OpenBSD changed the subsystem to return
non-deterministic results by default.
In OpenBSD the seed variable is ignored, and strong random number results will be provided from arc4random(3).
...
If the standardized behavior is required srand_deterministic() can be
substituted for srand(), then subsequent rand() calls will return results
using the deterministic algorithm.
This is the kind of solution that should really be the default approach to this kind of thing. Break the behavior but give an easy way to get to the old functionality. This forces developers to make a conscious choice to get the old behavior. Maximum flexibility with minimum collateral damage.
Replies (6)
Replies (1)
I just see this as a natural development of things. Companies have prioritized shipping shit fast. The security industry is snake oil on top of bad software (sorry, guys), and the software industry is even a larger joke. Now we are seeing the consequences. The only way forward is to increase spend on real security and to slow the fuck down.
Replies (1)
frankly, it should be made their problem and if the performance isn't good enough for them they should migrate to custom insecure PRNGs themselves.
Replies (1)
That also isn’t ideal
Replies (1)
Standards insist that this interface return deterministic results. Unsafe usage is very common, so OpenBSD changed the subsystem to return non-deterministic results by default.
In OpenBSD the seed variable is ignored, and strong random number results will be provided from arc4random(3).
...
If the standardized behavior is required srand_deterministic() can be substituted for srand(), then subsequent rand() calls will return results using the deterministic algorithm.
https://man.openbsd.org/rand
So if you need pretend random numbers, you can still get them. But the preferred choice is to use the arc4random family of functions.
Replies (1)