Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependency ws to v7.5.10 [SECURITY] #1438

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Dec 21, 2021

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
ws 7.4.1 -> 7.5.10 age adoption passing confidence

GitHub Vulnerability Alerts

CVE-2021-32640

Impact

A specially crafted value of the Sec-Websocket-Protocol header can be used to significantly slow down a ws server.

Proof of concept

for (const length of [1000, 2000, 4000, 8000, 16000, 32000]) {
  const value = 'b' + ' '.repeat(length) + 'x';
  const start = process.hrtime.bigint();

  value.trim().split(/ *, */);

  const end = process.hrtime.bigint();

  console.log('length = %d, time = %f ns', length, end - start);
}

Patches

The vulnerability was fixed in [email protected] (websockets/ws@00c425e) and backported to [email protected] (websockets/ws@78c676d) and [email protected] (websockets/ws@76d47c1).

Workarounds

In vulnerable versions of ws, the issue can be mitigated by reducing the maximum allowed length of the request headers using the --max-http-header-size=size and/or the maxHeaderSize options.

Credits

The vulnerability was responsibly disclosed along with a fix in private by Robert McLaughlin from University of California, Santa Barbara.

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 [email protected] (websockets/ws@e55e510) and backported to [email protected] (websockets/ws@22c2876), [email protected] (websockets/ws@eeb76d3), and [email protected] (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)

v7.5.10

Compare Source

Bug fixes

v7.5.9

Compare Source

Bug fixes

v7.5.8

Compare Source

Bug fixes

v7.5.7

Compare Source

Bug fixes

v7.5.6

Compare Source

Bug fixes

v7.5.5

Compare Source

Bug fixes

v7.5.4

Compare Source

Bug fixes

v7.5.3

Compare Source

Bug fixes

  • The WebSocketServer constructor now throws an error if more than one of the
    noServer, server, and port options are specefied (66e58d2).
  • Fixed a bug where a 'close' event was emitted by a WebSocketServer before
    the internal HTTP/S server was actually closed (5a58730).
  • Fixed a bug that allowed WebSocket connections to be established after
    WebSocketServer.prototype.close() was called (772236a).

v7.5.2

Compare Source

Bug fixes

  • The opening handshake is now aborted if the client receives a
    Sec-WebSocket-Extensions header but no extension was requested or if the
    server indicates an extension not requested by the client (aca94c8).

v7.5.1

Compare Source

Bug fixes

  • Fixed an issue that prevented the connection from being closed properly if an
    error occurred simultaneously on both peers (b434b9f).

v7.5.0

Compare Source

Features

  • Some errors now have a code property describing the specific type of error
    that has occurred (#​1901).

Bug fixes

  • A close frame is now sent to the remote peer if an error (such as a data
    framing error) occurs (8806aa9).
  • The close code is now always 1006 if no close frame is received, even if the
    connection is closed due to an error (8806aa9).

v7.4.6

Compare Source

Bug fixes

  • Fixed a ReDoS vulnerability (00c425e).

A specially crafted value of the Sec-Websocket-Protocol header could be used
to significantly slow down a ws server.

for (const length of [1000, 2000, 4000, 8000, 16000, 32000]) {
  const value = 'b' + ' '.repeat(length) + 'x';
  const start = process.hrtime.bigint();

  value.trim().split(/ *, */);

  const end = process.hrtime.bigint();

  console.log('length = %d, time = %f ns', length, end - start);
}

The vulnerability was responsibly disclosed along with a fix in private by
Robert McLaughlin from University of California, Santa Barbara.

In vulnerable versions of ws, the issue can be mitigated by reducing the maximum
allowed length of the request headers using the --max-http-header-size=size
and/or the maxHeaderSize options.

v7.4.5

Compare Source

Bug fixes

  • UTF-8 validation is now done even if utf-8-validate is not installed
    (23ba6b2).
  • Fixed an edge case where websocket.close() and websocket.terminate() did
    not close the connection (67e25ff).

v7.4.4

Compare Source

Bug fixes
  • Fixed a bug that could cause the process to crash when using the
    permessage-deflate extension (9277437).

v7.4.3

Compare Source

Bug fixes
  • The deflate/inflate stream is now reset instead of reinitialized when context
    takeover is disabled (#​1840).

v7.4.2

Compare Source

Bug fixes
  • Silenced a deprecation warning (a2c0d44).

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 becomes conflicted, 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.

@renovate renovate bot added the dependencies Pull requests that update a dependency file label Dec 21, 2021
@codecov
Copy link

codecov bot commented Dec 21, 2021

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f2a9f49) 49.23% compared to head (01a3f08) 49.23%.

❗ Current head 01a3f08 differs from pull request most recent head 5c92cf7. Consider uploading reports for the commit 5c92cf7 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1438   +/-   ##
=======================================
  Coverage   49.23%   49.23%           
=======================================
  Files          68       68           
  Lines        1501     1501           
  Branches      159      159           
=======================================
  Hits          739      739           
  Misses        752      752           
  Partials       10       10           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch 3 times, most recently from 008dd8a to 108ffcb Compare December 26, 2021 15:38
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch 8 times, most recently from c66c280 to c461376 Compare January 5, 2022 03:16
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch from c461376 to 01a3f08 Compare February 7, 2022 22:01
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch from 01a3f08 to 4469a3c Compare June 18, 2022 20:36
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch from 4469a3c to 41681af Compare November 20, 2022 08:56
@renovate renovate bot changed the title Update dependency ws to v7.4.6 [SECURITY] Update dependency ws to v7.4.6 [SECURITY] - autoclosed Dec 19, 2023
@renovate renovate bot closed this Dec 19, 2023
@renovate renovate bot deleted the renovate/npm-ws-vulnerability branch December 19, 2023 11:02
@renovate renovate bot restored the renovate/npm-ws-vulnerability branch December 19, 2023 12:56
@renovate renovate bot changed the title Update dependency ws to v7.4.6 [SECURITY] - autoclosed Update dependency ws to v7.4.6 [SECURITY] Dec 19, 2023
@renovate renovate bot reopened this Dec 19, 2023
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch from 41681af to 5c92cf7 Compare December 19, 2023 12:56
@renovate renovate bot force-pushed the renovate/npm-ws-vulnerability branch from 5c92cf7 to 4c81314 Compare July 21, 2024 13:08
@renovate renovate bot changed the title Update dependency ws to v7.4.6 [SECURITY] Update dependency ws to v7.5.10 [SECURITY] Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants