Skip to content

Fix WebSocket UTF8 validation for empty final frames - #137030

Merged
MihaZupan merged 1 commit into
dotnet:mainfrom
MihaZupan:websocket-utf8-validation
Nov 5, 2026
Merged

MihaZupan merged 1 commit into
dotnet:mainfrom
MihaZupan:websocket-utf8-validation

Conversation

@MihaZupan

Copy link
Copy Markdown
Member

ManagedWebSocket could accept an incomplete UTF8 sequence when a text message ended with an empty continuation frame, because the zero-byte receive path returned before validating the message.

Ensure completed messages reach UTF8 validation even when no payload bytes are received. Add regression coverage for empty final frames and zero-length receive buffers, and augment the WebSocket fuzzer to validate successfully received text messages.

Note

This description was generated with GitHub Copilot.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@MihaZupan MihaZupan added this to the 12.0.0 milestone Nov 5, 2026
@MihaZupan
MihaZupan requested a review from a team November 5, 2026 16:48
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @karelz, @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the WebSocket UTF-8 validation fix.

No open issues 🎉

What changed in this PR

Fixes ManagedWebSocket accepting incomplete UTF-8 text when a message ends with an empty continuation frame.

Changes:

  • Ensures completed messages reach UTF-8 validation even when no payload bytes are received.
  • Adds regression tests for incomplete and valid sequences, empty final frames, and zero-length receive buffers.
  • Extends the WebSocket fuzzer to validate accumulated text payloads when messages complete.
File Description
src/​libraries/​System.Net.WebSockets/​tests/​WebSocketUtf8Tests.cs Adds valid and invalid UTF-8 regression cases for empty final frames.
src/​libraries/​System.Net.WebSockets/​src/​System/​Net/​WebSockets/​ManagedWebSocket.cs Prevents completed messages from bypassing UTF-8 validation.
src/​libraries/​Fuzzing/​DotnetFuzzing/​Fuzzers/​WebSocketFuzzer.cs Checks successfully received text messages for valid UTF-8.

Review effort: Balanced

@MihaZupan
MihaZupan enabled auto-merge (squash) November 5, 2026 18:18
@MihaZupan
MihaZupan merged commit 72f7072 into dotnet:main Nov 5, 2026
87 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants