phobos icon indicating copy to clipboard operation
phobos copied to clipboard

Randomness in UUID generation is insufficient.

Open dlangBugzillaToGithub opened this issue 1 year ago • 6 comments

jdougan reported this on 2024-11-25T00:53:20Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=24877

Description

UUIDs generated by randomUUID() use the random numbers from std.random, granted with an unpredictableSeed, but from a fundamentally insecure and low entropy source.

As per the latest UUID RFC, RFC-8562, Section 8 this should at least have the option of using an actual quality entropy source.

https://www.rfc-editor.org/rfc/rfc9562.html in section 8 says:

"Instead CSPRNG data SHOULD be selected from a source with sufficient entropy to ensure guaranteed uniqueness among UUID generation."

dlangBugzillaToGithub avatar Nov 25 '24 00:11 dlangBugzillaToGithub

dfj1esp02 commented on 2024-11-25T09:49:06Z

There's an overload that accepts an RNG
---
UUID randomUUID(RNG)(ref RNG randomGen);
---

dlangBugzillaToGithub avatar Nov 25 '24 09:11 dlangBugzillaToGithub

jdougan commented on 2024-11-26T04:32:30Z

and no cryptographic streng RNG to use with it.

https://breakpoint.purrfect.fr/article/cracking_phobos_uuid.html

dlangBugzillaToGithub avatar Nov 26 '24 04:11 dlangBugzillaToGithub

Adding here a link to my onw implementation of UUIDv4 and v7, if useful. https://gist.github.com/trikko/31d12ecafc76c7eba02edd81e5d1e8e8

trikko avatar Apr 30 '25 08:04 trikko

It would be great to be able to manipulate with UUIDv7 with Phobos

denizzzka avatar Apr 30 '25 09:04 denizzzka

#10748 should allow us to resolve the randomness issue.

Regarding support for UUIDv7, it might be worth opening a separate issue for that enhancement.

0xEAB avatar May 01 '25 00:05 0xEAB

UUIDv7 randomness check failure: https://github.com/dlang/phobos/pull/10865 This makes UUIDv7 completely unusable

denizzzka avatar Sep 14 '25 12:09 denizzzka