anacronw/multer-s3

Disable Stack Traces When multler Recieves Unexpected/Invalid Content-Type

Closed this issue · 1 comments

I started using multler-s3 a few weeks ago and things were going well however today i ran into a minor issue by chance.
I was trying to security test my api for any weaknesses and thats when i found that if you send an incorrect or malformed file upload request, multler-s3 s3 spits out stack traces including directories etc.

I was wondering if it is possible to disable or overwrite this errors to a more custom json error

My Config ::

Express + Nodejs
"multer": "^1.4.5-lts.1",
"multer-s3": "^2.10.0",

api/upload.js code below;
https://gist.github.com/crypt0g30rgy/d619d789b4a1475c476fe5d8e4a3c986

Reproduction

user postman, select send formdata to api (http://localhost:3000/api/upload)
user postman, select send binary to api (http://localhost:3000/api/upload)

LinusU commented

The error handling is done by Express, you can read up on it here:

https://expressjs.com/en/guide/error-handling.html

I believe that just setting NODE_ENV=production would hide the stack traces. Good luck!