Medium severityGoCryptographyMEDIUM confidence
Insecure Random Token
math/rand is a deterministic, non-cryptographic PRNG and must not be used to generate tokens, keys, salts, or other secret/unpredictable values (CWE-330/CWE-338).
Standards mapping
Vulnerable vs. safe
Flagged by this check
sessionToken := rand.Intn(1000000)Passes - the safe pattern
retries := rand.Intn(3)Why it matters & how to fix it
math/rand is a deterministic, non-cryptographic PRNG and must not be used to generate tokens, keys, salts, or other secret/unpredictable values (CWE-330/CWE-338). An attacker who observes or reconstructs the seed can predict all outputs. Use crypto/rand (rand.Read / crypto/rand.Int) for any security-sensitive randomness.
References
Rule ID integsec-go-insecure-random-token - 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 pentestRelated checks
- JavaScript / TypeScript - CryptographyInsecure Randomness For Secrets
- JavaScript / TypeScript - CryptographyWeak Cipher Algorithm
- JavaScript / TypeScript - CryptographyWeak Hash Algorithm
- Python - CryptographyInsecure Random Token
- Python - CryptographyWeak Cipher DES ECB
- Python - CryptographyWeak Hash MD5 SHA1