Skip to content
File upload Disclosed report Intermediate CVE-2018-3758

Unrestricted file upload (RCE)

The express-cart application allows an administrator to upload a file to any path on the server without validating the path or file type. An attacker with admin privileges could upload a malicious JavaScript file to overwrite the application's main file and gain remote code execution.

patrickrbc Follow

Originally disclosed on HackerOne

Critical 9.1 View original
  • Triaged in 14 days
  • Fixed in 36 days
  • Disclosed after 36 days

I would like to report an unrestricted file upload in express-cart.

It allows a user with administrative privileges to upload a file to any path.

Module

module name: express-cart version: 1.1.5 npm page: https://www.npmjs.com/package/express-cart

Module Description

expressCart is a fully functional shopping cart built in Node.js (Express, MongoDB) with Stripe, PayPal and Authorize.net payments.

Vulnerability

Vulnerability Description

A privileged user can use the upload functionality to gain access to the server.

The application offers the possibility of uploading product images. However, there are many problems with the way it handles these uploads.

Firstly, it uses a path provided by the user. This path is not validated, therefore, it would allow the user to upload the file to any path on the hosting server.

Secondly, it does not restrict the type of the file being uploaded, therefore, it would allow the user to upload a malicious file to gain access to the server.

Finally, it does not restrict the size of the file. This would allow to easily exhaust the host resources and consequently produce a DoS.

Steps To Reproduce:

There are many ways this vulnerability could be exploited. Supposing our goal would be to establish access to the host machine, we could replace the app.js file with a malicious JavaScript that would give us a web shell.

Once you have administrator privileges you can use a request similar to:

POST /admin/file/upload HTTP/1.1
Host: localhost:1111
Referer: http://localhost:1111/
Content-Type: multipart/form-data; boundary=---------------------------1099055603892737061752875043
Cookie: [ADMINISTRATOR_COOKIE]

-----------------------------1099055603892737061752875043
Content-Disposition: form-data; name="upload_file"; filename="app.js"
Content-Type: image/png

[MALICIOUS_JAVASCRIPT]
-----------------------------1099055603892737061752875043
Content-Disposition: form-data; name="productId"

5ae2228d995e3e5d7c96474d
-----------------------------1099055603892737061752875043
Content-Disposition: form-data; name="directory"

../../
-----------------------------1099055603892737061752875043
Content-Disposition: form-data; name="saveButton"

-----------------------------1099055603892737061752875043--

Wrap up

  • I contacted the maintainer to let them know: [N]
  • I opened an issue in the related repository: [N]

Impact

This vulnerability would allow a privileged user to gain access in the hosting machine.

The original report as published on HackerOne, by patrickrbc. 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 application does not validate the user-supplied upload path or restrict the file type, allowing an administrator to write arbitrary files anywhere on the server.

Impact

A privileged user could gain access to the hosting machine, potentially leading to remote code execution.

What the attacker needed

Administrator privileges

How it was found

  1. Obtain administrator privileges.
  2. Send a multipart form upload request to the file upload endpoint.
  3. Include a file with a malicious JavaScript payload and a filename such as app.js.
  4. Set the directory parameter to a path traversal sequence like ../../ to target the application root.
  5. The uploaded file could overwrite the application's main file, potentially giving a web shell.

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.

This report is about a shopping cart application that lets administrators upload product images. The application trusts the administrator to provide the upload location and file type, so an administrator could upload a harmful file to a sensitive location and take over the server.

What is File upload?

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.

More by patrickrbc

View all

1 more disclosed report, best first.

More from Node.js third-party modules

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Unrestricted file upload

The lesson behind this report.

An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.