The vulnerability lies in ImageMagick's distributed pixel cache (DPC), which lacked proper authentication and validation, allowing potential information disclosure. The analysis of the security advisory and the associated patch revealed that the core issue was the absence of checks on the data requested from the cache.
The patch, identified by comparing the repository tags before and after the patched version, is in commit bb79e91155127dd6c3c18a01c8761e9c2ea82d70. This commit modifies the file MagickCore/distribute-cache.c.
The key changes involve adding calls to a new validation function, ValidateDistributedPixelCache, within two functions responsible for reading from the cache: ReadDistributeCacheMetacontent and ReadDistributeCachePixels.
These two functions are identified as the vulnerable functions because, prior to the patch, they would process read requests for pixel and metadata from the DPC without verifying if the requested size (length) was valid for the specified image region. This flaw could be exploited by a malicious actor to read arbitrary data from the server's memory where the cache is stored, leading to an information disclosure vulnerability. The patch mitigates this by calculating the expected size and comparing it against the requested length.