Skip to content

fix(router): prevent OOM by enforcing size limits on HTTP request bodies - #1677

Open
safiya2610 wants to merge 1 commit into
volcano-sh:mainfrom
safiya2610:fix-1641-oom-vulnerability
Open

fix(router): prevent OOM by enforcing size limits on HTTP request bodies#1677
safiya2610 wants to merge 1 commit into
volcano-sh:mainfrom
safiya2610:fix-1641-oom-vulnerability

Conversation

@safiya2610

Copy link
Copy Markdown
Contributor

Description

Fixes #1641

This PR addresses a critical Denial of Service (DoS) vulnerability where unbounded user requests could exhaust router memory and cause the pod to crash (OOMKilled).

Previously, several HTTP handlers used io.ReadAll directly on uncontrolled input streams without enforcing a maximum payload size. This PR mitigates the vulnerability by wrapping the incoming request bodies in an io.LimitReader configured with a strict 10MB limit before reading them into memory.

Changes Made

  • pkg/kthena-router/router/router.go: Wrapped c.Request.Body and req.Body with io.LimitReader (10MB) in ParseModelRequest and proxyModelEndpoint.
  • pkg/kthena-router/handlers/request.go: Wrapped r.Body with io.LimitReader (10MB) in ParseOpenAIRequestBody.
  • pkg/kthena-router/webhook/utils.go: Wrapped r.Body with io.LimitReader (10MB) in parseAdmissionReviewFromRequest.

@volcano-sh-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign yaozengzeng for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Comment thread pkg/kthena-router/router/router.go Outdated
@safiya2610
safiya2610 force-pushed the fix-1641-oom-vulnerability branch 3 times, most recently from 17b8345 to dfc34e0 Compare August 24, 2026 04:24
Prevent unbounded memory allocation by wrapping io.ReadAll calls with an io.LimitReader of 10MB.

Signed-off-by: safiya2610 <lci2023053@iiitl.ac.in>
@safiya2610
safiya2610 force-pushed the fix-1641-oom-vulnerability branch from dfc34e0 to c937510 Compare August 24, 2026 04:27
@safiya2610

Copy link
Copy Markdown
Contributor Author

@LiZhenCheng9527 PTAL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Accepted

Development

Successfully merging this pull request may close these issues.

Vulnerability: Unbounded reading of HTTP request bodies using io.ReadAll

3 participants