{"id":"CVE-2021-32640","aliases":["CVE-2021-32640","GHSA-6fc8-4gx4-v693"],"related":[],"kind":"vulnerability","state":"published","title":"ReDoS in Sec-Websocket-Protocol header","summary":"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 ws@7.4.6 (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`](https://nodejs.org/api/cli.html#cli_max_http_header_size_size) and/or the [`maxHeaderSize`](https://nodejs.org/api/http.html#http_http_createserver_options_requestlistener) options.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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 ws@7.4.6 (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`](https://nodejs.org/api/cli.html#cli_max_http_header_size_size) and/or the [`maxHeaderSize`](https://nodejs.org/api/http.html#http_http_createserver_options_requestlistener) options.","source":"cvelist"},{"lang":"en","text":"### Impact\n\nA specially crafted value of the `Sec-Websocket-Protocol` header can be used to significantly slow down a ws server.\n\n### Proof of concept\n\n```js\nfor (const length of [1000, 2000, 4000, 8000, 16000, 32000]) {\n  const value = 'b' + ' '.repeat(length) + 'x';\n  const start = process.hrtime.bigint();\n\n  value.trim().split(/ *, */);\n\n  const end = process.hrtime.bigint();\n\n  console.log('length = %d, time = %f ns', length, end - start);\n}\n```\n\n### Patches\n\nThe vulnerability was fixed in ws@7.4.6 (https://github.com/websockets/ws/commit/00c425ec77993773d823f018f64a5c44e17023ff) and backported to ws@6.2.2 (https://github.com/websockets/ws/commit/78c676d2a1acefbc05292e9f7ea0a9457704bf1b) and ws@5.2.3 (https://github.com/websockets/ws/commit/76d47c1479002022a3e4357b3c9f0e23a68d4cd2).\n\n### Workarounds\n\nIn 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`](https://nodejs.org/api/cli.html#cli_max_http_header_size_size) and/or the [`maxHeaderSize`](https://nodejs.org/api/http.html#http_http_createserver_options_requestlistener) options.\n\n### Credits\n\nThe vulnerability was responsibly disclosed along with a fix in private by [Robert McLaughlin](https://github.com/robmcl4) from University of California, Santa Barbara.","format":"markdown","source":"ghsa"},{"lang":"es","text":"ws es una biblioteca de servidor y cliente WebSocket de código abierto para Node.js.&#xa0;Un valor especialmente diseñado del encabezado \"Sec-Websocket-Protocol\" puede ser usado para ralentizar significativamente un servidor ws.&#xa0;La vulnerabilidad ha sido corregida en la versión ws@7.4.6 (https://github.com/websockets/ws/commit/00c425ec77993773d823f018f64a5c44e17023ff).&#xa0;En las versiones vulnerables de ws, el problema puede ser mitigado al reducir la longitud máxima permitida de los encabezados de petición utilizando [`--max-http-header-size=size`](https://nodejs.org/api/cli.html#cli_max_http_header_size_size) y/o las opciones [`maxHeaderSize`](https://nodejs.org/api/http.html#http_http_createserver_options_requestlistener)","source":"nvd"}],"published":"2021-05-25T18:25:09.000Z","modified":"2026-07-08T06:28:00.103Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:N/AC:L/Au:N/C:N/I:N/A:P","score":5,"rating":"MEDIUM"}],"cwes":["CWE-345","CWE-400"],"affected":[{"ranges":[{"version":">= 5.0.0 <= 7.4.5","status":"affected"}],"vendor":"websockets","product":"ws","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"7.0.0","status":"affected","fixed":"7.4.6"}],"ecosystem":"npm","package":"ws","purl":"pkg:npm/ws","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"6.0.0","status":"affected","fixed":"6.2.2"}],"ecosystem":"npm","package":"ws","purl":"pkg:npm/ws","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"5.0.0","status":"affected","fixed":"5.2.3"}],"ecosystem":"npm","package":"ws","purl":"pkg:npm/ws","source":"ghsa"},{"ranges":[{"status":"affected","introduced":"5.0.0","fixed":"6.2.2"},{"status":"affected","introduced":"7.0.0","fixed":"7.4.6"}],"vendor":"ws_project","product":"ws","cpe":"cpe:2.3:a:ws_project:ws:*:*:*:*:*:node.js:*:*","source":"nvd"},{"ranges":[],"vendor":"netapp","product":"e-series_performance_analyzer","cpe":"cpe:2.3:a:netapp:e-series_performance_analyzer:-:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/websockets/ws/security/advisories/GHSA-6fc8-4gx4-v693","tags":["exploit","mitigation","patch","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/websockets/ws/commit/00c425ec77993773d823f018f64a5c44e17023ff","tags":["patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://lists.apache.org/thread.html/rdfa7b6253c4d6271e31566ecd5f30b7ce1b8fb2c89d52b8c4e0f4e30%40%3Ccommits.tinkerpop.apache.org%3E","tags":["mailing-list","x-refsource-mlist","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://security.netapp.com/advisory/ntap-20210706-0005/","tags":["third-party-advisory","x-refsource-confirm","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-32640","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/websockets/ws/issues/1895","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/websockets/ws","tags":["package"],"sources":["ghsa"]},{"url":"https://lists.apache.org/thread.html/rdfa7b6253c4d6271e31566ecd5f30b7ce1b8fb2c89d52b8c4e0f4e30@%3Ccommits.tinkerpop.apache.org%3E","tags":["web"],"sources":["ghsa"]},{"url":"https://security.netapp.com/advisory/ntap-20210706-0005","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-32640","url":"https://www.cve.org/CVERecord?id=CVE-2021-32640","licence":"CVE Terms of Use","modified":"2024-08-03T23:25:31.019Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-6fc8-4gx4-v693","url":"https://github.com/advisories/GHSA-6fc8-4gx4-v693","licence":"CC-BY-4.0","modified":"2026-07-08T06:28:00.103Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-32640","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-32640","licence":"Public domain","modified":"2026-06-17T03:53:19.733Z"}],"updatedAt":"2026-11-25T22:58:01.531Z","epss":{"score":0.029,"percentile":0.87703,"date":"2026-11-30T12:00:22.000Z"}}