reject interleaved data frame in a fragmented websocket message - #13553
reject interleaved data frame in a fragmented websocket message#13553arshsmith1 wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #13553 +/- ##
=======================================
Coverage 99.02% 99.02%
=======================================
Files 135 135
Lines 50455 50461 +6
Branches 2647 2648 +1
=======================================
+ Hits 49962 49968 +6
Misses 370 370
Partials 123 123
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Merging this PR will not alter performance
Comparing Footnotes
|
What do these changes do?
WebSocketReader._handle_frameenforces RFC 6455 section 5.4 fragmentation only when a frame carries FIN. The not-fin branch appends the fragment and returns without checking whether a message is already in progress, so a new TEXT/BINARY frame with FIN cleared, sent between the opening fragment and its continuation, is silently merged into the message instead of failing the connection. The guard that rejects a non-continuation opcode mid-message is only reached for FIN=1 frames.A spec-following peer or on-path proxy fails such a stream, so the reader assembles a message a compliant party would reject. This puts the same in-progress check on the not-fin branch, reusing the existing protocol-error path.
Are there changes in behavior for the user?
Only for the malformed case. A normal fragmented message (initial data fragment, continuation frames, interleaved control frames) is unaffected; a data frame arriving mid-message now closes with a protocol error, matching the FIN=1 handling already in place.
Is it a substantial burden for the maintainers to support this?
No. A few lines at the single frame-assembly site, with a regression test beside the existing continuation tests.
Related issue number
N/A
Checklist
CONTRIBUTORS.txtCHANGES/folder