Skip to content

Commit 1712db1

Browse files
committed
feat(ws-server): added check for rsvBits - no rsv allowed at current version
1 parent 0e0d048 commit 1712db1

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/libs/custom_lib/WebSocketServer.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,18 @@ WebSocketServer stays in memory BECAUSE the closure holds a reference to `this`
389389
const secondByte = infoBuffer[1];
390390

391391
// Extract frame metadata from header bytes
392+
const rsvBits = firstByte & 0b01110000;
392393
this._fin = (firstByte & 0b10000000) === 0b10000000;
393394
this._opcode = firstByte & 0b00001111;
394395
this._masked = (secondByte & 0b10000000) === 0b10000000;
395396
this._initialPayloadSizeIndicator = secondByte & 0b01111111;
396397

398+
// No extensions allowed in current version
399+
if (rsvBits !== 0) {
400+
this._sendClose(1002, "RSV bits must be 0");
401+
return;
402+
}
403+
397404
// Validate: RFC 6455 requires client frames to be masked
398405
if (!this._masked) {
399406
this._sendClose(1002, "Client frames must be masked");

0 commit comments

Comments
 (0)