Fix OOB pointer in TensorAt for sub-byte packed types - #28973
Merged
Conversation
TensorAt computed pointer offsets using logical element indices but Size() returns the byte size of the packed storage unit (1 byte for Int4x2/UInt4x2 which holds 2 elements). This caused out-of-bounds pointer returns when element indices exceeded the actual buffer size. The API fundamentally cannot return a pointer to a sub-byte element, so reject sub-byte packed types with an appropriate error message, similar to how strings are already rejected. Fixes MSRC case 119499 (VULN-191667). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- tensor_at_normal_types_still_work: verifies float, int32, and int8 tensors still return correct values via TensorAt - tensor_at_bounds_check: verifies OOB indices, negative indices, and wrong dimension count all throw as expected Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
edgchen1
reviewed
Jun 10, 2026
edgchen1
reviewed
Jun 12, 2026
edgchen1
previously approved these changes
Jun 12, 2026
edgchen1
approved these changes
Jun 13, 2026
Contributor
Author
|
@microsoft-github-policy-service agree company="Microsoft" |
This was referenced Jul 25, 2026
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
Reject sub-byte packed types with appropriate error message. The TensorAt API returns a void*, it fundamentally cannot point to a sub-byte element. The fix is to reject sub-byte types at the API boundary, similar to how strings are rejected. Tests have been updated to reflect the changes.
Motivation and Context
TensorAt computed pointer offsets using logical element indices but Size() returns the byte size of the packed storage unit (1 byte for Int4x2/UInt4x2 which holds 2 elements). This caused out-of-bounds pointer returns when element indices exceeded the actual buffer size.
The API fundamentally cannot return a pointer to a sub-byte element, so reject sub-byte packed types with an appropriate error message, similar to how strings are already rejected.