CVE-2026-144293 — Websocket-driver — CWE-770
### Summary A server running `websocket-driver` can be made to buffer data in excess of `max_length` and potentially run out of memory by a client sending a non-terminated stream of message data. ### Details When configured using `allow_drafts: true`, the `websocket-driver` library continues to support legacy draft versions of the WebSocket protocol. These use delimited rather than length-prefixed frames; a frame is initiated by sending `00` and ended by sending `FF`. If a client sends `00` and then sends a long series of bytes, the server will buffer this data in excess of `max_length`, potentially causing it to run out of memory if the message is continued indefinitely. This has been mitigated by properly enforcing the `max_length` limit at the point where the data is buffered. It can also be prevented by not setting the `allow_drafts` option. ### Proof of concept This script demonstrates how much data is buffered by a draft-75 parser on receipt of a very long unterminated message: ```rb require 'bundler/setup' require 'websocket/driver' class Sock def write(_) ; end end d = WebSocket::Driver.server(Sock.new, :allow_drafts => true, :max_length => 1024) d.on(:connect) { d.start } # draft-75 handshake: NO Sec-WebSocket-Key/Version/Key1/Key2 -> Draft75 selected d.parse( "GET / HTTP/1.1\r\n" + "Host: localhost\r\n" + "Upgrade: websocket\r\n" + "Connection: Upgrade\r\n" + "Origin: http://localhost\r\n" + "\r\n") # One text frame: 0x00, then 10 MB of 0x41
### Summary A server running `websocket-driver` can be made to buffer data in excess of `max_length` and potentially run out of memory by a client sending a non-terminated stream of message data. ### Details When configured using `allow_drafts: true`, the `websocket-driver` library continues to support legacy draft versions of the WebSocket protocol. These use delimited rather than length-prefixed frames; a frame is initiated by sending `00` and ended by sending `FF`. If a client sends `00` and then sends a long series of bytes, the server will buffer this data in excess of `max_length`, potentially causing it to run out of memory if the message is continued indefinitely. This has been mitigated by properly enforcing the `max_length` limit at the point where the data is buffered. It can also be prevented by not setting the `allow_drafts` option. ### Proof of concept This script demonstrates how much data is buffered by a draft-75 parser on receipt of a very long unterminated message: ```rb require 'bundler/setup' require 'websocket/driver' class Sock def write(_) ; end end d = WebSocket::Driver.server(Sock.new, :allow_drafts => true, :max_length => 1024) d.on(:connect) { d.start } # draft-75 handshake: NO Sec-WebSocket-Key/Version/Key1/Key2 -> Draft75 selected d.parse( "GET / HTTP/1.1\r\n" + "Host: localhost\r\n" + "Upgrade: websocket\r\n" + "Connection: Upgrade\r\n" + "Origin: http://localhost\r\n" + "\r\n") # One text frame: 0x00, then 10 MB of 0x41
🎯 What is this vulnerability?
This vulnerability is a Resource Exhaustion (Denial of Service) flaw classified under CWE-770: Allocation of Resources Without Limits or Throttling.
Technical Flaw Analysis:
The core issue lies in the websocket-driver gem (a Ruby library) when configured with allow_drafts: true.
1. Legacy Protocol Support: When allow_drafts is enabled, the server accepts connections using obsolete WebSocket draft protocols (specifically draft-75/76).
2. Parser Logic Error: The parser for these legacy drafts does not correctly enforce the max_length limit during the buffering phase of an unterminated frame.
3. Unbounded Memory Allocation: If a client initiates a text frame but omits the terminating delimiter (or sends it in a way that the parser waits for indefinitely), the server continues to buffer incoming data into memory.
4. Lack of Timeout/Abort: The server does not abort the connection or reject the frame based on the max_length constraint while waiting for the terminator, leading to unbounded memory growth until the process crashes (OOM - Out of Memory).
CVSS Vector Breakdown:
- AV:N (Network): Exploitable remotely.
- AC:L (Low Complexity): No race conditions or complex timing required.
- PR:N (No Privileges): Unauthenticated access is sufficient.
- UI:N (No User Interaction): No user action needed.
- S:U (Unchanged Scope): The impact is contained to the vulnerable component (the server process).
- C:N / I:N / A:H (High Availability Impact): The primary impact is a crash of the server process, leading to a complete denial of service for that instance.
- Fingerprinting: Identify applications using Ruby on Rails or other Ruby frameworks that utilize
websocket-driver. - Version Check: * Check
- Configuration Inference: The vulnerability only manifests if
allow_draftsis explicitly set totruein the application code. Modern applications often disable this, but legacy or poorly configured apps may leave it on for backward compatibility.
⚡ Attack Chain
1. Discovery & Reconnaissance
Gemfile.lock if accessible (rare).
* Monitor HTTP response headers for X-Powered-By: Ruby or specific Rails version headers.
* Attempt a WebSocket handshake (Upgrade: websocket) to a known endpoint. If the server responds with a 101 Switching Protocols and accepts legacy draft headers (e.g., Sec-WebSocket-Protocol: draft-75), it is likely vulnerable if allow_drafts is enabled.
2. Exploitation
Mechanism: The attacker initiates a WebSocket connection using a legacy draft protocol header. They then send a text frame header indicating a large payload size (or no size, depending on the specific draft implementation) but do not send the terminating delimiter or send data slowly enough to keep the buffer open. The server buffers the incoming bytes indefinitely.Illustrative PoC (Ruby Script):
Note: The exact frame structure depends on the specific draft version (75/76). This is an illustrative example of the logic.
require 'socket'
require 'websocket-driver'
# Connect to the target WebSocket server
host = 'target.example.com'
port = 80
path = '/ws'
socket = TCPSocket.new(host, port)
# Send HTTP Upgrade request with legacy draft header
# Note: draft-75/76 uses different headers than modern RFC 6455
request = <<~HTTP
GET #{path} HTTP/1.1
Host: #{host}
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
Sec-WebSocket-Protocol: draft-75
Sec-WebSocket-Version: 75
HTTP
socket.write(request)
response = socket.readuntil("\r\n\r\n")
puts "Response: #{response}"
# If 101 is received, proceed to send malformed frames
# The attacker sends a start of a text frame but never sends the end delimiter
# or sends data in a way that the parser waits for more data without checking max_length
# Example: Send a frame header indicating a large length, then stream data slowly
# The specific byte sequence for draft-75/76 must be constructed according to that draft spec.
# For demonstration, we simulate the logic of keeping the connection open and sending data
# that the parser buffers without enforcing the limit.
# In a real exploit, this would involve crafting the specific binary frame structure
# for draft-75/76 that triggers the buffering bug.
puts "Vulnerability triggered: Server is now buffering unbounded data."Curl-based Reconnaissance (Not Exploit):
# Check if the server accepts WebSocket upgrades
curl -i -N \
-H "Connection: Upgrade" \
-H "Upgrade: websocket" \
-H "Sec-WebSocket-Version: 75" \
-H "Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==" \
http://target.example.com/ws3. Post-Exploitation
systemd, pm2, or foreman).🌍 Real World Impact
🛡️ Remediation & Mitigation
1. Upgrade (Primary Fix)
websocket-driver < 0.9.2websocket-driver >= 0.9.2Gemfile:gem 'websocket-driver', '>= 0.9.2'Then run bundle update websocket-driver.
2. Workarounds (If Immediate Upgrade is Not Possible)
# Example in a Rails application or custom WebSocket server
driver = WebSocket::Driver.server(
allow_drafts: false # CRITICAL: Set to false
)Note: This is the most effective mitigation if you can control the server configuration.
# ModSecurity Rule
SecRule REQUEST_HEADERS:Sec-WebSocket-Version "@rx ^7[56]$|draft-7[56]" \
"id:100001,phase:1,deny,status:403,msg:'Blocked legacy WebSocket draft'"Note: This rule blocks connections using draft-75/76. Adjust the regex to match the specific headers used by the vulnerable parser.
ulimit -v) for the Ruby process to prevent it from consuming all available memory. This will cause the process to crash earlier, but it does not prevent the DoS.3. Detection (IoCs)
Sec-WebSocket-Version: 75 or 76 or Sec-WebSocket-Protocol: draft-75/draft-76.
* Example log entry:GET /ws HTTP/1.1
Upgrade: websocket
Sec-WebSocket-Version: 75OOM Killer events in /var/log/syslog or dmesg related to the Ruby process.
* Example:Out of memory: Kill process 1234 (ruby) score 900 or sacrifice child⚠️ Urgency
allow_drafts if possible.
2. Short-term: Upgrade websocket-driver to 0.9.2 or later.
3. Ongoing: Monitor for OOM events and legacy WebSocket connection attempts.[🤖 CVE Professor AI Security Engine]