websockets / ws

Simple to use, blazing fast and thoroughly tested WebSocket client and server for Node.js
MIT License
21.34k stars 2.3k forks source link

Fix crash when the Upgrade header cannot be read #2231

Closed lpinca closed 3 weeks ago

lpinca commented 3 weeks ago

It is possible that the Upgrade header is correctly received and handled (the 'upgrade' event is emitted) without its value being returned to the user. This can happen if the number of received headers exceed the server.maxHeadersCount or request.maxHeadersCount threshold. In this case incomingMessage.headers.upgrade may not be set.

Handle the case correctly and abort the handshake.

Fixes #2230