CVE-2019-6977
published 2019-01-27CVE-2019-6977: gdImageColorMatch in gd_color_match.c in the GD Graphics Library (aka LibGD) 2.2.5, as used in the imagecolormatch function in PHP before 5.6.40, 7.x before…
PriorityP274high8.8CVSS 3.0
AVNACLPRNUIRSUCHIHAH
EXPLOIT
EPSS
65.12%
99.2th percentile
gdImageColorMatch in gd_color_match.c in the GD Graphics Library (aka LibGD) 2.2.5, as used in the imagecolormatch function in PHP before 5.6.40, 7.x before 7.1.26, 7.2.x before 7.2.14, and 7.3.x before 7.3.1, has a heap-based buffer overflow. This can be exploited by an attacker who is able to trigger imagecolormatch calls with crafted image data.
Affected
12 ranges
| Vendor | Product | Version range | Fixed in |
|---|---|---|---|
| canonical | ubuntu_linux | — | — |
| canonical | ubuntu_linux | — | — |
| canonical | ubuntu_linux | — | — |
| canonical | ubuntu_linux | — | — |
| debian | debian_linux | — | — |
| debian | debian_linux | — | — |
| debian | libgd2 | < libgd2 2.2.5-5.1 (bookworm) | libgd2 2.2.5-5.1 (bookworm) |
| libgd | libgd | — | — |
| php | php | < 5.6.40 | 5.6.40 |
| php | php | — | — |
| php | php | >= 7.0.0 < 7.1.26 | 7.1.26 |
| php | php | >= 7.2.0 < 7.2.14 | 7.2.14 |
Detection & IOCsextracted from sources · hover to see the quote
- →The vulnerability is triggered via PHP's imagecolormatch() function with a crafted second image that has a minimal color palette (e.g., 1-2 colors allocated via imagecolorallocate) while pixel color index values are set out-of-bounds (up to 255), causing a heap OOB write. Monitor PHP applications calling imagecolormatch() with untrusted image input. ↗
- →Exploit proof-of-concept uses a GET/POST parameter 'f' to pass a function pointer address and 'c' to pass an OS command for execution, delivered to a PHP script exposing imagecolormatch(). Look for HTTP requests with hex-formatted pointer values in parameters (e.g., ?f=0x...) alongside a command parameter. ↗
- →The exploit allocates exactly 2 colors (nb_colors=2) in the palette image so that buf size equals 0x50 bytes (2 * 0x28), matching dom_object fastbin size for heap feng shui. Detection of imagecolormatch() calls where the second image has very few colors (1-2) but pixel values reference out-of-range color indices is a strong exploit indicator. ↗
- →The attacker needs to be able to upload a specially crafted image to a PHP script which uses the imagecolormatch() function. Monitor file upload endpoints on PHP applications for palette-mode images (imagecreate) with anomalous pixel color indices exceeding the allocated color count. ↗
- ·Affected PHP versions are: before 5.6.40, 7.x before 7.1.26, 7.2.x before 7.2.14, and 7.3.x before 7.3.1. The exploit was specifically tested on PHP 7.2.12. Detection and patching scope should be validated against the exact PHP version in use. ↗
- ·The exploit is architecture-dependent (heap layout, pointer sizes, fastbin sizes). The PoC targets 64-bit PHP 7.2.x specifically; exploitation reliability on other versions or 32-bit systems may differ significantly. ↗
CVSS provenance
nvdv3.08.8HIGHCVSS:3.0/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
nvdv2.06.8MEDIUMAV:N/AC:M/Au:N/C:P/I:P/A:P
osv8.8HIGH
vendor_debian8.8HIGH
vendor_redhat8.8HIGH
CVEs like this are exactly what “Exploited This Week” covers.
Every Monday: what got weaponized or added to CISA KEV in the last seven days — each CVE cross-linked to its PoC, Nuclei template, and detection rule. Free, one email a week, unsubscribe in one click.
GHSA
GHSA-3jrx-xgc5-h2f9: gdImageColorMatch in gd_color_match
ghsa_unreviewed·2022-05-13
CVE-2019-6977 [HIGH] CWE-787 GHSA-3jrx-xgc5-h2f9: gdImageColorMatch in gd_color_match
gdImageColorMatch in gd_color_match.c in the GD Graphics Library (aka LibGD) 2.2.5, as used in the imagecolormatch function in PHP before 5.6.40, 7.x before 7.1.26, 7.2.x before 7.2.14, and 7.3.x before 7.3.1, has a heap-based buffer overflow. This can be exploited by an attacker who is able to trigger imagecolormatch calls with crafted image data.
OSV
CVE-2019-6977: gdImageColorMatch in gd_color_match
osv·2019-01-27·CVSS 8.8
CVE-2019-6977 [HIGH] CVE-2019-6977: gdImageColorMatch in gd_color_match
gdImageColorMatch in gd_color_match.c in the GD Graphics Library (aka LibGD) 2.2.5, as used in the imagecolormatch function in PHP before 5.6.40, 7.x before 7.1.26, 7.2.x before 7.2.14, and 7.3.x before 7.3.1, has a heap-based buffer overflow. This can be exploited by an attacker who is able to trigger imagecolormatch calls with crafted image data.
Ubuntu
GD vulnerabilities
vendor_ubuntu·2019-02-28
CVE-2019-6977 GD vulnerabilities
Title: GD vulnerabilities
Summary: Several security issues were fixed in GD.
It was discovered that GD incorrectly handled memory when processing
certain images. A remote attacker could use this issue with a specially
crafted image file to cause GD to crash, resulting in a denial of service,
or possibly execute arbitrary code.
Instructions: In general, a standard system update will make all the necessary changes.
Debian
CVE-2019-6977: libgd2 - gdImageColorMatch in gd_color_match.c in the GD Graphics Library (aka LibGD) 2.2...
vendor_debian·2019·CVSS 8.8
CVE-2019-6977 [HIGH] CVE-2019-6977: libgd2 - gdImageColorMatch in gd_color_match.c in the GD Graphics Library (aka LibGD) 2.2...
gdImageColorMatch in gd_color_match.c in the GD Graphics Library (aka LibGD) 2.2.5, as used in the imagecolormatch function in PHP before 5.6.40, 7.x before 7.1.26, 7.2.x before 7.2.14, and 7.3.x before 7.3.1, has a heap-based buffer overflow. This can be exploited by an attacker who is able to trigger imagecolormatch calls with crafted image data.
Scope: local
bookworm: resolved (fixed in 2.2.5-5.1)
bullseye: resolved (fixed in 2.2.5-5.1)
forky: resolved (fixed in 2.2.5-5.1)
sid: resolved (fixed in 2.2.5-5.1)
trixie: resolved (fixed in 2.2.5-5.1)
Red Hat
gd: Heap-based buffer overflow in gdImageColorMatch() in gd_color_match.c
vendor_redhat·2018-12-09·CVSS 8.8
CVE-2019-6977 [HIGH] CWE-122 gd: Heap-based buffer overflow in gdImageColorMatch() in gd_color_match.c
gd: Heap-based buffer overflow in gdImageColorMatch() in gd_color_match.c
gdImageColorMatch in gd_color_match.c in the GD Graphics Library (aka LibGD) 2.2.5, as used in the imagecolormatch function in PHP before 5.6.40, 7.x before 7.1.26, 7.2.x before 7.2.14, and 7.3.x before 7.3.1, has a heap-based buffer overflow. This can be exploited by an attacker who is able to trigger imagecolormatch calls with crafted image data.
Package: gd (Red Hat Enterprise Linux 5) - Will not fix
Package: php (Red Hat Enterprise Linux 5) - Will not fix
Package: php53 (Red Hat Enterprise Linux 5) - Will not fix
Package: gd (Red Hat Enterprise Linux 6) - Will not fix
Package: php (Red Hat Enterprise Linux 6) - Will not fix
Package: gd (Red Hat Enterprise Linux 7) - Not affected
Package: php (Red Hat Ente
No detection rules found.
HackerOne
Apache HTTP [2.4.17-2.4.38] Local Root Privilege Escalation
hackerone·2019-09-11·CVSS 7.8
CVE-2019-0211 [HIGH] Apache HTTP [2.4.17-2.4.38] Local Root Privilege Escalation
Apache HTTP [2.4.17-2.4.38] Local Root Privilege Escalation
Hello,
I reported a Local Root privilege escalation vulnerability on Apache HTTPd at the beginning of the year. Apache has now patched it, [as you can see here](https://httpd.apache.org/security/vulnerabilities_24.html#CVE-2019-0211).
The vulnerability affects mod_prefork, mod_event, and mod_worker, the most used mods on Linux.
Basically, this is an arbitrary function call as root triggered whenever the server gracefully restarts, which is generally once a day.
Here is the article I plan to publish soon, as MarkDown (careful, wall of text):
# Introduction
From version 2.4.17 (Oct 9, 2015) to version 2.4.38 (Apr 1, 2019), Apache HTTP suffers from a local root privilege escalation vulnerability due to an out-of-bounds array acc
Bugzilla
CVE-2019-6977 gd: Heap-based buffer overflow in gdImageColorMatch() in gd_color_match.c
bugzilla·2019-02-04·CVSS 8.8
CVE-2019-6977 [HIGH] CVE-2019-6977 gd: Heap-based buffer overflow in gdImageColorMatch() in gd_color_match.c
CVE-2019-6977 gd: Heap-based buffer overflow in gdImageColorMatch() in gd_color_match.c
gdImageColorMatch in gd_color_match.c in the GD Graphics Library (aka LibGD) 2.2.5, as used in the imagecolormatch function in PHP before 5.6.40, 7.x before 7.1.26, 7.2.x before 7.2.14, and 7.3.x before 7.3.1, has a heap-based buffer overflow. This can be exploited by an attacker who is able to trigger imagecolormatch calls with crafted image data.
Upstream patch:
https://gist.github.com/cmb69/1f36d285eb297ed326f5c821d7aafced
Discussion:
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:
Aff
Bugzilla
CVE-2019-6977 libwmf: gd: heap based buffer overflow in gd_color_match.c:gdImageColorMatch() in libgd as used in imagecolormatch() [fedora-all]
bugzilla·2019-02-04·CVSS 8.8
CVE-2019-6977 [HIGH] CVE-2019-6977 libwmf: gd: heap based buffer overflow in gd_color_match.c:gdImageColorMatch() in libgd as used in imagecolormatch() [fedora-all]
CVE-2019-6977 libwmf: gd: heap based buffer overflow in gd_color_match.c:gdImageColorMatch() in libgd as used in imagecolormatch() [fedora-all]
This is an automatically created tracking bug! It was created to ensure
that one or more security vulnerabilities are fixed in affected versions
of fedora-all.
For comments that are specific to the vulnerability please use bugs filed
against the "Security Response" product referenced in the "Blocks" field.
For more information see:
http://fedoraproject.org/wiki/Security/TrackingBugs
When submitting as an update, use the fedpkg template provided in the next
comment(s). This will include the bug IDs of this tracking bug as well as
the relevant top-level CVE bugs.
Please also mention the CVE IDs being fixed in the RPM changelog and the
fedpkg com
Bugzilla
CVE-2019-6977 gd: heap based buffer overflow in gd_color_match.c:gdImageColorMatch() in libgd as used in imagecolormatch() [fedora-all]
bugzilla·2019-02-04·CVSS 8.8
CVE-2019-6977 [HIGH] CVE-2019-6977 gd: heap based buffer overflow in gd_color_match.c:gdImageColorMatch() in libgd as used in imagecolormatch() [fedora-all]
CVE-2019-6977 gd: heap based buffer overflow in gd_color_match.c:gdImageColorMatch() in libgd as used in imagecolormatch() [fedora-all]
This is an automatically created tracking bug! It was created to ensure
that one or more security vulnerabilities are fixed in affected versions
of fedora-all.
For comments that are specific to the vulnerability please use bugs filed
against the "Security Response" product referenced in the "Blocks" field.
For more information see:
http://fedoraproject.org/wiki/Security/TrackingBugs
When submitting as an update, use the fedpkg template provided in the next
comment(s). This will include the bug IDs of this tracking bug as well as
the relevant top-level CVE bugs.
Please also mention the CVE IDs being fixed in the RPM changelog and the
fedpkg commit mess
Bugzilla
CVE-2019-6977 php: gd: heap based buffer overflow in gd_color_match.c:gdImageColorMatch() in libgd as used in imagecolormatch() [fedora-all]
bugzilla·2019-02-04·CVSS 8.8
CVE-2019-6977 [HIGH] CVE-2019-6977 php: gd: heap based buffer overflow in gd_color_match.c:gdImageColorMatch() in libgd as used in imagecolormatch() [fedora-all]
CVE-2019-6977 php: gd: heap based buffer overflow in gd_color_match.c:gdImageColorMatch() in libgd as used in imagecolormatch() [fedora-all]
This is an automatically created tracking bug! It was created to ensure
that one or more security vulnerabilities are fixed in affected versions
of fedora-all.
For comments that are specific to the vulnerability please use bugs filed
against the "Security Response" product referenced in the "Blocks" field.
For more information see:
http://fedoraproject.org/wiki/Security/TrackingBugs
When submitting as an update, use the fedpkg template provided in the next
comment(s). This will include the bug IDs of this tracking bug as well as
the relevant top-level CVE bugs.
Please also mention the CVE IDs being fixed in the RPM changelog and the
fedpkg commit
http://lists.opensuse.org/opensuse-security-announce/2019-04/msg00025.htmlhttp://lists.opensuse.org/opensuse-security-announce/2019-04/msg00031.htmlhttp://packetstormsecurity.com/files/152459/PHP-7.2-imagecolormatch-Out-Of-Band-Heap-Write.htmlhttp://php.net/ChangeLog-5.phphttp://php.net/ChangeLog-7.phphttp://www.securityfocus.com/bid/106731https://access.redhat.com/errata/RHSA-2019:2519https://access.redhat.com/errata/RHSA-2019:3299https://bugs.php.net/bug.php?id=77270https://lists.debian.org/debian-lts-announce/2019/01/msg00028.htmlhttps://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/3CZ2QADQTKRHTGB2AHD7J4QQNDLBEMM6/https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/3WRUPZVT2MWFUEMVGTRAGDOBHLNMGK5R/https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/TEYUUOW75YD3DENIPYMO263E6NL2NFHI/https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/TTXSLRZI5BCQT3H5KALG3DHUWUMNPDX2/https://security.gentoo.org/glsa/201903-18https://security.netapp.com/advisory/ntap-20190315-0003/https://usn.ubuntu.com/3900-1/https://www.debian.org/security/2019/dsa-4384https://www.exploit-db.com/exploits/46677/http://lists.opensuse.org/opensuse-security-announce/2019-04/msg00025.htmlhttp://lists.opensuse.org/opensuse-security-announce/2019-04/msg00031.htmlhttp://packetstormsecurity.com/files/152459/PHP-7.2-imagecolormatch-Out-Of-Band-Heap-Write.htmlhttp://php.net/ChangeLog-5.phphttp://php.net/ChangeLog-7.phphttp://www.securityfocus.com/bid/106731https://access.redhat.com/errata/RHSA-2019:2519https://access.redhat.com/errata/RHSA-2019:3299https://bugs.php.net/bug.php?id=77270https://lists.debian.org/debian-lts-announce/2019/01/msg00028.htmlhttps://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/3CZ2QADQTKRHTGB2AHD7J4QQNDLBEMM6/https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/3WRUPZVT2MWFUEMVGTRAGDOBHLNMGK5R/https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/TEYUUOW75YD3DENIPYMO263E6NL2NFHI/https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/TTXSLRZI5BCQT3H5KALG3DHUWUMNPDX2/https://security.gentoo.org/glsa/201903-18https://security.netapp.com/advisory/ntap-20190315-0003/https://usn.ubuntu.com/3900-1/https://www.debian.org/security/2019/dsa-4384https://www.exploit-db.com/exploits/46677/
2019-01-27
Published