Case 6C5CB4 · Cryptography · L2 Practitioner
Secure Randomness and CSPRNGs
- 01 What is it?
- 02 How is it abused?
- 03 How do you stop it?
What a strong answer covers
Try it out loud first. Then check yourself:
- Keys, nonces, session IDs and reset tokens need a CSPRNG: unpredictable even to someone who has seen earlier outputs.
- Math.random, java.util.Random and Python random are fast PRNGs; Mersenne Twister state is recoverable from 624 outputs.
- Abuse: predict password reset or session tokens, or guess keys generated with low entropy at boot or after VM snapshot cloning.
- Use OS-backed sources: getrandom()/urandom, Python secrets, crypto.getRandomValues, Java SecureRandom; never seed with time.
- Detect in review with SAST rules flagging weak RNGs in security contexts; size tokens at 128+ bits of entropy.
If the interviewer pushes back
- Why did shared prime factors show up across many RSA keys on embedded devices, and what does that say about entropy at boot?