Skip to content
SQL injection Write-up Intermediate

One Weird Query String That Let Anyone Hijack Any Account in Rocket.Chat

Rocket.Chat failed to validate that the access_token parameter was a string, allowing MongoDB query operators to be injected. An unauthenticated attacker could retrieve a valid OAuth token and take over an account.

rrozif96 Follow

Published on medium.com

Imagine you’re running Rocket.Chat — an open-source team chat app like Slack.

nocxs, 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

Impact

An unauthenticated attacker could take over any account, provided at least one OAuth token exists in the database.

What the attacker needed

At least one OAuth token in the database; no authentication needed

The fix

Rocket.Chat patched it by validating that access_token is a string and rejecting MongoDB operators in auth-related parameters.

How it was found

  1. Send a request to the login endpoint with an access_token parameter containing a MongoDB operator.
  2. The server builds a database query that matches any token where access_token is not null.
  3. MongoDB returns the first matching token.
  4. Use the returned token to make authenticated API calls or log into the web interface.

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.

Rocket.Chat is a chat app that stores login tokens in a database called MongoDB. Normally the app looks up a token by its exact text, but it didn't check that the text was really just text. An attacker could send a special instruction instead of a token, and the database would hand back someone else's token, letting the attacker log in as that person.

What is SQL injection?

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.

More by rrozif96

View all

3 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.