Repository navigation
fix: validate WebSocket CLOSE frames - #583
Merged
Merged
Conversation
azkrishpy
force-pushed
the
todo/websocket-close
branch
from
September 8, 2026 22:05
58a5c8f to
eb8fdb7
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #583 +/- ##
==========================================
+ Coverage 79.95% 80.10% +0.14%
==========================================
Files 28 28
Lines 12154 12182 +28
==========================================
+ Hits 9718 9758 +40
+ Misses 2436 2424 -12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
TingDaoK
approved these changes
Sep 30, 2026
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.
Issue #, if available: N/A
Description of changes:
Validates received WebSocket control frames, which the decoder previously accepted without checking. Replaces the open
validate payload of CLOSE frameTODO.Three rules, all
MUSTrequirements the decoder was not meeting:Why this is a
fixand not part of the TODO-cleanup chore: these frames used to decode and reach the caller, and now close the connection. The realistic case is a CLOSE frame carrying1005or1006. Those codes are reserved for an endpoint's own internal use and must never be sent, but implementations do emit them. Previously the frame was delivered and the connection closed normally; now the decoder raisesAWS_ERROR_HTTP_WEBSOCKET_PROTOCOL_ERROR, and there is no per-frame recovery, so the whole connection is dropped during what the peer intended as an orderly shutdown. That is what the spec asks for, but it turns working traffic into a failure and deserves its own review and release note.The status code table accepts 1000-1014 except 1004, plus 3000-4999, and rejects 1005/1006/1015 along with everything else. Rejecting the reserved 1016-2999 range is the one judgment call here; the RFC leaves it undefined, so accepting and ignoring would also be defensible.
Still patch-level: no API changes, and the behavior is what the spec expects.
Two new decoder test cases covering the oversized control frame and the status codes.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.