Skip to content

Cap IPC buffer size at 10 MB to prevent unbounded memory growth#44

Merged
jancurn merged 1 commit intomainfrom
claude/fix-ipc-buffer-leak-SdO3i
Mar 8, 2026
Merged

Cap IPC buffer size at 10 MB to prevent unbounded memory growth#44
jancurn merged 1 commit intomainfrom
claude/fix-ipc-buffer-leak-SdO3i

Conversation

@jancurn
Copy link
Member

@jancurn jancurn commented Mar 8, 2026

Summary

This PR adds a buffer size limit to the IPC communication between the CLI and bridge process to prevent unbounded memory growth from malformed or excessively large messages.

Changes

  • Added MAX_BUFFER_SIZE constant (10 MB) to both BridgeProcess and BridgeClient
  • Implemented buffer overflow detection in the data event handlers of both IPC endpoints
  • When the buffer exceeds the limit, the socket is destroyed and cleaned up to prevent memory exhaustion
  • Updated CHANGELOG to document the fix

Implementation Details

  • The check is performed after each data chunk is appended to the buffer
  • If the limit is exceeded, an error is logged and the socket is immediately destroyed
  • In BridgeProcess, the socket is removed from the connections map
  • In BridgeClient, the cleanup method is called to properly release resources
  • Both implementations follow the same pattern for consistency across the IPC layer

https://claude.ai/code/session_016foZUbDw68HevDoSakfUHF

Both sides of the bridge IPC accumulated socket data into an unbounded
string buffer. A message without a newline delimiter would grow the
buffer until OOM. Added a 10 MB ceiling that destroys the socket if
exceeded.

https://claude.ai/code/session_016foZUbDw68HevDoSakfUHF
@jancurn jancurn merged commit fc07764 into main Mar 8, 2026
6 checks passed
@jancurn jancurn deleted the claude/fix-ipc-buffer-leak-SdO3i branch March 12, 2026 14:17
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.

3 participants