The vulnerability is an out-of-bounds read in the imageproc library caused by improper handling of NaN (Not a Number) floating-point coordinates. The root cause lies in several interpolation functions (interpolate_bilinear, interpolate_bicubic, interpolate_nearest) within the geometric_transformations.rs file. These functions performed bounds checks using a series of OR (||) conditions. In floating-point arithmetic, any comparison involving NaN (e.g., NaN < 0.0) evaluates to false. Consequently, if an attacker supplied a NaN coordinate, all parts of the bounds check would evaluate to false, causing the check to be bypassed and allowing code in the else block, which contained unsafe memory access, to be executed with invalid indices.
The patch addresses this by inverting the logic. It replaces the negative checks with positive checks combined with AND (&&) operators (e.g., x >= 0.0 && x < width). With this change, if x is NaN, the first part of the condition (NaN >= 0.0) is false, causing the entire expression to be false and correctly preventing the unsafe code from being executed.
The public-facing API functions warp_into and warp_into_with are the primary entry points for this vulnerability, as they take user-controlled transformations or mappings that can be crafted to produce NaN coordinates and then pass them to the vulnerable interpolation functions. Therefore, a runtime profile during exploitation would show calls originating from warp_into or warp_into_with and leading to one of the vulnerable interpolate_* functions.