Skip to content

Security: Missing bounds checks on batch size can cause memory/CPU exhaustion#1468

Open
tuanaiseo wants to merge 1 commit into
instill-ai:mainfrom
tuanaiseo:contribai/fix/security/missing-bounds-checks-on-batch-size-can-
Open

Security: Missing bounds checks on batch size can cause memory/CPU exhaustion#1468
tuanaiseo wants to merge 1 commit into
instill-ai:mainfrom
tuanaiseo:contribai/fix/security/missing-bounds-checks-on-batch-size-can-

Conversation

@tuanaiseo
Copy link
Copy Markdown

@tuanaiseo tuanaiseo commented Apr 4, 2026

Problem

Multiple handlers derive input_len = len(inputs) (or vision inputs) and allocate response lists directly from that size without limits. Large crafted requests can trigger oversized allocations and excessive compute, causing denial of service.

Severity: medium
File: integration-test/models/dummy-chat/model.py

Solution

Validate and cap maximum batch size before processing (e.g., reject or truncate requests above a configured threshold) and add global request size limits.

Changes

  • integration-test/models/dummy-chat/model.py (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

Note

Low Risk
Low risk: adds a simple bounds check that rejects oversized chat batches before allocating per-item response structures. Main impact is a new ValueError for requests over the limit, which could affect any callers relying on unbounded batch sizes.

Overview
Adds a maximum batch size guard to integration-test/models/dummy-chat/model.py by introducing MAX_BATCH_SIZE = 128 and rejecting requests where len(inputs) exceeds this limit.

This prevents oversized batch requests from triggering large list allocations and excessive compute; oversized requests now fail fast with a ValueError.

Reviewed by Cursor Bugbot for commit a616489. Bugbot is set up for automated code reviews on this repo. Configure here.

Multiple handlers derive `input_len = len(inputs)` (or vision inputs) and allocate response lists directly from that size without limits. Large crafted requests can trigger oversized allocations and excessive compute, causing denial of service.

Affected files: model.py

Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
@tuanaiseo tuanaiseo requested a review from pinglin as a code owner April 4, 2026 15:19
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