Multi-sandwich attack with MongoDB Object ID or the scenario for real-time monitoring of web application invitations: a new use case for the sandwich attack
The article describes a theoretical attack against invitation tokens that use the MongoDB Object ID format, where an attacker creates their own invitations to bound a time window and then guesses the token generated for a victim inside that window. By splitting the window into many short frames and checking candidate tokens in real time, the attacker could create the victim's account before the victim does.
In the previous article, we saw how to exploit a web application using time-based data as its secret. To do this, we necessarily needed to control the time variable.
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 invitation token is a MongoDB Object ID, which is predictable because it combines a timestamp, a process value and an incrementing counter rather than random data.
Impact
An attacker could create the victim's account before the victim does, but only if the application is single-instance and the counter evolves predictably, and the approach needs a very large number of requests.
What the attacker needed
Attacker can create invitations; victim invitation is triggered; single application instance; predictable counter evolution
The fix
Invitation tokens should be generated from a cryptographically random value rather than a predictable MongoDB Object ID.
How it was found
- Create a first invitation with the attacker account and note the token.
- Wait for an arbitrary amount of time.
- Create a second invitation with the attacker account and note the token.
- Generate all possible intermediate tokens between the two and check their validity.
- Repeat with short time frames to monitor invitations in real time.
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.
Some web applications send a secret code by email so a new person can join a company account. If that code is built from the current time plus a counter, an attacker who can make their own codes can work out the codes created in between. This article explores how many guesses that would take and whether it is practical.
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.