Skip to content
Account takeover Write-up Advanced

Compromission de comptes via attaque sandwich sur System.Random

The application generated eight-character temporary passwords for password reset using C#'s non-cryptographic System.Random, seeded from Environment.TickCount under .NET Framework 4.8.1. By requesting resets for their own account around a victim's reset, an attacker could brute-force the two known seeds, narrow the victim's seed to a small range, and generate roughly 3,000 candidate passwords to try against the victim's account without reading their email.

Amin TRAORE Follow

Published on vaadata.com

Lors d’un test d’intrusion sur une application web, nous avons identifié une vulnérabilité permettant de prendre le contrôle de n’importe quel compte utilisateur en exploitant le mécanisme de réinitialisation de mot de passe. L’attaque reposait sur une technique dite sandwich attack (attaque sandwich) et sur…

Amin TRAORE, on vaadata.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 temporary password was produced with the non-cryptographic System.Random class, whose default seed derives from the predictable Environment.TickCount value, making the output reproducible from a narrow time window.

Impact

An attacker could predict a victim's temporary password and take over their account, though the text notes that rate limiting, account lockout and detection of repeated attempts can reduce the attack's effectiveness.

What the attacker needed

Ability to trigger resets on own account; ability to trigger reset on victim account; victim has not yet used the temp password; no strict rate limiting or lockout

The fix

Sensitive values such as temporary passwords and reset tokens should be generated with a cryptographically secure generator, for example System.Security.Cryptography.RandomNumberGenerator in .NET.

How it was found

  1. Request a password reset on your own account and note the temporary password received.
  2. Request a password reset on the victim's account so a temporary password is generated and emailed to them.
  3. Request a second password reset on your own account and note the second temporary password.
  4. Brute-force locally the seeds that reproduce the first and second known passwords.
  5. Enumerate the seeds between the two bounds and generate the candidate passwords for each.
  6. Try the resulting candidate list against the victim's account.

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.

When you forget a password, many sites email you a temporary one. This site made that temporary password with a random-number generator that is fine for games but not for secrets, because its starting point (the seed) comes from the computer's uptime clock. If an attacker can see two of their own temporary passwords created just before and just after the victim's, they can work out the small range of seeds in between and guess the victim's password.

What is Account takeover?

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.