Skip to content
Crypto Write-up Intermediate

Yet Another Random Story: VBScript's Randomize Internals

The VBScript token generator used a weak PRNG seeded by the system clock, which has limited resolution and precision, leading to a small set of possible tokens. An attacker who knows the approximate time of day could predict the token and recover the secret.

blog.doyensec.com

Published on blog.doyensec.com

In one of our recent posts, Dennis shared an interesting case study of C# exploitation that rode on Random-based password-reset tokens. He demonstrated how to use the single-packet attack, or a bit of old-school math, to beat the game.

Adrian Denkiewicz, on blog.doyensec.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

Likely the token generator used VBScript's Randomize and Rnd, which are seeded by the system clock with low resolution and precision, resulting in a small set of predictable seeds.

Impact

An attacker who knows the approximate time of day when a token was generated could predict the token and recover the secret.

What the attacker needed

Approximate time of token generation

How it was found

  1. Obtain the token generation code and identify the use of Randomize and Rnd.
  2. Note that Randomize without an argument seeds the PRNG using the system clock via GetLocalTime.
  3. Observe that the clock has limited resolution (about 15.625 ms) and precision (Single type), reducing the number of unique seeds.
  4. Generate many tokens locally and count unique values to confirm duplicates.
  5. Use the approximate time of token generation to brute-force the seed and predict the token.

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.

This report is about a secret token generated using a random number generator that is not truly random. The generator was seeded with the current time, which changes slowly and has limited precision, so the number of possible tokens is small. An attacker who knows roughly when the token was created can try likely seeds and guess the token.

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.