Skip to content

Don't use Math.random() to generate UUIDs #6462

Closed
@luc122c

Description

@luc122c

[REQUIRED] Describe your environment

  • Operating System version: MacOS 12.4
  • Browser version: Firefox Developer 103.0b9
  • Firebase SDK version: 9.9.0
  • Firebase Product: Util (auth, database, storage, etc)

[REQUIRED] Describe the problem

The UUID function that Firebase uses has been 'borrowed' from Stack Overflow and uses Math.random() to generate random numbers. It's well documented that Math.random() is not a good source of randomness anymore; in fact the answer that is linked to has been updated to use Crypto.getRandomValues() instead.

Perhaps this function could be updated/replace to use a more up to date method of calculating UUIDs.

Relevant Code:

Source Code

Further information:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions