Unbounded streaming buffers (OOM risk) #6

Open
opened 2026-05-18 02:18:43 +00:00 by renekv · 0 comments
Contributor

Severity: High

In streamAnthropic and streamResponses, text/reasoning content is accumulated in unbounded strings.Builder:

var reasoning strings.Builder
var text strings.Builder

These grow without limit. A malicious upstream that streams an infinite response (or a very long one) causes OOM.

Files: cmd/ocgo/main.go:1063, 1192

Fix: Cap the builders at a reasonable limit (e.g., truncate after N bytes).

**Severity: High** In `streamAnthropic` and `streamResponses`, text/reasoning content is accumulated in unbounded `strings.Builder`: ```go var reasoning strings.Builder var text strings.Builder ``` These grow without limit. A malicious upstream that streams an infinite response (or a very long one) causes OOM. **Files:** `cmd/ocgo/main.go:1063`, `1192` **Fix:** Cap the builders at a reasonable limit (e.g., truncate after N bytes).
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: opencode/ocgo#6
No description provided.