Skip to content
Crypto Write-up Intermediate

When Time Becomes a Vulnerability: Breaking Chronohack’s Token

The token generator used Python's random module seeded with the current time in milliseconds, making tokens predictable. An attacker could guess the seed within a small time window and generate the correct token to retrieve the flag.

Gregory Kovalchuk Follow

Published on medium.com

Security bugs are often not about complex cryptography, but about wrong assumptions. One of the most common — and dangerous — assumptions is that the current time is random enough for secrets.

Gregory Kovalchuk, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The token was generated using a non-cryptographic random number generator seeded with a predictable value (current time in milliseconds).

Impact

An attacker could predict the token and retrieve the flag, demonstrating that time-based seeding of a non-cryptographic PRNG is insecure.

What the attacker needed

Access to the challenge service; knowledge of token generation code; ability to make multiple connections

The fix

Use a cryptographically secure random source such as Python's secrets module instead of seeding random with time.

How it was found

  1. Open a connection and note the local time in milliseconds
  2. Account for network latency by trying a range of nearby seed values
  3. For each seed and each guess index (0–49), generate a candidate token
  4. Submit these tokens until one matches

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

The server created a secret code using a random number generator that was started with the current time. Because the time is predictable, an attacker could try a few nearby times to recreate the same code and guess it correctly.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.