Skip to content

Access control

Security token made with Math.random()access.insecure-random-token

Math.random() is predictable: its output can be reconstructed from a few earlier values. A login code, password-reset token, API key or session id made with it can be guessed, which lets an attacker take over accounts.

  • In force Rule access.insecure-random-token
  • 3 clauses

At a glance

access.insecure-random-token
Severityhigh
CertaintyNeeds review — a heuristic; confirm before changing code
Looks atyour source code
When it runsRuns on every scan

How to fix it

Use the cryptographic generator: `crypto.randomBytes(32).toString("hex")` or `crypto.randomUUID()` in Node, `crypto.getRandomValues()` in the browser, and `crypto.randomInt(100000, 1000000)` for numeric codes.

Check your own app

Run npx scanlyfix scan in your project. Every finding gets an id; after fixing, npx scanlyfix verify <id> proves it is gone.

If it is a false positive in your project, silence that one line with // scanlyfix-ignore-next-line access.insecure-random-token -- <why>.

All rules

Your code stays
on your machine

Only findings are uploaded, and only to your own dashboard.