Skip to content

GHSA-58qx-3vcg-4xpx CVE-2026-45736

ws: Uninitialized memory disclosure

High npm
Severity
4.4 / 10
High · CVSS 3.1
Exploit chance (EPSS)
0.74%
Chance of exploitation in the next 30 days. Higher than 54.80% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-908 Use of Uninitialized Resource
Fix
8.20.1
Upgrade ws to this version or later

Description

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 (https://github.com/websockets/ws/commit/c0327ec15a54d701eb6ccefaa8bef328cfc03086).

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

Affected versions

npm

PackageVulnerableFixed in
ws
>= 8.0.0, < 8.20.1
8.20.1
ws
>= 8.0.0, < 8.20.1
8.20.1

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

ws npm → 8.20.1

npm
npm install ws@8.20.1
yarn
yarn add ws@8.20.1
pnpm
pnpm add ws@8.20.1

Severity breakdown

CVSS 3.1 4.4

CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:H/I:N/A:N

Attack vector
Network
Attack complexity
High
Privileges required
High
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
None
Availability
None

Weakness

CWE-908: Use of Uninitialized Resource

The product uses or accesses a resource that has not been initialized.

How to prevent it
  • Implementation: Explicitly initialize the resource before use. If this is performed through an API function or standard procedure, follow all required steps.
  • Implementation: Pay close attention to complex conditionals that affect initialization, since some branches might not perform the initialization.
  • Implementation: Avoid race conditions (CWE-362) during initialization routines.
  • Build and Compilation: Run or compile the product with settings that generate warnings about uninitialized variables or data.

References

Advisories

Fixes and patches

Packages

Other links

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-96hv-2xvq-fx4p
ws: Memory exhaustion DoS from tiny fragments and data chunks
High Also affects ws
GHSA-3h5v-q93c-6h6q
ws affected by a DoS when handling a request with many HTTP headers
High Also affects ws
GHSA-6fc8-4gx4-v693
ReDoS in Sec-Websocket-Protocol header
Medium Also affects ws
GHSA-5v72-xg48-5rpm
Denial of Service in ws
High Also affects ws
GHSA-6663-c963-2gqg
DoS due to excessively large websocket message in ws
High Also affects ws
GHSA-2mhh-w6q8-5hxw
Remote Memory Disclosure in ws
Low Also affects ws
GHSA-654x-cwwv-5j9c
Pillow: Arrow export leaks stale heap memory when PILLOW_ALIGNMENT > 1
Medium Same weakness, CWE-908
GHSA-q45j-58j2-45rg
Pillow: TiffDecode returns uninitialized memory as pixels for short JPEG strips
Medium Same weakness, CWE-908

Credits: ChALkeR

Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor