Skip to content
Account takeover Write-up Intermediate

$6,500 for Sending an Object Instead of a String: MongoDB Operator Injection to Account Takeover

The login endpoint passed the password field straight into a MongoDB query without checking it was a string, so a JSON object containing a query operator could be sent instead. This let an attacker log in as any account whose email address was known, without knowing the password.

T4nv1 Follow

Published on medium.com

Every injection-testing habit I’d built up over the years pointed in the wrong direction on this one, at least at first. I tried quotes, I tried comment sequences, I tried everything that normally rattles a SQL-backed login form, and the application shrugged off all of it cleanly.

T4nv1, on medium.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

The login endpoint passed the request body's password value into a MongoDB query without validating its type, so an object containing a query operator restructured the query instead of being compared as a literal password.

Impact

An attacker with a known or guessable email address could authenticate as that user in a single request, with no password knowledge and no brute-force or rate-limiting concern.

What the attacker needed

A known or guessable email address; no password knowledge needed; no account required

The fix

The login endpoint was given input type validation as an emergency fix, followed by a broader schema-validation rollout across other endpoints.

How it was found

  1. Send a normal login request with a wrong password and confirm it fails.
  2. Replace the password string with an object containing a not-equal operator and send it for a real account.
  3. Observe that authentication succeeds without the real password.
  4. Repeat against a second account with a different password to confirm it generalises.
  5. Send the same request for a username that does not exist and confirm it correctly fails.
  6. Register a fresh account, avoid recording its password, and confirm the same request authenticates as it.

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.

A login form normally sends a username and a password as text. Here the server accepted a structured object in place of the password text and handed it to the database, which treated it as a rule like 'password is not empty'. Because that rule is true for every real account, the password check was effectively switched off for any email the attacker knew.

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 T4nv1

View all

113 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.