Skip to content
Info disclosure Disclosed report Intermediate CVE-2022-32219

REST API gets `query` as parameter and executes it

The users.list REST endpoint accepted a client-supplied query object and passed it directly to the database, letting any authenticated user with the view-d-room permission retrieve most fields of every user record, including admin accounts and email addresses. An attacker could then use that information to brute-force admin passwords.

paulocsanz Follow

Originally disclosed on HackerOne

Medium 6.5 View original
  • Triaged in 9 days
  • Fixed in 15 months
  • Disclosed after 18 months

Summary by the program

Summary: Any user with 'view-d-room' permission can access any (except users.services) data from the users collection

Description:

The "users.list" REST endpoint gets a query parameter from JSON and runs Users.find(queryFromClientSide). This means virtually any authenticated user can access any data (except password hashes) of any user authenticated. They can list admins and then brute-force their passwords with that information, for example. And all emails get leaked.

This report is only for one specific endpoint, but there are a lot of endpoint that have a query parameter, some attach fields to it making it "safer", but it's never a good idea to run queries that came from the users. This always will end-up as a security vulnerability. This is basically a SQL injection in a NOSQL database.

https://github.com/RocketChat/Rocket.Chat/blob/develop/app/api/server/v1/users.js#L232

Although contained to 'view-d-room', most accounts have this permission and even then, this permission does not allow for unfettered access to the entire users collection (except the password hash)

Releases Affected:

From 2.5 on.

Steps To Reproduce (from initial installation to vulnerability):

Signup to open.rocket.chat, get the X-Auth-Token and X-User-Id from storage. Fill the data in the query above, and access the list of most metadata of every admin user

curl --location -g --request GET 'xxx.rocket.chat/api/v1/users.list?query={"roles":"admin"}' \
--header 'X-Auth-Token:  xxx' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'X-User-Id: yyy'

Suggested mitigation

This endpoint needs to rethinking, why being so generic? It's a breaking change now, but it should never been this generic. So there isn't much hope besides breaking compatibility and making the endpoint simple, into one that does only one thing.

And other REST endpoints should be investigated too. We will do it, but it's such a critical problem that it seems the Rocket.Chat team can explore it more too.

Impact

Any authenticated account can access virtually any data from the users collection.

Fix

We have fix this vulnerability in 4.7.5>

The original report as published on HackerOne, by paulocsanz. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The endpoint passed a user-controlled query object straight into the database lookup instead of restricting which fields and values a client may filter on.

Impact

Any authenticated account could access virtually any data from the users collection, except password hashes, and could use the leaked details to brute-force admin passwords; the view-d-room permission was required but most accounts had it.

What the attacker needed

An authenticated account; the view-d-room permission

The fix

The vulnerability was fixed in version 4.7.5, and the reporter recommended making the endpoint do one specific thing rather than accepting a generic query.

How it was found

  1. Sign up for an account on the hosted Rocket.Chat instance.
  2. Read the authentication token and user identifier from browser storage.
  3. Send a request to the users.list endpoint with a query selecting admin accounts and the captured authentication headers.
  4. Receive the list of admin users and their metadata.

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 report has not been written yet. The Original tab links to the source.

A web API endpoint let the person making the request supply a database search filter, and the server ran it without checking. Because the filter could target any field, a normal logged-in user could pull back details about every account, including administrators. This is like a database injection flaw, but for a document database rather than a traditional SQL one.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More from Rocket.Chat

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.