High severityJavaScript / TypeScriptCryptographyMEDIUM confidence
Insecure Randomness For Secrets
Math.random() is not cryptographically secure and is being used to build a security-sensitive value (token/secret/OTP/etc.).
Standards mapping
Vulnerable vs. safe
Flagged by this check
const sessionToken = Math.random().toString(36).slice(2);Passes - the safe pattern
const discountAmount = Math.random() * 100;Why it matters & how to fix it
Math.random() is not cryptographically secure and is being used to build a security-sensitive value (token/secret/OTP/etc.). Use crypto.randomBytes()/crypto.randomUUID() for unpredictable values.
References
Rule ID integsec-js-insecure-randomness-for-secrets - engine: Opengrep - license: MIT - Copyright (c) IntegSec Inc.
TurboPentest runs this check automatically
Connect a GitHub repo and this check runs on every white-box pentest - AI-validated and reported with proof, from $99 per target.
Start a pentest