coreybutler / coreybutler/node-windows
CPU overload due to wrapper launching new Node processes when an unhandled error occurs
- Dominant language
- JavaScript
- Stars
- 2.9k
- Forks
- 368
- PR merge metrics
- No merged PRs in 30d
Description
**Issue:**
When running port scans on nodejs apps running via node-windows, the server CPU and memory is being overloaded to 100% due to node-windows continuously launching new processes when receiving the error:
```
events.js:183
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at _errnoException (util.js:1022:11)
at TCP.onread (net.js:615:25)
```
The scanner client connects to server, sends TCP packet data, then disconnects. Each time the disconnect happens, the wrapper catches this error and launches a new process here:
https://github.com/coreybutler/node-windows/blob/27779d9caafe9854fa5767574ac288d98447c0ff/lib/wrapper.js#L205
**How To Reproduce:**
1. Locally, use node-windows to install a node application that runs a simple http server listening on a specific port
2. Install Nessus Expert trial version locally and run a scan that targets the application port
3. Observe in task manager that multiple processes are being created from the wrapper each time the scanner TCP client disconnects
**Expected Behavior:**
The wrapper to handle the `ECONNRESET` error gracefully and not launch more processes without killing the previous one
**Screenshots:**
1. Create the node server and run as node-windows service

2. Run the Nessus scans targeting the port and observe the daemon logs showing the TCP clients connecting, sending data, then disconnecting. Then new processes try to start up but are unable to due to the original process running on the same port.


3. In Event Viewer, observe the `read ECONNRESET` error being logged from `wrapper.js`

4. Observe Node processes continuously being launched over and over

Contributor guide
Assessment
This issue has not been assessed yet.