- Analyzer
- semgrep
- Category
- Cryptography
- Default severity
- MEDIUM
- CWE
- CWE-338
- Execution
- Passive
- Authentication
- Not required
- Applicability
- javascript, typescript
- Availability
- stable
What it detects
JavaScript/TypeScript: Security token generated with Math.random(): a cryptography check run by the semgrep analyzer.
Evidence
The Semgrep source location, rule identity, and bounded match context normalized into Fendix evidence.
Remediation
Math.random() output becomes a token (a reset link, session, API key or one- time code). Math.random is not cryptographically secure: its output can be predicted from a few observed values. Generate tokens with crypto.randomBytes, crypto.randomUUID or crypto.getRandomValues.
Limitations
This check is limited to the applicability and evidence delivered by semgrep. Review the evidence in context; a match is a finding input, while confidence and policy determine its disposition.
Related reference
Analyzer Registry · Findings and release decisions · Policy and confidence
Remediation guidance: Remediation and fix verification · Baselines and suppressions