GHSA-h5j3-crg5-8jqm: orx-pinned-vec has undefined behavior in index_of_ptr with empty slices
N/A
Basic Information
Technical Details
| Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
|---|---|---|---|
| orx-pinned-vec | rust | < 3.21.0 | 3.21.0 |
Vulnerability Intelligence
Miggo AI
Root Cause Analysis
The vulnerability lies in the index_of_ptr function within the orx-pinned-vec crate. The provided patch directly modifies this function to fix an integer underflow that leads to undefined behavior. The vulnerable code path is triggered when an empty slice is passed to the function. The problematic line ptr.add(slice.len() - 1) attempts to calculate the end of the slice, but for an empty slice, slice.len() is 0, causing an underflow. This results in the creation of an out-of-bounds pointer, which is considered undefined behavior in Rust. The fix replaces the manual pointer arithmetic with a safer method slice.as_ptr_range().contains() to check if the pointer is within the slice's bounds. Therefore, any runtime profile of an exploit of this vulnerability would show the index_of_ptr function.
Vulnerable functions
index_of_ptrsrc/utils/slice.rs