<-- Back

Cryptographically weak pseudo-random number generator Math.random() in the GenerateUniqueID action of Nanoflow Commons

Issue

The NanoflowCommons.GenerateUniqueID JavaScript action in the Nanoflow Commons module uses Math.random(), a cryptographically weak pseudo-random number generator (PRNG).

Environment

Nanoflow Commons (all versions)

Cause

The GenerateUniqueID action generates an identifier in the format <sessionObjectId>:<counter>:<rnd>, where:

  • sessionObjectId is the object identifier of the System.Session record of the current session.
  • counter is a sequential number that increments on each call.
  • rnd is a random number between zero and ten thousand, generated with Math.random().

The action provides identifiers that are unique per session and device. Typical uses are temporary keys for client-created items, correlation identifiers for client actions, and de-duplication markers. Uniqueness comes from the session identifier and the counter. The random suffix is an additional element that reduces ambiguity.

In this action, the use of Math.random() does not indicate an exploitable weakness, because no security decision depends on the unpredictability of the value. The Mendix Runtime authenticates requests with separate, more secure methods.

Solution / Workaround

This behavior is intended. No change to the Nanoflow Commons module is required. Apply the following steps to prevent misuse of the identifier:

  1. Use the generated identifier only as a temporary client-side key, a correlation identifier, or a de-duplication marker.
  2. Keep the identifier out of security contexts, such as authentication, authorization, session management, and access-token generation.
  3. For tokens and secrets, generate the value server-side in a microflow and return it to the client.

The Mendix development team is evaluating a cryptographically secure replacement for Math.random(). 

Internal information related

  • 290865
  • MOO-2546
  • C07BE6K6F5L/p1793022997083639

Additional information

Mendix documentation: Nanoflow Commons

Have more questions? Submit a request

0 Comments

Article is closed for comments.

To provide feedback, please open a ticket here. Don't forget to include the article's URL along with the feedback you would like to provide.