-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Two Integer Overflow bugs in image.cxx #471
Comments
#471) All images are now limited to 4GiB of memory usage (37837x37837 pixels).
I wasn't able to reproduce the issue with poc2, but I added range checks to the JPEG and PNG load functions to limit images to <4GiB - a little lazy but for the intended usage I don't see a problem limiting images like this. [master 31f7804] Fix a potential integer overflow bug in the JPEG and PNG loaders (Issue #471) |
Oh, I‘m sorry, this is the correct poc2 file: I forgot to modify the html file in the above poc2 file.
|
Re-confirmed that the changes I pushed also address this test file. |
Currently tracked as |
@BrianInglis a release was done a few days ago. Please refamiliarize yourself with the license terms of this free software that comes with no warranties or guarantees of any kind! |
Hi, there is two integer overflow bugs in the latest version of htmldoc.
They are similar to CVE-2021-20308.
os: ubuntu 20.04
version: 1.9.16(the latest)
First
First, in image_load_jpeg function, image.cxx.
When it calls malloc,'img->width' and 'img->height' are enough large to cause an integer overflow
So, the malloc function may return a heap block smaller than the expected size, and it will cause a buffer overflow/Address boundary error in the jpeg_read_scanlines function.
htmldoc/htmldoc/image.cxx
Lines 1390 to 1395 in cb4cdee
htmldoc/htmldoc/image.cxx
Lines 1452 to 1466 in cb4cdee
Asan report:
And this is the poc file:
poc1.zip
Second
There is another integer overflow bug in image_load_png function, image.cxx, similar to the first one.
htmldoc/htmldoc/image.cxx
Lines 1631 to 1647 in cb4cdee
It calls calloc to get heap block.
However, the width and height of the png file are both four bytes long, so 'img->width' and 'img->height' are enough large to cause an integer overflow.
The calloc function may return a heap block smaller than the expected size, and finally cause a heap overflow in the png_read_rows function when memcpy.
This is the Asan report:
And this is the poc file:
poc2.zip
(wrong poc)
This is the correct poc:
real_poc2.zip
The text was updated successfully, but these errors were encountered: