Every CVE Search/ Get API key

CVE-2021-32640

ReDoS in Sec-Websocket-Protocol header

5.3 MediumFix available

ws is an open source WebSocket client and server library for Node.js. A specially crafted value of the Sec-Websocket-Protocol header can be used to significantly slow down a ws server. The vulnerability has been fixed in [email protected] (https://github.com/websockets/ws/commit/00c425ec77993773d823f018f64a5c44e17023ff). In vulnerable versions of ws, the issue can be mitigated by reducing the maximum allowed length of the request headers using the --max-http-header-size=size and/or the maxHeaderSize options.

Attack profile

How easy it is to exploit

Attack vector
Network
Complexity
Low
Privileges needed
None
User interaction
None

What an attacker can affect

Confidentiality
None
Integrity
None
Availability
Low

Exploit likelihood

2.82%Up 2.2 points since May 26, 2021
90%50%10%1%

What each source reports

CVE List Score used 5.3

ReDoS in Sec-Websocket-Protocol header

ws is an open source WebSocket client and server library for Node.js. A specially crafted value of the Sec-Websocket-Protocol header can be used to significantly slow down a ws server. The vulnerability has been fixed in [email protected] (https://github.com/websockets/ws/commit/00c425ec77993773d823f018f64a5c44e17023ff). In vulnerable versions of ws, the issue can be mitigated by reducing the maximum allowed length of the request headers using the --max-http-header-size=size and/or the maxHeaderSize options.

Record
CVE-2021-32640
CVSS 3.1
5.3 MediumCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Weakness
CWE-400
Updated
2026-11-02
EUVDEUVD-2021-0968 5.3

ws is an open source WebSocket client and server library for Node.js. A specially crafted value of the Sec-Websocket-Protocol header can be used to significantly slow down a ws server. The vulnerability has been fixed in [email protected] (https://github.com/websockets/ws/commit/00c425ec77993773d823f018f64a5c44e17023ff). In vulnerable versions of ws, the issue can be mitigated by reducing the maximum allowed length of the request headers using the --max-http-header-size=size and/or the maxHeaderSize options.

Record
EUVD-2021-0968
CVSS 3.1
5.3 MediumCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Updated
2026-11-03
GitHub AdvisoriesGHSA-6fc8-4gx4-v693 5.3

ReDoS in Sec-Websocket-Protocol header

Impact

A specially crafted value of the Sec-Websocket-Protocol header can be used to significantly slow down a ws server.

Proof of concept

for (const length of [1000, 2000, 4000, 8000, 16000, 32000]) {
  const value = 'b' + ' '.repeat(length) + 'x';
  const start = process.hrtime.bigint();

  value.trim().split(/ *, */);

  const end = process.hrtime.bigint();

  console.log('length = %d, time = %f ns', length, end - start);
}

Patches

The vulnerability was fixed in [email protected] (https://github.com/websockets/ws/commit/00c425ec77993773d823f018f64a5c44e17023ff) and backported to [email protected] (https://github.com/websockets/ws/commit/78c676d2a1acefbc05292e9f7ea0a9457704bf1b) and [email protected] (https://github.com/websockets/ws/commit/76d47c1479002022a3e4357b3c9f0e23a68d4cd2).

Workarounds

In vulnerable versions of ws, the issue can be mitigated by reducing the maximum allowed length of the request headers using the --max-http-header-size=size and/or the maxHeaderSize options.

Credits

The vulnerability was responsibly disclosed along with a fix in private by Robert McLaughlin from University of California, Santa Barbara.

Record
GHSA-6fc8-4gx4-v693
CVSS 3.1
5.3 MediumCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Weakness
CWE-345, CWE-400
Updated
2026-11-02
NVD 5.3

ws is an open source WebSocket client and server library for Node.js. A specially crafted value of the Sec-Websocket-Protocol header can be used to significantly slow down a ws server. The vulnerability has been fixed in [email protected] (https://github.com/websockets/ws/commit/00c425ec77993773d823f018f64a5c44e17023ff). In vulnerable versions of ws, the issue can be mitigated by reducing the maximum allowed length of the request headers using the --max-http-header-size=size and/or the maxHeaderSize options.

Record
CVE-2021-32640
CVSS 3.1
5.3 MediumCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
CVSS 2.0
5.0 MediumAV:N/AC:L/Au:N/C:N/I:N/A:P
Weakness
CWE-400
Updated
2026-11-02
OSVAZL-44670 5.3

CVE-2021-32640 affecting package js-jquery 3.5.0-4

ws is an open source WebSocket client and server library for Node.js. A specially crafted value of the Sec-Websocket-Protocol header can be used to significantly slow down a ws server. The vulnerability has been fixed in [email protected] (https://github.com/websockets/ws/commit/00c425ec77993773d823f018f64a5c44e17023ff). In vulnerable versions of ws, the issue can be mitigated by reducing the maximum allowed length of the request headers using the --max-http-header-size=size and/or the maxHeaderSize options.

Record
AZL-44670
CVSS 3.1
5.3 MediumCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Updated
2026-11-05
OSV 5.3

ws is an open source WebSocket client and server library for Node.js. A specially crafted value of the Sec-Websocket-Protocol header can be used to significantly slow down a ws server. The vulnerability has been fixed in [email protected] (https://github.com/websockets/ws/commit/00c425ec77993773d823f018f64a5c44e17023ff). In vulnerable versions of ws, the issue can be mitigated by reducing the maximum allowed length of the request headers using the --max-http-header-size=size and/or the maxHeaderSize options.

Record
CVE-2021-32640
CVSS 3.1
5.3 MediumCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Updated
2026-11-02
Show 10 moreShow less
OSVDEBIAN-CVE-2021-32640 5.3

ws is an open source WebSocket client and server library for Node.js. A specially crafted value of the Sec-Websocket-Protocol header can be used to significantly slow down a ws server. The vulnerability has been fixed in [email protected] (https://github.com/websockets/ws/commit/00c425ec77993773d823f018f64a5c44e17023ff). In vulnerable versions of ws, the issue can be mitigated by reducing the maximum allowed length of the request headers using the --max-http-header-size=size and/or the maxHeaderSize options.

Record
DEBIAN-CVE-2021-32640
CVSS 3.1
5.3 MediumCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Updated
2026-11-02
OSVGHSA-6fc8-4gx4-v693 5.3

ReDoS in Sec-Websocket-Protocol header

Impact

A specially crafted value of the Sec-Websocket-Protocol header can be used to significantly slow down a ws server.

Proof of concept

for (const length of [1000, 2000, 4000, 8000, 16000, 32000]) {
  const value = 'b' + ' '.repeat(length) + 'x';
  const start = process.hrtime.bigint();

  value.trim().split(/ *, */);

  const end = process.hrtime.bigint();

  console.log('length = %d, time = %f ns', length, end - start);
}

Patches

The vulnerability was fixed in [email protected] (https://github.com/websockets/ws/commit/00c425ec77993773d823f018f64a5c44e17023ff) and backported to [email protected] (https://github.com/websockets/ws/commit/78c676d2a1acefbc05292e9f7ea0a9457704bf1b) and [email protected] (https://github.com/websockets/ws/commit/76d47c1479002022a3e4357b3c9f0e23a68d4cd2).

Workarounds

In vulnerable versions of ws, the issue can be mitigated by reducing the maximum allowed length of the request headers using the --max-http-header-size=size and/or the maxHeaderSize options.

Credits

The vulnerability was responsibly disclosed along with a fix in private by Robert McLaughlin from University of California, Santa Barbara.

Record
GHSA-6fc8-4gx4-v693
CVSS 3.1
5.3 MediumCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Weakness
CWE-345, CWE-400
Updated
2026-11-02
OSVROOT-APP-NPM-CVE-2021-32640 5.3

CVE-2021-32640 in ws - Patched by Root

Root has patched CVE-2021-32640 in the ws package for Root:npm. Multiple fixed versions available.

Record
ROOT-APP-NPM-CVE-2021-32640
CVSS 3.1
5.3 MediumCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Updated
2026-11-02
OSVUBUNTU-CVE-2021-32640 5.3

ws is an open source WebSocket client and server library for Node.js. A specially crafted value of the Sec-Websocket-Protocol header can be used to significantly slow down a ws server. The vulnerability has been fixed in [email protected] (https://github.com/websockets/ws/commit/00c425ec77993773d823f018f64a5c44e17023ff). In vulnerable versions of ws, the issue can be mitigated by reducing the maximum allowed length of the request headers using the --max-http-header-size=size and/or the maxHeaderSize options.

Record
UBUNTU-CVE-2021-32640
CVSS 3.1
5.3 MediumCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
Updated
2026-11-02
OSVCLSA-2026-1785380875 No score

TuxCare security update for ws (1 CVE)

TuxCare rebuilt ws to address 1 CVE. Fixed in 6.2.1-tuxcare.2.

Record
CLSA-2026-1785380875
Updated
2026-11-02
OSVCLSA-2026-1788560420 No score

TuxCare security update for ws (3 CVEs)

TuxCare rebuilt ws to address 3 CVEs. Fixed in 7.4.5-tuxcare.1.

Record
CLSA-2026-1788560420
Updated
2026-11-02
OSVCLSA-2026-1788560439 No score

TuxCare security update for ws (3 CVEs)

TuxCare rebuilt ws to address 3 CVEs. Fixed in 6.0.0-tuxcare.1.

Record
CLSA-2026-1788560439
Updated
2026-11-02
OSVCLSA-2026-1792164186 No score

TuxCare security update for ws (3 CVEs)

TuxCare rebuilt ws to address 3 CVEs. Fixed in 7.4.3-tuxcare.1.

Record
CLSA-2026-1792164186
Updated
2026-11-02
OSVCLSA-2026-1792443025 No score

TuxCare security update for ws (3 CVEs)

TuxCare rebuilt ws to address 3 CVEs. Fixed in 7.4.0-tuxcare.1.

Record
CLSA-2026-1792443025
Updated
2026-11-02
OSVCLSA-2026-1793112519 No score

TuxCare security update for ws (3 CVEs)

TuxCare rebuilt ws to address 3 CVEs. Fixed in 6.1.4-tuxcare.1.

Record
CLSA-2026-1793112519
Updated
2026-11-02

Affected products

Affected packages

Affected packages
PackageAffectedFixed
ws
npm
7.0.0 up to 7.4.6
7.4.6
ws
npm
6.0.0 up to 6.2.2
6.2.2
ws
npm
5.0.0 up to 5.2.3
5.2.3
js-jquery
Azure Linux:3
through 3.5.0-4 None known
ws
TuxCare:npm
6.2.1-tuxcare.0 up to 6.2.1-tuxcare.2, plus listed versions
6.2.16.2.1-tuxcare.1
6.2.1-tuxcare.2
ws
TuxCare:npm
From an advisory covering 3 CVEs
7.4.5-tuxcare.0 up to 7.4.5-tuxcare.1, plus listed versions
7.4.5
7.4.5-tuxcare.1
ws
TuxCare:npm
From an advisory covering 3 CVEs
6.0.0-tuxcare.0 up to 6.0.0-tuxcare.1, plus listed versions
6.0.0
6.0.0-tuxcare.1
ws
TuxCare:npm
From an advisory covering 3 CVEs
7.4.3-tuxcare.0 up to 7.4.3-tuxcare.1, plus listed versions
7.4.3
7.4.3-tuxcare.1
ws
TuxCare:npm
From an advisory covering 3 CVEs
7.4.0-tuxcare.0 up to 7.4.0-tuxcare.1, plus listed versions
7.4.0
7.4.0-tuxcare.1
ws
TuxCare:npm
From an advisory covering 3 CVEs
6.1.4-tuxcare.0 up to 6.1.4-tuxcare.1, plus listed versions
6.1.4
6.1.4-tuxcare.1
Show 9 moreShow less
Affected packages
PackageAffectedFixed
node-ws
Debian:12
before 7.4.2+~cs18.0.8-2
7.4.2+~cs18.0.8-2
node-ws
Debian:13
before 7.4.2+~cs18.0.8-2
7.4.2+~cs18.0.8-2
node-ws
Debian:14
before 7.4.2+~cs18.0.8-2
7.4.2+~cs18.0.8-2
ws
Root:npm
before 6.2.2-aikido.2
6.2.2-aikido.27.4.6-aikido.26.2.2-aikido.15.2.3-aikido.1
@rootio/ws
Root:npm
before 7.4.6-root.io.1
7.4.6-root.io.16.2.2-root.io.27.4.6-root.io.26.2.2-root.io.15.2.3-root.io.1
node-ws
Ubuntu:16.04:LTS
All versions, plus listed versions
0.7.2+ds1.349b7460-11.0.1+ds1.e6ddaae4-1
None known
node-ws
Ubuntu:18.04:LTS
All versions, plus listed versions
1.1.0+ds1.e6ddaae4-3build11.1.0+ds1.e6ddaae4-3ubuntu1
None known
node-ws
Ubuntu:20.04:LTS
All versions, plus listed versions
1.1.0+ds1.e6ddaae4-57.2.1-27.2.1-3
None known
node-ws
Ubuntu:22.04:LTS
All versions, plus listed versions
7.4.2+~cs18.0.8-27.5.5+~cs13.0.13-18.5.0+~cs13.3.3-2
None known

History

History
RecordedChangedSources
affected
factsOSV
aliasesEUVD
first indexedCVE List, GitHub Advisories, NVD, OSV

Dates are when Every CVE recorded each change. Upstream dates may differ.

In short

CVE-2021-32640 is a medium vulnerability (CVSS 5.3) in Websockets Ws, published May 25, 2021. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 2.82%, the 86th percentile. Fixed in ws 7.4.6.

References

Show 6 moreShow less
MoveEnter Open