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:
-
sessionObjectIdis the object identifier of theSystem.Sessionrecord of the current session. -
counteris a sequential number that increments on each call. -
rndis a random number between zero and ten thousand, generated withMath.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:
- Use the generated identifier only as a temporary client-side key, a correlation identifier, or a de-duplication marker.
- Keep the identifier out of security contexts, such as authentication, authorization, session management, and access-token generation.
- 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
0 Comments