Skip to content

fix: bound sys.stdin.read() to prevent OOM on oversized payloads - #3903

Open
Quratulain-bilal wants to merge 1 commit into
github:mainfrom
Quratulain-bilal:fix/bounded-stdin-read
Open

fix: bound sys.stdin.read() to prevent OOM on oversized payloads#3903
Quratulain-bilal wants to merge 1 commit into
github:mainfrom
Quratulain-bilal:fix/bounded-stdin-read

Conversation

@Quratulain-bilal

Copy link
Copy Markdown
Contributor

Problem

sys.stdin.read() loads all of stdin into memory with no size limit. A malfunctioning agent hook or malicious process can pipe gigabytes of data into stdin, exhausting process memory before the payload is ever consumed.

This affects both the CLI event runner (commands/event.py) and the standalone events entry point (events.py).

Fix

Cap stdin reads at 10 MiB using a bounded chunked read loop. The function reads in 64 KiB chunks and stops once the limit is reached, preventing unbounded memory allocation.

Testing

  • Verified that normal payloads (well under 10 MiB) pass through unchanged
  • Verified that the bounded reader stops at the limit instead of reading all input

sys.stdin.read() loads all of stdin into memory with no size limit.
A malfunctioning agent hook can pipe gigabytes of data, exhausting
process memory. Cap reads at 10 MiB in both the CLI event runner
and the standalone events entry point.
@Quratulain-bilal
Quratulain-bilal requested a review from mnriem as a code owner July 31, 2026 12:12
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