Skip to content
Fallow home
All docs pages

Docs home

Insecure randomness sink

What an insecure-randomness finding of fallow security means, why it matters and how to fix it.

What it reports

Catalogue security candidate for CWE-338.

Security explains how fallow finds it.

Why it matters

Math.random() and pseudoRandomBytes are predictable. A token, session ID or salt made with them can be guessed.

Example

const resetToken = Math.random().toString(36);

Fix

Review the candidate trace before acting. Confirm attacker control, missing sanitization, and reachable runtime context, then fix with the category-appropriate safer API or add a reviewed suppression.

Facts

FactValue
Issue typeinsecure-randomness
Rule id in SARIF outputsecurity/insecure-randomness
Commandfallow security
Default severityoff
Suppression comment// fallow-ignore-next-line security-sink
Fixable with fallow fixNo
Opt-inYes

Note. Tainted-sink catalogue category; the security-sink suppression token covers every category.