Skip to content

fail websocket handshake on invalid sec-websocket-accept#2211

Merged
hyperxpro merged 1 commit into
AsyncHttpClient:mainfrom
jmestwa-coder:websocket-invalid-accept
Jun 23, 2026
Merged

fail websocket handshake on invalid sec-websocket-accept#2211
hyperxpro merged 1 commit into
AsyncHttpClient:mainfrom
jmestwa-coder:websocket-invalid-accept

Conversation

@jmestwa-coder

Copy link
Copy Markdown
Contributor

WebSocket upgrade continues after a failed challenge check
When the server's Sec-WebSocket-Accept doesn't match the key (or the header is absent), upgrade() aborts the future but does not return, so it goes on to swap in the WebSocket pipeline and call onOpen on the listener. RFC 6455 section 4.1 requires the client to fail the connection here, which is what the sibling handshake check right above already does. Added the missing return so a bad or missing accept value ends the connection instead of surfacing an unverified peer as an open WebSocket.

Covered by a new test that drives the client against a server returning a 101 with a wrong Sec-WebSocket-Accept and asserts onOpen never fires.

@hyperxpro hyperxpro merged commit ccdcaa6 into AsyncHttpClient:main Jun 23, 2026
22 of 26 checks passed
@hyperxpro

Copy link
Copy Markdown
Member

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants