Skip to main content

What it flags

Math.random() feeds a token, code, nonce, session or secret.

How to review or fix

Use crypto.randomBytes, randomInt or randomUUID; names that only end in id are contextual. Math.floor(Math.random() * N) has a source fix.

Example from the editor

Use crypto.randomBytes for tokens, crypto.randomInt for numeric codes and crypto.randomUUID for identifiers.

Configuration

Set the rule to "off" in loadwise.config.json to drop its findings: