Skip to content

fix: Input batch size overflow vulnerability #434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 24, 2025

Conversation

yinggeh
Copy link
Contributor

@yinggeh yinggeh commented Apr 23, 2025

What does the PR do?

  1. Cast uint32_t (batch_size_) to int32_t is not safe. Cast to int64_t instead. Before the change, request with overflowed batch size will bypass core check and propagate to backend. Although backend will catch the error, it's still better to stop the request at early stage.
  2. Remove input_memory_type from ValidateBytesInputs parameters as it's not used.

Checklist

  • PR title reflects the change and is of format <commit_type>: <Title>
  • Changes are described in the pull request.
  • Related issues are referenced.
  • Populated github labels field
  • Added test plan and verified test passes.
  • Verified that the PR passes existing CI.
  • Verified copyright is correct on all changed files.
  • Added succinct git squash message before merging ref.
  • All template sections are filled out.
  • Optional: Additional screenshots for behavior/output changes with before/after.

Commit Type:

Check the conventional commit type
box here and add the label to the github PR.

  • fix

Related PRs:

triton-inference-server/server#8165

Where should the reviewer start?

Test plan:

L0_input_validation--base

  • CI Pipeline ID:
    27387023

Caveats:

Background

Related Issues: (use one of the action keywords Closes / Fixes / Resolves / Relates to)

  • closes GitHub issue: #xxx

@yinggeh yinggeh added the bug Something isn't working label Apr 23, 2025
@yinggeh yinggeh requested review from indrajit96 and ziqif-nv April 23, 2025 00:41
@yinggeh yinggeh self-assigned this Apr 23, 2025
@@ -1076,7 +1076,7 @@ InferenceRequest::Normalize()

// Make sure request batch-size doesn't exceed what is supported by
// the model.
if ((int)batch_size_ > model_config.max_batch_size()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

batch_size_ is uint32_t type.

@yinggeh yinggeh marked this pull request as draft April 23, 2025 01:14
@yinggeh yinggeh marked this pull request as ready for review April 23, 2025 12:36
@yinggeh yinggeh changed the title fix: Overflow issue when uint32_t cast to int32 fix: Input batch size overflow vulnerability Apr 23, 2025
@yinggeh
Copy link
Contributor Author

yinggeh commented Apr 23, 2025

No HTTP or gRPC client test because input size is gigantic. The minimum input byte size to validate, assuming bool input with shape [-1,1], is 2^31 bytes or 2 GB.

In gRPC client, the maximum byte size allowed is exactly 2^31-1 bytes.
In http client, request stops at server with error
tritonclient.utils.InferenceServerException: [400] inference header size should be in range (0, -2147483525), got: 155.
In shared memory, returns error when shared memory size is 1 GB.

Bus error (core dumped)
UserWarning: resource_tracker: There appear to be 1 leaked shared_memory objects to clean up at shutdown

Copy link

@ziqif-nv ziqif-nv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yinggeh yinggeh merged commit 6fe7384 into main Apr 24, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

2 participants