From 2fa10052cf4181b6edb1a8bd84bd57463464eee4 Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Thu, 26 Mar 2026 15:37:38 +0100 Subject: [PATCH] websocket: check pdu opcode for reassembly Ticket: 8413 RFC 6455 Section 5.4 states Control frames (see Section 5.5) MAY be injected in the middle of a fragmented message. Control frames are identified by opcodes where the most significant bit of the opcode is 1. --- rust/src/websocket/websocket.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/src/websocket/websocket.rs b/rust/src/websocket/websocket.rs index d29b08a5e3..f3e3a9bf22 100644 --- a/rust/src/websocket/websocket.rs +++ b/rust/src/websocket/websocket.rs @@ -220,7 +220,7 @@ impl WebSocketState { (&mut self.c2s_buf, &mut self.c2s_dec) }; let mut compress = pdu.compress; - if !buf.data.is_empty() || !pdu.fin { + if pdu.opcode < 8 && (!buf.data.is_empty() || !pdu.fin) { if buf.data.is_empty() { buf.compress = pdu.compress; } @@ -234,7 +234,7 @@ impl WebSocketState { } } tx.pdu = pdu; - if tx.pdu.fin && !buf.data.is_empty() { + if tx.pdu.opcode < 8 && tx.pdu.fin && !buf.data.is_empty() { // the final PDU gets the full reassembled payload compress = buf.compress; std::mem::swap(&mut tx.pdu.payload, &mut buf.data);