bug: unhandled error from a malformed request can crash the server - Unexpected end of form #12415
Closed
3 of 15 tasks
Labels
needs triage
This issue has not been looked into
Is there an existing issue for this?
Current behavior
During pen-testing we came across what appears to be a major vulnerability that allows a malicious actor to crash a nestjs/express server using a malformed request. This is not a new issue, there are several issue referencing it, but most have been closed as it was not easy to reproduce the issue. I have made a minimal reproduction below that with two scripts that show how easy it is to reliably crash the server, one using
netcat
and the other sending a request usingnode http
.I believe that the following issues are related:
#9489
#10264
expressjs/multer#1176
Minimum reproduction code
https://github.com/eamon0989/minimal-crash-reproduction-nestjs
Steps to reproduce
yarn
to install dependencies.yarn run start
to start the server.cat crash-file-request.raw | nc localhost 3000
ornode malformed-request.mjs
from the terminal which will cause the app to crash.Expected behavior
I would expect the app to handle the bad request and return a
400
response.Package
@nestjs/common
@nestjs/core
@nestjs/microservices
@nestjs/platform-express
@nestjs/platform-fastify
@nestjs/platform-socket.io
@nestjs/platform-ws
@nestjs/testing
@nestjs/websockets
Other package
busbuy/multer
NestJS version
10.2.5
Packages versions
[System Information]
OS Version : macOS Unknown
NodeJS Version : v18.17.1
YARN Version : 1.22.19
[Nest CLI]
Nest CLI Version : 10.1.17
[Nest Platform Information]
platform-express version : 10.2.5
schematics version : 10.0.2
testing version : 10.2.5
common version : 10.2.5
core version : 10.2.5
cli version : 10.1.17
Node.js version
18.17.1
In which operating systems have you tested?
Other
Here is the exact error:
Screen.Recording.2023-09-21.at.10.12.37.mov
In case this issue gets closed, we are using a temporary workaround from expressjs/multer#1177 where we modify line 44 in
node_modules/multer/lib/make-middleware.js
frombusboy.removeAllListeners()
to:using https://github.com/ds300/patch-package
The text was updated successfully, but these errors were encountered: