|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-12-09 09:34 UTC] stas@php.net
[2018-12-09 12:04 UTC] cmb@php.net
-Assigned To:
+Assigned To: cmb
[2018-12-09 12:04 UTC] cmb@php.net
[2018-12-09 23:05 UTC] sscannell at ripstech dot com
[2018-12-11 18:13 UTC] cmb@php.net
-Status: Assigned
+Status: Verified
[2018-12-11 18:13 UTC] cmb@php.net
[2018-12-30 02:56 UTC] stas@php.net
[2018-12-30 13:13 UTC] cmb@php.net
-Assigned To: cmb
+Assigned To: stas
[2018-12-30 13:13 UTC] cmb@php.net
[2019-01-03 06:26 UTC] stas@php.net
[2019-01-07 08:10 UTC] stas@php.net
[2019-01-07 08:10 UTC] stas@php.net
-Status: Verified
+Status: Closed
[2019-01-07 08:19 UTC] stas@php.net
[2019-01-07 08:19 UTC] stas@php.net
[2019-01-07 08:20 UTC] stas@php.net
[2019-01-07 08:20 UTC] stas@php.net
[2019-01-07 08:20 UTC] stas@php.net
[2019-01-07 08:20 UTC] stas@php.net
[2019-01-07 08:21 UTC] stas@php.net
[2019-01-07 08:21 UTC] stas@php.net
[2019-01-07 13:17 UTC] cmb@php.net
[2019-01-27 18:07 UTC] sscannell at ripstech dot com
[2019-01-27 19:00 UTC] kaplan@php.net
-CVE-ID:
+CVE-ID: 2019-6977
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 09:00:01 2025 UTC |
Description: ------------ It is possible to write up to 1200 bytes over the boundaries of a buffer allocated in the imagecolormatch function, which then calls gdImageColorMatch() The function takes two gdImagePtr as arguments and wants to compare both of them. It then allocates a dynamic buffer with the following calculation: buf = (unsigned long *)safe_emalloc(sizeof(unsigned long), 5 * im2->colorsTotal, 0); im2->colorsTotal is under the control of an attacker. By simply allocating only one color to the second image, the calculation becomes sizeof(unsigned long) (8 byte on a 64 bit system) * 5 * 1, which results in a buffer of 40 bytes. The buffer is then written to in a for loop. for (x=0; x<im1->sx; x++) { for( y=0; y<im1->sy; y++ ) { color = im2->pixels[y][x]; rgb = im1->tpixels[y][x]; bp = buf + (color * 5); (*(bp++))++; *(bp++) += gdTrueColorGetRed(rgb); *(bp++) += gdTrueColorGetGreen(rgb); *(bp++) += gdTrueColorGetBlue(rgb); *(bp++) += gdTrueColorGetAlpha(rgb); } The buffer is written to by means of a color being the index: color = im2->pixels[y][x]; .. bp = buf + (color * 5); However, an attacker can set the value of color to be at maximum 255 (since it is a char). This would result in bp pointing at buffer + 1275 bytes. Since buffer is only 40 bytes big, this leads to an out of bounds write with data that is also under the control of the attacker. Test script: --------------- <?php $img1 = imagecreatetruecolor(0xfff, 0xfff); $img2 = imagecreate(0xfff, 0xfff); imagecolorallocate($img2, 0, 0, 0); imagesetpixel($img2, 0, 0, 255); imagecolormatch($img1, $img2);