-
Notifications
You must be signed in to change notification settings - Fork 636
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
A possible overflow in png_progressive_combine_row followed by png_read_png #455
Comments
This is the full trigger case, the overflow will be triggered if this file was compiled and linked with AddressSanitizer (add '-fsanitize=address' flag).
|
Hi @hopper-vul , I saw that you found another possible bug described in the issue #454 , did you improve the fuzzer or just created a custom one? Maybe the current could be improved that to your suggestions Thanks |
@thealberto Yes, we have created a custom one. Briefly speaking, the created fuzzer could automatically synthesizes programs from library headers (e.g. API declarations) and then links and interprets them to execute. We have spent a lot efforts to infer API relations, constraints and usages, and designed an IR to represent, interpret and execute the generated programs. Now, the fuzzer is still under development. |
@hopper-vul , Any idea regarding that? Thanks |
@thealberto Nevertheless, we are going to write and public some technical papers about it, so that more people will be learned how to build an nicer library fuzzer. What i can do now is picking the reliable/credible crashes from the output of the fuzzer, and help you or communities to fix them. best regards |
Good news, our team woould like to open source the fuzzer tool after this tool was completed. At that time, it was possible to integrate it to libpng and more projects. |
@hopper-vul Thanks for all |
As the original report says quite clearly this is an application bug; the application deliberately calls png_progressive_combine_row with a buffer that is too small! This is not a libpng bug; in fact the overwrite happens in memcpy, which is a standard library routine! The test case needs to include <stdint.h> In addition the sequential and progressive readers are incompatible and, anyway, png_read_png does the interlace handling. I find it almost impossible to believe that a real app developer would actually make mistakes like this. Apart from that it is up to the caller of png_progressive_combine_row to make sure that the 'old_row' and 'new_row' pointers actually match the current state of the (progressive) read engine. To rewrite the code to make the bug more clear:
'new_row' is ignored; technically it should be png_ptr->row_buf+1, the 'new' row of pixels set up by the progressive reader, but it's just checked for being non-null. The code is clearly bogus:
As the documentation says it just does a memcpy of 32 bytes in a buffer the size of v24_tmp; 26 bytes.... |
No response since June; @ctruta, please close. |
Hi,
when fuzzing libpng, we found
png_progressive_combine_row()
could be crashed if it is called afterpng_read_png()
.In
png_read_png
,it calls
png_read_info(png_ptr,..)
->png_handle_IHDR(png_ptr,..)
to read bytes (exactly 13 bytes) form png io to get a IDHR chunk.If the png io is initialized with a file beforehand, the bytes will read from this file and set the read IDHR information into
png_ptr
, such aspng_ptr->width
.Then,
If
png_progressive_combine_row(png_ptr, old_row, ..)
is called currently and the length ofold_row
smaller thanpng_ptr->width
, and if we can change the contents of the input file, an overflow ofold_row
will happen in the inner ofpng_progressive_combine_row
at this statement:memcpy(dp, sp, PNG_ROWBYTES(pixel_depth, row_width))
where
dp
isold_row
and the copy length ispng_ptr->width
.e.g.
The text was updated successfully, but these errors were encountered: