Skip to content

fix(read): reject truncated messages - #579

Open
Grivn wants to merge 1 commit into
coder:masterfrom
Grivn:fix/reject-truncated-messages
Open

Grivn wants to merge 1 commit into
coder:masterfrom
Grivn:fix/reject-truncated-messages

Conversation

@Grivn

@Grivn Grivn commented Oct 16, 2026 •

Copy link
Copy Markdown

Fixes #578.

When a connection closes during a frame payload or before the final continuation frame, Read and Reader can return a partial message without an error. Return io.ErrUnexpectedEOF until the final frame's payload is complete.

Compressed messages need the same check. A valid DEFLATE stream can end before the WebSocket message does, so consume its remaining framing and padding before returning EOF. This preserves fragmented BFINAL messages and prevents buffered padding from affecting the next message.

The 108 regression cases cover plain and compressed messages, both receiver roles, both read APIs, and complete messages followed by more messages. The unchanged base fails 76 cases; the fix passes all 108.

Verified locally:

  • Go 1.23.12 package tests and Go 1.27.2 race tests.
  • Full AUTOBAHN=1 suite with the repository's existing exclusions: 296 OK, 3 informational results.
  • Linux/amd64 and WASM vet, native/WASM staticcheck, WASM compilation, examples and third-party integration tests.
  • Browser runtime: CI=1 go test -run ^TestWasm$ passed locally on macOS arm64 with Go 1.23.12, Chrome 155 and the same pinned wasmbrowsertest revision used in CI. This runtime run disabled native vet because of the existing assembly diagnostics below.

Native arm64 vet reports two existing assembly variable-name errors, also reproduced on the unchanged base.

The upstream TestWasm job times out starting the browser (websocket url timeout reached). The same failure is present in the unchanged-base CI run. The Linux startup failure remains unresolved; the current job does not include browser startup output to identify its cause.

Transport EOF before the final frame is complete can silently return a
partial message. Report unexpected EOF and finish the remaining framing
after a DEFLATE BFINAL block so valid fragmented messages still work.

This branch has not been deployed

No deployments
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.

Read returns a truncated fragmented message as complete when the connection closes mid-message

1 participant