8000 java.util.UUID.randomUUID() uses an insecure PRNG · Advisory · scala-js/scala-js · GitHub
[go: up one dir, main page]

Skip to content

java.util.UUID.randomUUID() uses an insecure PRNG

High
sjrd published GHSA-j2f9-w8wh-9ww4 Apr 4, 2022

Package

maven org.scala-js:scalajs-library_2.11 (Maven)

Affected versions

< 1.10.0

Patched versions

1.10.0
maven org.scala-js:scalajs-library_2.12 (Maven)
< 1.10.0
1.10.0
maven org.scala-js:scalajs-library_2.13 (Maven)
< 1.10.0
1.10.0

Description

Impact

Generation of insufficiently random numbers in java.util.UUID.randomUUID() allows attackers to predict future generated UUIDs via observation of previously generated UUIDs (observing a single generated UUID may be sufficient). Depending on whether and how particular applications expose and use the generated UUIDs, the actual vector and impact vary.

If you use java.util.UUID.randomUUID() to generate user-visible UUIDs, and predicting subsequent UUIDs poses a security risk to your application, you are affected.

In addition, the underlying PRNG has only 48 bits of state, which means that at most 2^48 different UUIDs may be generated by randomUUID(). This can cause likely collisions between generated UUIDs.

Patches

Scala.js v1.10.0 fixes the issue. It uses java.security.SecureRandom to implement randomUUID().

java.security.SecureRandom is not provided by Scala.js core. Therefore, to be able to use randomUUID(), you will need to add a dependency on scalajs-java-securerandom. Failing to do so will result in linking errors (i.e., fastLinkJS/fullLinkJS will fail).

Workarounds

If you cannot upgrade, you should generate UUIDs using a different method than randomUUID(). Use a better random number generator, for example crypto.getRandomValues() in browsers or require("crypto").randomFillSync in Node.js.

References

  • #4657 Scala.js should not provide a cryptographically insecure UUID.randomUUID() implementation

Severity

High

CVE ID

CVE-2022-28355

Credits

0