-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use appropriate RNG for version 4 generation #52
Comments
That's a good point. Version 4 UUIDs are supposed to be un-guessable, and there are potentially many scenarios where an attacker being able to guess at generated UUIDs would be a security vulnerability. |
Well... While I agree that
P.S.: The |
Is that a guarantee, or an implementation detail? Has the implementation been verified for correctness? The
Many experts recommend that using the system RNG is always a better, less error-prone choice. |
In the order of your questions:
Both. The Rust developers have decided to not include insecure RNGs by default some time ago. Thus the StdRng is always a CSPRNG.
Unfortunately they don't have unit tests yet as it seems. I guess someone should create a PR for it. On the other hand the ISAAC RNG in the code is a near identical translation of the code in the original paper which in turn has been verified. The only thing I'd worry about now is how the PRNG is seeded by the OsRng.
Just like the man page recommends random over urandom, because it's a good recommendation if you are not familiar with the topic.
Well I'd argue that guys like him are as much an "expert" as anyone else though… But anyways: The article you linked basically tells you only 2 things:
I absolutely agree about both points. This is actually a good recommendation. The problem now is that I still don't think that the hefty performance hit you take that way is worth it in this case, since the IsaacRng is a very strong and correctly implemented CSPRNG and IMHO enough for this. |
I originally believed that the
Note that it's talking here about using it as an entropy source, rather than just using it as a CSPRNG. Given this, my only concern about using
I'm not sure what you mean by this. The At this point it's probably a bad idea for the |
I mean: If I remember correctly there where multiple points in time when official Rust developers said that using a insecure PRNG by default would be a bad idea. Instead they said, that using a CSPRNG by default is always preferable. Breaking that change retroactively in the rand crate would be major breaking change. So yeah: I 💯 agree that the rand crate should guarantee the security of the |
We need to find a way to use |
More recently, rand considered switching to HC-128 and it was merged. It seems that |
@uuid-rs/uuid what is blocking this issue.. if anything... |
@kinggoesgaming we've made it possible to build a v4 uuid using externally generated bytes, so could punt on this. How random bytes are generated is an implementation detail though, so there's nothing really blocking this issue and this issue doesn't really block anything else. |
close this based on @KodrAus's explanation |
Version 4 identifiers are generally expected to be globally random, unique and collision free. To ensure this, a cryptographically secure random number generator should be used. Most if not all implementations (for example,
libuuid
, Java and Python) do this.Secure defaults are important. The current code uses
thread_rng
, which is not suitable for this purpose according to therand
documentation.The text was updated successfully, but these errors were encountered: