Unsecure time-based secret and Sandwich Attack - Analysis of my research and release of the “Reset Tolkien” tool by Aethlios
Password reset and email confirmation tokens were generated from predictable time-based values (PHP uniqid and MongoDB ObjectIDs) rather than cryptographically secure randomness. An attacker who knows the victim's email address could reconstruct the victim's token from the request date and reset the password, leading to full account takeover.
In this article, I detail my research into time-based secrets. This research began for me a year ago, following a finding during a Bug bounty program, and enabled me to take the time to implement my Python tool: “Reset Tolkien”.
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 application generated security tokens from time-based, low-entropy functions (PHP uniqid and MongoDB ObjectID) instead of a cryptographically secure random source.
Impact
An attacker knowing only the victim's email address could reset the password and, on the affected perimeter, change the email to achieve full account takeover; the report was rated critical.
What the attacker needed
Victim's email address; ability to request a reset for the victim
The fix
Tokens should be generated with a cryptographically secure random function rather than time-based values.
How it was found
- Create an account on the target and request a password reset to a controlled email, noting the request date.
- Retrieve the token and detect its format to confirm it derives from the generation date.
- Request a password reset for the victim's account and note the request date.
- Apply the deduced format to the victim's request date to generate the victim's token.
- Use the generated token to reset the victim's password.
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 ask a site to reset your password, it sends a secret code (a token) to prove the request is yours. If that code is built from something predictable, like the current time, an attacker can work out what code the site will create for someone else and use it first. Here the codes were made from the clock, so knowing roughly when the victim asked for a reset was enough to guess their code.
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.