Medium severityRubyCryptographyMEDIUM confidence
Insecure Random For Security
A security-sensitive value is generated with the non-cryptographic Kernel#rand/Random#rand PRNG, which is predictable (CWE-338).
Standards mapping
- OWASP Top 10
- A02:2021 - Cryptographic Failures
- OWASP ASVS
- V6.3.1 (L2)
Vulnerable vs. safe
Flagged by this check
reset_token = rand(1_000_000)Passes - the safe pattern
reset_token = SecureRandom.hex(32)Why it matters & how to fix it
A security-sensitive value is generated with the non-cryptographic Kernel#rand/Random#rand PRNG, which is predictable (CWE-338). Use SecureRandom (SecureRandom.hex / .uuid / .random_number) for tokens, nonces, salts, and other security values.
References
Rule ID integsec-ruby-insecure-random-for-security - 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