libjpeg-turbo: DoS via small Image with large Dimensions
Categories
(Core :: Graphics: ImageLib, defect, P3)
Tracking
()
People
(Reporter: jaas, Unassigned)
References
Details
(Keywords: csectype-dos, sec-low, Whiteboard: [gfx-noted])
Attachments
(1 file)
3.58 KB,
text/x-csrc
|
Details |
Updated•9 years ago
|
Updated•9 years ago
|
Updated•8 years ago
|
Updated•7 years ago
|
Comment 7•5 years ago
|
||
Note that this issue is - AFAICT - unaddressed in the standard (or libjpegturbo, based on the lack of consensus about how to proceed.) https://libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf was authored to draw attention to this issue.
Updated•5 years ago
|
Updated•2 years ago
|
Comment 8•2 years ago
|
||
In the process of migrating remaining bugs to the new severity system, the severity for this bug cannot be automatically determined. Please retriage this bug using the new severity system.
Whereas Issue #1252196 is an exploit involving relatively tiny progressive JPEG images (both valid and invalid) with unreasonable numbers of scans, this issue is an exploit involving relatively tiny progressive JPEG images with an unreasonable image size. The JPEG format has 16-bit width and height fields, so images can be up to 4 gigapixels (64k x 64k) in size. When decompressing a multi-scan JPEG image, libjpeg[-turbo] must allocate a "whole-image buffer" in order to render each successive scan on top of the previously-decompressed scan. (It does this within the body of jpeg_start_decompress().) Thus, a tiny invalid progressive JPEG image can be generated that causes libjpeg[-turbo] to allocate a 4-gigapixel x 32-bit whole-image buffer. libjpeg[-turbo] encounters junk data in the invalid image and throws a warning, but since libjpeg API warnings aren't fatal by default, it continues trying to decompress the image, leading to memory exhaustion. The attack surface can be greatly reduced by making libjpeg API warnings fatal. (djpeg in libjpeg-turbo 2.1.x has a -strict argument that demonstrates how to do that.) However, it is still possible to craft a perfectly valid 2 MB JPEG image that requires gigabytes of memory to decompress, by taking advantage of the same "EOB run" feature that was exploited in Issue #1252196 (more specifically, the ability of the progressive JPEG format to represent large runs of zeroes using a very small amount of data.) As with Issue #1252196, the exploit can be greatly diminished by making libjpeg API warnings fatal, but the only way to completely eliminate it is to place a reasonable limit on the JPEG image dimensions or to place a limit on the amount of memory used by libjpeg-turbo. (Refer to the -maxmemory switch in djpeg.)
Updated•2 years ago
|
Comment 10•2 years ago
|
||
Filed bug 1823614 to give us a finite limit on the number of scans. Not sure if there are more/separate problems here from that.
Description
•