ws: Reject frames with unknown reserved bits set

RFC 6455 Section 5.2 notes that for bits RSV1, RSV2, and RSV3 of the
framing header, a non-zero value that is not defined by a negotiated
extension MUST Fail the WebSocket connection.

Test 2310 verifies

Closes #16069
This commit is contained in:
Andrew Kaster 2025-01-21 09:57:46 -07:00 committed by Daniel Stenberg
parent e2ec7bf1b4
commit 1b740aedcd
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
6 changed files with 168 additions and 10 deletions

View file

@ -256,7 +256,7 @@ test2100 \
test2200 test2201 test2202 test2203 test2204 test2205 \
\
test2300 test2301 test2302 test2303 test2304 test2305 test2306 test2307 \
test2308 test2309 \
test2308 test2309 test2310 \
\
test2400 test2401 test2402 test2403 test2404 test2405 test2406 \
\

68
tests/data/test2310 Normal file
View file

@ -0,0 +1,68 @@
<testcase>
<info>
<keywords>
WebSockets
</keywords>
</info>
#
# Sends a PING + a TEXT with RSV1 set
<reply>
<data nocheck="yes" nonewline="yes">
HTTP/1.1 101 Switching to WebSockets
Server: test-server/fake
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: HkPsVga7+8LuxM4RGQ5p9tZHeYs=
%hex[%89%00%C1%05hello]hex%
</data>
# allow upgrade
<servercmd>
upgrade
</servercmd>
</reply>
#
# Client-side
<client>
# require debug for the forced CURL_ENTROPY
<features>
Debug
ws
</features>
<server>
http
</server>
<name>
WebSockets unknown reserved bit set in frame header
</name>
<tool>
lib%TESTNUMBER
</tool>
<command>
ws://%HOSTIP:%HTTPPORT/%TESTNUMBER
</command>
</client>
#
# PONG with no data and the 32 bit mask
#
<verify>
<protocol nocheck="yes" nonewline="yes">
GET /%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: webbie-sox/3
Accept: */*
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: NDMyMTUzMjE2MzIxNzMyMQ==
%hex[%8a%808321]hex%
</protocol>
<stdout mode="text">
Returned 56, should be 56.
</stdout>
</verify>
</testcase>