Case 6C5CB4 · Cryptography · L2 Practitioner

Secure Randomness and CSPRNGs

Practise as: Explain itLevel: L2 Practitioner
  1. 01 What is it?
  2. 02 How is it abused?
  3. 03 How do you stop it?
What a strong answer covers

Try it out loud first. Then check yourself:

  1. Keys, nonces, session IDs and reset tokens need a CSPRNG: unpredictable even to someone who has seen earlier outputs.
  2. Math.random, java.util.Random and Python random are fast PRNGs; Mersenne Twister state is recoverable from 624 outputs.
  3. Abuse: predict password reset or session tokens, or guess keys generated with low entropy at boot or after VM snapshot cloning.
  4. Use OS-backed sources: getrandom()/urandom, Python secrets, crypto.getRandomValues, Java SecureRandom; never seed with time.
  5. 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?

More Cryptography cards

All Cryptography cards →

cardosec draws a security topic and gives you a clock: explain it out loud with no notes, then see what you covered and what you missed. Free during early access.

Reviewed 2026-10-09