Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

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

Package

Codestin Search App org.scala-js:scalajs-library_2.11 (Maven)

Affected versions

< 1.10.0

Patched versions

1.10.0
Codestin Search App org.scala-js:scalajs-library_2.12 (Maven)
< 1.10.0
1.10.0
Codestin Search App 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

Weaknesses

Small Space of Random Values

The number of possible random values is smaller than needed by the product, making it more susceptible to brute force attacks. Learn more on MITRE.

Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG)

The product uses a Pseudo-Random Number Generator (PRNG) in a security context, but the PRNG's algorithm is not cryptographically strong. Learn more on MITRE.

Predictable Exact Value from Previous Values

An exact value or random number can be precisely predicted by observing previous values. Learn more on MITRE.

Credits