Fix integer overflow vulnerability in exportImagePixels#775
Open
vah13 wants to merge 1 commit intoImagick:masterfrom
Open
Fix integer overflow vulnerability in exportImagePixels#775vah13 wants to merge 1 commit intoImagick:masterfrom
vah13 wants to merge 1 commit intoImagick:masterfrom
Conversation
Fixed a critical integer overflow in Imagick::exportImagePixels() that could lead to heap buffer overflow. The vulnerability occurred when calculating pixel buffer size (map_len * width * height) using 32-bit signed integers, which would overflow for large images and result in undersized buffer allocation followed by out-of-bounds memory writes. Changes: - Changed map_size type from int to size_t to handle large values - Added overflow checks before calculating map_size - Added overflow check before memory allocation - Prevents potential heap corruption and RCE exploits The fix validates calculations at each step: 1. Check map_len * width for overflow 2. Check result * height for overflow 3. Check final size * sizeof(type) for overflow
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.
Fixed a critical integer overflow in Imagick::exportImagePixels() that could lead to heap buffer overflow. The vulnerability occurred when calculating pixel buffer size (map_len * width * height) using 32-bit signed integers, which would overflow for large images and result in undersized buffer allocation followed by out-of-bounds memory writes.
Changes:
The fix validates calculations at each step: