Skip to content
Account takeover Write-up Advanced

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.

Aethlios Follow

Published on aeth.cc

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.

Aethlios (@AethliosIK), on aeth.cc

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

  1. Create a first invitation with the attacker account and note the token.
  2. Wait for an arbitrary amount of time.
  3. Create a second invitation with the attacker account and note the token.
  4. Generate all possible intermediate tokens between the two and check their validity.
  5. 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.

More by Aethlios

View all

3 more disclosed reports, best first.

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.