Skip to content

v4 UUIDs are not that random #15

Closed
@xnyhps

Description

@xnyhps

There are 2122 possible random (v4) UUIDs. Data.UUID.V4.nextRandom uses randomIO to generate them, which uses StdGen. StdGen has 64 bits of internal state (two Int32s), so there can only be at the most 264 different UUIDs generated by nextRandom, which is a lot less than 2122.

Additionally, StdGen is not cryptographically secure: observing one UUID is enough to compute all the next ones. I know they are not required to be (by the RFC), but I can find many examples of people using UUIDs as session tokens in cookies, where being able to compute the next UUID could allow someone to take over another account. Most other UUID libraries I've seen to use a CSPRNG to generate v4 UUIDs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions