Skip to content

security fix for transpose optimizer - #27555

Merged
prathikr merged 7 commits into
mainfrom
prathikrao/transpose-optimizer-security-fix
Mar 5, 2026
Merged

security fix for transpose optimizer#27555
prathikr merged 7 commits into
mainfrom
prathikrao/transpose-optimizer-security-fix

Conversation

@prathikr

@prathikr prathikr commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

A denial-of-service (DoS) vulnerability exists in the ONNX Runtime's TransposeOptimizer component. The issue arises when a maliciously crafted ONNX model with specific tensor ranks, such as rank-0 or scalar, triggers a division-by-zero error during the graph optimization phase. This occurs due to the improper handling of tensor ranks and permutations in the optimizer utility Permute1DConstant, particularly when processing Pad nodes. The vulnerability can lead to an immediate process crash, such as SIGFPE or SIGSEGV.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR is a targeted security fix for the ONNX Runtime's TransposeOptimizer component to address a denial-of-service (DoS) vulnerability. When a maliciously crafted ONNX model contains a Transpose node with a rank-0 (empty) perm attribute, the optimizer's Permute1DConstant utility function performs an integer division by zero (data.size() / rank where rank == 0), leading to a process crash (SIGFPE or SIGSEGV).

Changes:

  • Adds an early-exit guard in IsValidPerm() that returns false when the permutation vector is empty (rank-0), preventing the invalid permutation from propagating downstream into Permute1DConstant and causing a division-by-zero crash.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread onnxruntime/core/optimizer/transpose_optimization/onnx_transpose_optimization.cc Outdated
Comment thread onnxruntime/test/optimizer/transpose_optimizer_test.cc Outdated
prathikr and others added 2 commits March 4, 2026 14:55
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread onnxruntime/test/optimizer/transpose_optimizer_test.cc Outdated
Comment thread onnxruntime/test/optimizer/transpose_optimizer_test.cc Outdated
prathikr and others added 2 commits March 4, 2026 15:56
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread onnxruntime/test/optimizer/transpose_optimizer_test.cc Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@prathikr
prathikr merged commit 6eb3dcc into main Mar 5, 2026
95 checks passed
@prathikr
prathikr deleted the prathikrao/transpose-optimizer-security-fix branch March 5, 2026 18: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.

3 participants