No request body size limits on proxy endpoints #4

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

Severity: High

All three proxy endpoints (/v1/messages, /v1/chat/completions, /v1/responses) use json.NewDecoder(r.Body) or io.ReadAll(r.Body) without http.MaxBytesReader or any size limit. An attacker on localhost (or via DNS rebinding) can exhaust server memory with a multi-gigabyte payload.

Files: cmd/ocgo/main.go:368, 408, 442

Fix: Add r.Body = http.MaxBytesReader(w, r.Body, <limit>) to all handlers.

**Severity: High** All three proxy endpoints (`/v1/messages`, `/v1/chat/completions`, `/v1/responses`) use `json.NewDecoder(r.Body)` or `io.ReadAll(r.Body)` without `http.MaxBytesReader` or any size limit. An attacker on localhost (or via DNS rebinding) can exhaust server memory with a multi-gigabyte payload. **Files:** `cmd/ocgo/main.go:368`, `408`, `442` **Fix:** Add `r.Body = http.MaxBytesReader(w, r.Body, <limit>)` to all handlers.
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#4
No description provided.