Skip to content

websocket: change the max_message_size default from unlimited to 32 MiB - #491

Merged
Leward merged 1 commit into
mainfrom
claude/max-message-size-defaults-6d111b
Sep 2, 2026
Merged

websocket: change the max_message_size default from unlimited to 32 MiB#491
Leward merged 1 commit into
mainfrom
claude/max-message-size-defaults-6d111b

Conversation

@Leward

@Leward Leward commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

The websocket input's max_message_size shipped in v4.78.0 with a default of 0: no read limit. This could allow a websocket server to make the process allocate an unbounded amount of memory with a single streamed message, leading to an OOM kill.

For existing configs the impact is limited. 32 MiB is a generous limit: typical websocket messages are orders of magnitude smaller. An explicit max_message_size, including 0 for unlimited, keeps its behaviour. The rare pipeline that receives larger messages fails loudly, not silently: the connection closes with a 1009 (message too big) status, an error is logged, and the input reconnects.

Ref:

  • CON-545
  • VM-73

The websocket input's `max_message_size` shipped in `v4.78.0` with a default
of 0: no read limit. This could allow a websocket server to make the process allocate an unbounded amount of memory with a single streamed message, leading to an OOM kill.

For existing configs the impact is limited. 32 MiB is a generous limit: typical websocket messages are orders of magnitude smaller. An explicit `max_message_size`, including 0 for unlimited, keeps its behaviour. The rare pipeline that receives larger messages fails loudly, not silently: the connection closes with a 1009 (message too big) status, an error is logged, and the input reconnects.

**Ref:**
 * CON-545
 * VM-73
@claude

claude Bot commented Sep 1, 2026

Copy link
Copy Markdown

Commits
LGTM

Review
Small, well-scoped change: introduces a defaultMaxMessageSize constant (32 MiB) and switches the websocket input's max_message_size field default from 0 (unlimited) to that constant, with a matching field-description update, a Changed CHANGELOG entry documenting the behavioural break and the 0 escape hatch, and a new TestWebsocketMaxMessageSizeDefault unit test asserting the parsed default. The existing negative-value validation, the SetReadLimit call in getConn, and the ErrReadLimit reconnect path in ReadBatch remain correct under the new default, and the constant is well within int range on 32-bit platforms. No other config, docs, or test fixtures reference this field.

LGTM

@josephwoodward

Copy link
Copy Markdown
Contributor

How did you arrive at the value of 32MiB?

@Leward

Leward commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

How did you arrive at the value of 32MiB?

It was the value recommended by the security audit: VM-73 - F-01 - Websocket Memory Exhaustion

IMO it is reasonable.

32MiB is quite large for websocket, so as a default it remains permissive while addressing the unbound memory usage issue.

@josephwoodward

Copy link
Copy Markdown
Contributor

@Leward Yes, it does sound reasonable. Was more curious to understand how your arrived at the figure which I see was suggested by the finding which clarifies it 👌

@Leward
Leward merged commit 347450b into main Sep 2, 2026
4 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.

2 participants