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

NoSQL-Injection discloses S3 File Upload URLs

The getS3FileUrl Meteor method did not validate the fileId argument, allowing a regular expression to be passed instead of a string. An authenticated attacker could use this to retrieve the secret S3 URL for any uploaded file, bypassing access checks and disclosing file contents.

gronke Follow

Originally disclosed on HackerOne

Medium 6.5 View original
  • Triaged in 4 days
  • Fixed in 6 months
  • Disclosed after 8 months

Summary by the program

Summary

A NoSQL-Injection vulnerability in the getS3FileUrl Meteor server method can disclose arbitrary file upload URLs to users that should not be able to access.

Description

The fileId argument of the getS3FileUrl Meteor server method is not validated and can contain a regular expression.

The File Upload lookup result in app/file-upload/server/methods/getS3FileUrl.js#L18 is returned to the requesting user, regardless of the users ability to access the file.

JavaScript
Meteor.methods({
	async getS3FileUrl(fileId) {
		if (protectedFiles && !Meteor.userId()) {
			throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'sendFileMessage' });
		}
		const file = await Uploads.findOneById(fileId);

		return UploadFS.getStore('AmazonS3:Uploads').getRedirectURL(file);
	},
});

The S3 storage URL is secret because no further access checks occur so that disclosure of the URL also discloses the file contents.

Releases Affected:

  • 3.18.3
  • 4.3.0
  • develop
  • 0.53.0

Steps To Reproduce (from initial installation to vulnerability):

  1. Login to Rocket.Chat instance with S3 storage enabled
  2. Run PoC to access the first file matching the Regular Expression pattern

Supporting Material/References:

Proof of Concept

JavaScript
const pattern = ".*";
Meteor.call(
  "getS3FileUrl",
  { $regex: $pattern },
  (err, url) => { window.location.href=url }
);

Suggested mitigation

  • Check access to a files room
  • Require fileId to be a string

Impact

Authenticated users can enumerate and access arbitrary file uploads they should not have access to.

Fix

Fixed in versions 4.7.5, 4.8.2 and 5.0>

The original report as published on HackerOne, by gronke. 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

Impact

Authenticated users could enumerate and access arbitrary file uploads they should not have access to, because the disclosed S3 URL grants direct access to the file contents.

What the attacker needed

Authenticated user; S3 storage enabled

The fix

The issue was fixed in versions 4.7.5, 4.8.2 and 5.0; the suggested mitigations were to check room access and require fileId to be a string.

How it was found

  1. Log in to a Rocket.Chat instance that has S3 storage enabled.
  2. Call the getS3FileUrl method with a regular expression as the fileId to retrieve the URL of the first matching file.

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 server method that returns a file's secret web address accepted a search pattern instead of a single file identifier. Because it did not check whether the user was allowed to see that file, an attacker could ask for any file and get a link that works without further login checks.

What is Info disclosure?

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

More by gronke

View all

27 more disclosed reports, best first.

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.