Fix out-of-bounds read in ConvTransposeWithDynamicPads - #32679
Open
Bryan B (bbernhar) wants to merge 3 commits into
Open
Bryan B (bbernhar) wants to merge 3 commits into
Bryan B (bbernhar) wants to merge 3 commits into
Conversation
When 'kernel_shape' is not provided as an attribute, it is derived from the weight (W) tensor's rank but indexed using n_input_dims, which is derived from the input (X) tensor's rank. A W rank greater than X rank overruns `dilations` in the dilation-scaling loop; a W rank less than X rank leaves `effective_kernel_shape` too short for the output-shape loop. Both occur in convTransposeWithDynamicPadsShapeInference() during Graph::Resolve(), before the model ever runs. Guard the derived kernel_shape against n_input_dims before it is used, matching the check already applied when 'kernel_shape' is supplied as an explicit attribute.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The regression test misses the vulnerable inference path and may fail on DML builds.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Prevents out-of-bounds reads during dynamic ConvTranspose shape inference when input and weight ranks differ.
Changes:
- Adds derived kernel-rank validation.
- Adds a mismatched-rank regression test.
File summaries
| File | Description |
|---|---|
onnxruntime/core/graph/contrib_ops/contrib_defs.cc |
Guards vector indexing against rank mismatch. |
onnxruntime/test/contrib_ops/conv_transpose_with_dynamic_pads_test.cc |
Adds malformed-rank coverage. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The guard prevents both unsafe indexing paths and the regression tests cover each rank mismatch direction.
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0 new
- Review effort level: Balanced (auto)
Note
Copilot is running an experiment and ran this review at Balanced.
Akshay Sonawane (apsonawane)
approved these changes
Sep 17, 2026
50 tasks
Author
|
Akshay Sonawane (@apsonawane) merged |
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
Add an explicit rank-consistency check in
convTransposeWithDynamicPadsShapeInference()so that a derivedkernel_shape(built from the weight tensor's rank when thekernel_shapeattribute is absent) must have the same length asn_input_dims(derived from the input tensor's rank) before it is used, exactly like the existing check on the explicit-attribute path.Motivation and Context
n_input_dimsis computed from inputX's rank. Whenkernel_shapeis not given as an attribute, it is instead derived from weightW's rank. IfW's rank disagrees withX's rank, the resultingkernel_shape(andeffective_kernel_shape, sized identically) is shorter or longer thann_input_dims. Both directions are unsafe:n_input_dimstimes overeffective_kernel_shape/pads, reading past the end of the shorter vector.kernel_shape.size()times overdilations, which is always sized ton_input_dims, reading past the end ofdilations.This runs during
Graph::Resolve()(model load), before any kernelCompute()validation is ever reached.Testing
Added
ConvTransposeWithDynamicPads_MismatchedInputWeightRank(X rank 5, W rank 3, nokernel_shapeattribute), asserting the model now fails cleanly at the existing kernel-level rank check ("X num_dims does not match W num_dims.") instead of hitting the shape-inference OOB read during load.