Fix OneHot depth amplification DoS vulnerability#28014
Open
GopalakrishnanN wants to merge 1 commit intomicrosoft:mainfrom
Open
Fix OneHot depth amplification DoS vulnerability#28014GopalakrishnanN wants to merge 1 commit intomicrosoft:mainfrom
GopalakrishnanN wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Add overflow-safe validation of the output tensor size in PrepareOutputShape() to prevent unbounded memory allocation from attacker-controlled depth values. The depth parameter is used directly as an output tensor dimension, and previously only had a <= 0 check with no upper bound validation. An attacker could supply depth=2^32 with a small indices tensor to allocate ~16 GB. Changes: - Add overflow check in PrepareOutputShape() that validates total output element count won't overflow int64 before allocation (CPU + CUDA path) - Add null check on Output() return in both CPU and CUDA Compute functions as defense-in-depth against allocation failures - Add unit tests for overflow detection with large depth values
Contributor
|
@GopalakrishnanN please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix a Denial of Service vulnerability in the OneHot CPU/CUDA operator where an attacker-controlled
depthparameter could cause unbounded memory allocation.Root Cause
OneHotOp::Compute()readsdepthfrom a scalar tensor input and uses it directly as an output tensor dimension. The only validation wasdepth_val <= 0- there was no upper bound check. An attacker-supplied depth of 2^32 with a [1]-shape indices tensor creates a [1, 4294967296] float32 output requiring ~16 GB of memory, crashing servers.Fix
Files Changed
onnxruntime/core/providers/cpu/tensor/onehot.cc- overflow check + null guardonnxruntime/core/providers/cuda/tensor/onehot.cc- null guard (overflow check via shared PrepareOutputShape)onnxruntime/test/providers/cpu/tensor/onehot_op_test.cc- 2 new tests for overflow detectionTesting
All 30 OneHot tests pass (28 existing + 2 new)
Motivation and Context
MSRC security report: OneHot depth amplification - unbounded allocation DoS.