Security foundations Randomness in security 2 min read

Why does security need randomness?

Two password reset links contain strings that look equally random. What should the server care about beyond how those strings look?

  1. Think about the next token

    A reset token grants temporary authority to change a password. The server needs a way to generate tokens that someone cannot feasibly guess, even after seeing other tokens. Appearance alone gives no evidence that the next value is unpredictable.

    The server uses a secure generator to create an unpredictable token for the reset link. ServerSecure generatorReset tokenReset link

    In short A token needs unpredictability, even if other tokens are visible.

  2. Use the platform’s secure generator

    When creating a reset token, use the platform’s cryptographically secure random generator and give the token enough random bits. The server checks the token before letting any password change go through.

    In short Use a secure random source for secrets that must resist guessing.

Where this example stops

A leaked token can still be used while it is valid. Bind it to one account, expire it quickly, and accept it only once.

Keep this

Use a secure random generator for reset tokens.

Treat each token as a temporary credential from generation through verification.

Sources

Last reviewed 21 November 2026.

Next byte · Security foundations What is threat modeling?