Bug 1672207 (CVE-2019-6977)
Summary: | CVE-2019-6977 gd: Heap-based buffer overflow in gdImageColorMatch() in gd_color_match.c | ||
---|---|---|---|
Product: | [Other] Security Response | Reporter: | msiddiqu |
Component: | vulnerability | Assignee: | Red Hat Product Security <security-response-team> |
Status: | CLOSED ERRATA | QA Contact: | |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | unspecified | CC: | caillon+fedoraproject, caolanm, databases-maint, hhorak, john.j5live, jorton, mbarnes, panovotn, patalber, rcollet, rhughes, rstrode, sandmann, webstack-team |
Target Milestone: | --- | Keywords: | Security |
Target Release: | --- | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | php 5.6.40, php 7.1.26, php 7.2.14, php 7.3.1 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2019-08-19 08:47:33 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: | |||
Bug Depends On: | 1672209, 1672210, 1672240, 1678101, 1678102, 1678103, 1678104, 1678105, 1678106, 1678107 | ||
Bug Blocks: | 1672246 |
Description
msiddiqu
2019-02-04 09:34:41 UTC
Reference: https://bugs.php.net/bug.php?id=77270 Created gd tracking bugs for this issue: Affects: fedora-all [bug 1672210] Created php tracking bugs for this issue: Affects: fedora-all [bug 1672209] Created libwmf tracking bugs for this issue: Affects: fedora-all [bug 1672240] Analysis: This is essentially a flaw in gdImageColorMatch(), which can be triggered via the PHP API imagecolormatch() [http://php.net/manual/en/function.imagecolormatch.php] The imagecolormatch() takes two gdImagePtr as arguments and compares them. It allocates a buffer based the following: buf = (unsigned long *)safe_emalloc(sizeof(unsigned long), 5 * im2->colorsTotal, 0); Here im2>colorsTotal comes from the second image being compared and therefore is under the controller of the 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. 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. The attacker needs to be able to upload a specially crafted image to a PHP script, which uses the imagecolormatch() function in order to trigger this flaw. Simple way to reproduce from https://gist.github.com/cmb69/1f36d285eb297ed326f5c821d7aafced <?php $img1 = imagecreatetruecolor(0xfff, 0xfff); $img2 = imagecreate(0xfff, 0xfff); imagecolorallocate($img2, 0, 0, 0); imagesetpixel($img2, 0, 0, 255); imagecolormatch($img1, $img2); ?> This issue has been addressed in the following products: Red Hat Software Collections for Red Hat Enterprise Linux 7 Red Hat Software Collections for Red Hat Enterprise Linux 7.4 EUS Red Hat Software Collections for Red Hat Enterprise Linux 7.5 EUS Red Hat Software Collections for Red Hat Enterprise Linux 7.6 EUS Via RHSA-2019:2519 https://access.redhat.com/errata/RHSA-2019:2519 This bug is now closed. Further updates for individual products will be reflected on the CVE page(s): https://access.redhat.com/security/cve/cve-2019-6977 This issue has been addressed in the following products: Red Hat Software Collections for Red Hat Enterprise Linux 7 Red Hat Software Collections for Red Hat Enterprise Linux 7.5 EUS Red Hat Software Collections for Red Hat Enterprise Linux 7.6 EUS Red Hat Software Collections for Red Hat Enterprise Linux 7.7 EUS Via RHSA-2019:3299 https://access.redhat.com/errata/RHSA-2019:3299 This issue has been addressed in the following products: Red Hat Enterprise Linux 8 Via RHSA-2020:4659 https://access.redhat.com/errata/RHSA-2020:4659 |