fix(websocket): don't require Sec-WebSocket-Accept on an h2 handshake - #5774
Open
kjsik11 wants to merge 1 commit into
Open
fix(websocket): don't require Sec-WebSocket-Accept on an h2 handshake#5774kjsik11 wants to merge 1 commit into
kjsik11 wants to merge 1 commit into
Conversation
Assisted-by: Claude Code
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5774 +/- ##
==========================================
+ Coverage 93.51% 93.53% +0.01%
==========================================
Files 110 110
Lines 39324 39325 +1
==========================================
+ Hits 36774 36781 +7
+ Misses 2550 2544 -6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This relates to...
WebSocket over h2 (RFC 8441) handshake validation.
Reported in #5681 and closed as a server-compliance issue — but per RFC 8441 §5 the response is valid:
Sec-WebSocket-Acceptis not processed on an h2 handshake.Rationale
Over h1, the handshake response is validated against RFC 6455 §4.1 steps 2–6.
Over h2,
Sec-WebSocket-KeyandSec-WebSocket-Acceptare not processed at all — RFC 8441 §5:undici already skips steps 2 (
Upgrade) and 3 (Connection) for h2, but not step 4 (Sec-WebSocket-Accept).An h2 server that responds without
Sec-WebSocket-Accepttherefore fails step 4 and closes with 1006.Repro(.mjs) — 1006 on
main, opens with this PRChanges
lib/web/websocket/connection.js: give step 4 the same h2 gate steps 2 and 3 have.test/websocket/opening-handshake.js: an h2 server responds200withoutSec-WebSocket-Acceptand the test awaitsopen. Fails onmain, passes with the patch.Features
N/A
Bug Fixes
Sec-WebSocket-Accept.Breaking Changes and Deprecations
N/A
Test results (Node 24.20.0)
npm run lintcleantest/websocket/**/*.js148/148Assisted-by: Claude Code
Status