-
Notifications
You must be signed in to change notification settings - Fork 630
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
pngimage: heap-buffer-overflow in ./pngimage.c:1249 in compare_read #481
Comments
I confirm the vulnerability that you reported, and I will develop a fix. @gandalf4a, it is not required, but it would be appreciated if I may please know your real-world name. Alternatively, I can credit your discovery at the bottom of the commit message, as follows, if that's ok with you:
|
On a second thought, considering that (Unless @jbowler steps in ASAP with a fix...) The crash occurs at The crashing POC test case confirms my hypothesis. The POC image width is 32, and everything works fine for the first half, i.e. for the first 16 iterations. The crash occurs after
|
The code is comparing bytes, not pixels; it's memcmp but with sigbits factored in. Look at line 1222 which converts bits-per-pixel into bytes-per-pixel. makepng.c in the same directory was made uncompilable by commit e2bb5e7 and that commit also contains quite a lot of similar changes to pngimage.c. @gandalf4a can you verify that the bug existed in b50d5ce (i.e. 1.6.24)? |
pngimage fails in both HEAD and libpng-1.6.24-signed on that file, but it is a regular failure at line 24 (IRC how to decode the error message). I don't know if either version has out-of-bounds error. The file does have an sBIT chunk with a value of '4', which is clearly spurious so the most likely explanation is that pngimage can't handle an image where sBIT==depth; so what? It's more interesting if it is a bug in libpng, but I doubt that. |
The sBIT/SHIFT code was backported from 1.7 and never gets invoked in 1.6. The original path did, indeed, use memcmp on 'rowbytes', the other (else) path should be using rowbytes too but the error message tries to output a pixel coordinate. contrib/pngsuite contains basn3p02 and basn3p04 with sBIT but those are palette images so use the memcmp branch. The attached patch is simple, safe and keeps the format of the error message. |
This issue should be closed; the original reporter has dropped the ball. |
from:https://github.com/gandalf4a/crash_report/blob/main/libpng/pngimage/bufferoverflow_compareread.md
Summary
There is a buffer overflow in ./pngimage.c:1249 in compare_read.
Remote attackers could leverage this vulnerability to cause a denial-of-service via a crafted PNG file.
Version
Platform
ASAN_heap-buffer-overflow
Steps to reproduce
POC File
poc_png_overflow
Credit
The text was updated successfully, but these errors were encountered: