79% vs 51%: independent neobanks lag on app security. Read the report

Deep Dive

Deep Dive

websocket-driver DoS and Duplicate Messages (CVE-2026-140004)

A short crafted frame on a draft75 or draft76 WebSocket makes websocket-driver duplicate a message or crash the server; fixed in 0.8.0.

TL;DR

  • A short byte sequence on a legacy draft75 or draft76 WebSocket makes the websocket-driver parser emit a message twice or crash the process. The maintainer disclosed the flaw on 2026-11-17.
  • Servers that use websocket-driver to handle WebSocket connections and accept draft75 or draft76 handshakes are exposed. Before the fix those drafts are accepted by default.
  • GitHub rates it Critical, CVSS v3.1 9.1. No exploitation in the wild is known, and it is not in CISA KEV as of 2026-12-01.
  • Upgrade to 0.8.0 on npm, or 0.9.0 on the Ruby gem. The fix closes the parser bug and disables draft support by default; see "How do I fix it?".

Am I affected?

You are exposed when a server uses websocket-driver to handle WebSocket connections and accepts a draft75 or draft76 handshake. All of these conditions must hold:

  • The server uses the npm websocket-driver package before 0.8.0, or the Ruby websocket-driver gem before 0.9.0.
  • The server passes an accepted socket to the driver, as a raw TCP upgrade or through a framework that does the same.
  • The server accepts a draft75 or draft76 handshake. Before the fix the driver accepts them by default; after the fix they are disabled unless the server sets allowDrafts: true.
  • The attacker can open a TCP connection to the server. No account and no WebSocket version negotiation with the RFC 6455 protocol are needed.

websocket-driver is widely used. npm counted 39,177,273 downloads of the websocket-driver package in the week of 2026-11-23 to 2026-11-29 (npm). It is the protocol handler behind several WebSocket servers and clients, so a vulnerable copy can sit under a framework rather than in the application's own dependencies.

Branch Affected versions Fixed version
websocket-driver, npm 0.7.x and earlier 0.8.0
websocket-driver, Ruby gem 0.8.x and earlier 0.9.0

Check the version in the project and in the lockfile:

npm ls websocket-driver
grep -A2 '"node_modules/websocket-driver"' package-lock.json

For the Ruby gem, list the resolved version:

bundle list | grep websocket-driver
gem list websocket-driver

Then check whether the server enables legacy drafts. After the fix, a server that needs them sets allowDrafts: true; a server that never sets it uses the safe default.

How do I fix it?

Upgrade the npm package to 0.8.0 or later, and the Ruby gem to 0.9.0 or later. The patch fixes the parser and changes the default so draft support is off.

  1. Upgrade the npm package:
npm install websocket-driver@0.8.0
  1. Upgrade the Ruby gem:
bundle update websocket-driver
  1. If a framework pins the package, force the fixed version with an override, then reinstall:
npm pkg set overrides.websocket-driver=0.8.0
rm -rf node_modules package-lock.json
npm install

After the upgrade, confirm that drafts are off unless the application asks for them. A server that still needs draft75 or draft76 passes allowDrafts: true in npm or allow_drafts: true in Ruby; the advisory says the fixed parser handles the crafted sequence correctly in that mode.

If you cannot upgrade, block legacy draft handshakes at the proxy. A draft75 or draft76 request does not carry the Sec-WebSocket-Version: 13 header that RFC 6455 requires. Rejecting a WebSocket upgrade without that header removes the parser path from the network.

The advisory calls the upgrade the only known mitigation. The proxy rule is a stopgap, because it depends on every path to the server passing through the proxy.

What is the root cause?

The draft75 and draft76 parser used one state for two jobs: skipping a stored message length and collecting the message body. A 0xFF byte inside a length-prefixed frame was therefore treated as the message terminator.

websocket-driver supports the early WebSocket drafts, which predate the standard. A draft75 text frame starts with a 0x00 byte and ends with 0xFF. A length-prefixed frame uses the high bit of the first byte and stores the payload length. The parser keeps a _stage value and advances it as bytes arrive.

This is lib/websocket/driver/draft75.js before the fix:

else if ((octet & 0x80) !== 0x80) {
  if (this._length === 0) {
    this._stage = 0;
  }
  else {
    this._skipped = 0;
    this._stage   = 2;
  }
}
...
case 2:
  if (octet === 0xFF) {
    this._stage = 0;
    message = Buffer.from(this._buffer).toString('utf8', 0, this._buffer.length);
    this.emit('message', new Base.MessageEvent(message));
  }
  else {
    if (this._length) {
      this._skipped += 1;
      if (this._skipped === this._length)
        this._stage = 0;
    } else {
      this._buffer.push(octet);
      if (this._buffer.length > this._maxLength) return this.close();
    }
  }
  break;

When a length-prefixed frame sets _length, stage 2 is supposed to skip exactly that many bytes. The code checks octet === 0xFF before it checks the skip counter. A 0xFF in the skipped bytes is read as the end of a message, so the parser emits the buffered message early and resets the stage. The bytes that follow are parsed again as new frames.

The same stage handles unterminated text frames, where _length is not set. In that path the branch pushes each byte into _buffer. The two meanings of stage 2 are the defect: one path skips bytes and the other collects them, and a 0xFF is ambiguous between them.

How is it exploited?

An unauthenticated client sends a draft75 handshake and a short frame sequence. The parser emits one message twice, or crashes on a frame that is only three bytes.

  1. The client opens a TCP connection and sends HTTP upgrade headers that match the draft75 handshake.
  2. The driver accepts the connection and starts the draft75 parser.
  3. The client sends a length-prefixed frame whose payload contains 0xFF, then a second short frame. The parser treats the 0xFF as a terminator and emits the first message early, so the same message is emitted twice.
  4. If the client omits the first frame and sends only 80 01 ff, the parser reaches an invalid state and the server crashes.

The advisory's proof of concept sends the handshake headers and two frames:

tcp.write(Buffer.from([0x00, 0x48, 0x69, 0xff]))
tcp.write(Buffer.from([0x80, 0x01, 0xff]))

The first frame carries Hi. The second is the three bytes that trigger the duplicate. The advisory states that a client sending only 80 01 ff crashes the server.

The proof of concept is public in the advisory. No exploitation in the wild has been reported, and the issue is not in CISA KEV as of 2026-12-01.

The advisory credits eliteaja11-dev for the report.

How does the attack flow?

A client sends a draft75 handshake and a short crafted frame, the parser mistakes a data byte for a message terminator, and the server duplicates a message or crashes.

flowchart LR A["Unauthenticated client opens a TCP connection"] --> B["Draft75 handshake is accepted"] B --> C["Length-prefixed frame carries 0xFF"] C --> D["Parser checks 0xFF before the skip counter"] D --> E["Message emitted early"] C --> F["Short frame leaves an invalid state"] E --> G["Duplicate message reaches the application"] F --> H["Server process crashes"]

What can an attacker do?

An unauthenticated attacker can crash a vulnerable WebSocket server with a single short frame, or make the server deliver a message to the application twice. Both outcomes are denial of service or integrity problems, not code execution.

The crash is the stronger impact. One TCP connection and three bytes are enough, so an attacker can repeat it and keep the service down. The advisory calls the input very short and says the attacker can easily crash a remote server.

The duplicate message is an integrity problem. An application that treats a WebSocket message as an order, a command or a state change may process it twice. The advisory describes the duplicate as message corruption, and the CVSS vector rates integrity High and availability High.

Confidentiality is not impacted in the CVSS vector. The advisory demonstrates no file read and no code execution. The impact needs the server to accept a draft75 or draft76 connection, which is the default before the fix.

Why does the fix work?

The fix gives the length-prefix skip its own stage, so a 0xFF in the skipped bytes is counted as data and not as a message terminator. It also disables draft support by default.

This is the diff in lib/websocket/driver/draft75.js:

-          else if ((octet & 0x80) !== 0x80) {
+
+          if ((octet & 0x80) !== 0x80) {
             if (this._length === 0) {
               this._stage = 0;
-            }
-            else {
+            } else {
               this._skipped = 0;
               this._stage   = 2;
             }
@@
         case 2:
+          this._skipped += 1;
+          if (this._skipped === this._length) {
+            delete this._length;
+            delete this._skipped;
+            this._stage = 0;
+          }
+          break;
+
+        case 3:
           if (octet === 0xFF) {
             this._stage = 0;
             message = Buffer.from(this._buffer).toString('utf8', 0, this._buffer.length);
             this.emit('message', new Base.MessageEvent(message));
-          }
-          else {
-            if (this._length) {
-              this._skipped += 1;
-              if (this._skipped === this._length)
-                this._stage = 0;
-            } else {
-              this._buffer.push(octet);
-              if (this._buffer.length > this._maxLength) return this.close();
-            }
+          } else {
+            this._buffer.push(octet);
+            if (this._buffer.length > this._maxLength) return this.close();
           }
           break;

Stage 2 now only counts the skipped bytes. It runs for every byte, including 0xFF, and moves to stage 0 when the count reaches _length. Stage 3 collects the payload and stops at a real 0xFF. The parser no longer has to decide which meaning a byte has inside the same stage.

The fix also changes the start of a length-prefixed message from this._stage = 2 to this._stage = 3, so the payload path begins after the length bytes. The advisory adds that draft support is disabled by default and requires allowDrafts: true. The default change removes the parser from most servers even before they upgrade every dependency.

The patch is complete for the two legacy draft parsers it touches. It does not change the RFC 6455 parser, which does not use these stages.

How do I check if I was compromised?

Look for WebSocket upgrade requests that use a draft75 or draft76 handshake, and for a server process that restarted after a short connection. No vendor indicator set has been published.

Draft75 and draft76 requests omit the Sec-WebSocket-Version: 13 header. Search the web server or proxy access log for upgrades without it:

grep -Ei 'upgrade: *websocket' /var/log/nginx/access.log | grep -vi 'sec-websocket-version: *13'

A hit is a lead, because old clients and scanners also send draft handshakes. Correlate it with a process restart or an error at the same time.

Check the application log for a WebSocket error or an uncaught exception around a short connection. The advisory says the three-byte frame crashes the process, so a crash in the WebSocket handler is the indicator.

Look for duplicate application events that share one client message. Because the parser emits the same message twice, an application that records message ids or idempotency keys can find two records for one send.

No file hashes, IP addresses or domains have been published. A failed attempt on a patched server leaves a rejected upgrade, and an attempt on an unpatched server may leave only a crash.

Timeline

  • 2026-11-15: The maintainer commits the parser fix.
  • 2026-11-17: The maintainer publishes advisory GHSA-v36f-rjg3-3v46.
  • 2026-11-30: NVD publishes CVE-2026-140004 and CVE-2026-140016.

From the fix commit to the advisory and the NVD records
Figure 1: The fix commit on 2026-11-15, the advisory on 2026-11-17, and the NVD records on 2026-11-30. Source: websocket-driver commit f9f657c, GHSA-v36f-rjg3-3v46 and NVD, checked December 1, 2026

FAQ

Does this affect the RFC 6455 WebSocket protocol?

No. The bug is in the draft75 and draft76 parsers. Standard RFC 6455 connections use a different parser and are not affected.

Do I need to expose a WebSocket endpoint to be affected?

Yes. The attacker needs a TCP connection that the driver accepts as a draft75 or draft76 handshake. A server that never accepts WebSocket connections is not exposed.

Is the Ruby gem affected too?

Yes. The same parser fix ships in the Ruby gem as CVE-2026-140016, fixed in 0.9.0. The advisory for the Ruby package also disables draft support by default.

Is there a public proof of concept?

Yes. The advisory includes the handshake and the frame bytes that duplicate a message, and states that a shorter sequence crashes the server. No exploitation in the wild has been reported.

Does upgrading break legacy clients?

Only clients that use draft75 or draft76. After the upgrade those connections are rejected unless the server sets allowDrafts: true. Standard clients negotiate RFC 6455 and are unaffected.

Is a crash the only impact?

No. The parser can emit the same message twice, so an application that acts on WebSocket messages may process one event two times. The advisory describes both the duplicate and the crash.

Find vulnerable WebSocket dependencies with Ostorlab

Ostorlab's software composition analysis inventories the open-source packages in your repositories and flags the versions an advisory marks as affected. Use it to find every copy of websocket-driver below the fixed release, including the ones a framework pulls in.

References

  • websocket-driver, advisory GHSA-v36f-rjg3-3v46, "Message corruption and denial of service triggered by crafted client message", published 2026-11-17 (checked December 1, 2026): https://github.com/faye/websocket-driver-node/security/advisories/GHSA-v36f-rjg3-3v46
  • NVD, CVE-2026-140004 record (checked December 1, 2026): https://nvd.nist.gov/vuln/detail/CVE-2026-140004
  • NVD, CVE-2026-140016 record for the Ruby gem (checked December 1, 2026): https://nvd.nist.gov/vuln/detail/CVE-2026-140016
  • websocket-driver, fix commit f9f657c823ff826dc4bccda4c603ee076c089bd7 (checked December 1, 2026): https://github.com/faye/websocket-driver-node/commit/f9f657c823ff826dc4bccda4c603ee076c089bd7
  • websocket-driver Ruby, advisory GHSA-pf93-24xc-xgxc (checked December 1, 2026): https://github.com/faye/websocket-driver-ruby/security/advisories/GHSA-pf93-24xc-xgxc
  • websocket-driver Ruby, release 0.9.0 (checked December 1, 2026): https://github.com/faye/websocket-driver-ruby/releases/tag/0.9.0
  • websocket-driver source at the last affected release, lib/websocket/driver/draft75.js (checked December 1, 2026): https://github.com/faye/websocket-driver-node/blob/0.7.5/lib/websocket/driver/draft75.js
  • npm, websocket-driver package page, 39,177,273 downloads in the week of 2026-11-23 to 2026-11-29 (checked December 1, 2026): https://www.npmjs.com/package/websocket-driver
  • CISA, Known Exploited Vulnerabilities Catalog, catalog version 2026.11.30 (checked December 1, 2026): https://www.cisa.gov/known-exploited-vulnerabilities-catalog

Free scan

Scan your own app for free

or book a demo

Keep reading

Related articles

Browse the blog