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.
Imagine you’re running Rocket.Chat — an open-source team chat app like Slack.
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
- Send a request to the login endpoint with an access_token parameter containing a MongoDB operator.
- The server builds a database query that matches any token where access_token is not null.
- MongoDB returns the first matching token.
- 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.