Skip to content

Close a WebSocket connection whose unfinished frame passes 1 MB - #95

Closed
rkv0id wants to merge 1 commit into
rawhat:masterfrom
rkv0id:frame-cap-pr
Closed

rkv0id wants to merge 1 commit into
rawhat:masterfrom
rkv0id:frame-cap-pr

Conversation

@rkv0id

@rkv0id rkv0id commented Oct 22, 2026

Copy link
Copy Markdown

A WebSocket frame says how long it is in its header, and mist keeps buffering until the whole frame has arrived. A client that announces a very large frame and keeps sending can grow one connection's buffer until the node runs out of memory.

This closes the connection once more than 1 MiB of an unfinished frame is waiting, and logs a warning. Frames under the limit are unaffected.

The limit is a constant for now; happy to make it configurable (e.g. on the websocket builder) if you'd prefer.

Notes, both on master as well and unrelated to this change:

  • http1_test.it_rejects_large_requests_test fails for me (macOS).
  • gleam format --check flags src/mist/internal/http2/frame.gleam; I left it untouched to keep this PR to the fix.

A frame announces its length and its payload follows; mist kept
buffering until the frame was whole, so a peer announcing a huge frame
could grow the buffer until the node ran out of memory. Past 1 MiB of
unfinished frame the connection is now closed, with a warning in the
log.
@rkv0id

rkv0id commented Oct 22, 2026

Copy link
Copy Markdown
Author

Closing in favour of #92 , which fixes the same issue more completely (the declared length is checked before buffering, fragmented messages have a shared limit, the limits are configurable). I'll follow that one instead.

@rkv0id rkv0id closed this Oct 22, 2026
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.

1 participant