Description
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.
Fixed in Linux distributions
Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.
Debian
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Debian 14 | libgd2 | 2.2.5-5.1 | — |
| Debian 13 | libgd2 | 2.2.5-5.1 | — |
| Debian 12 | libgd2 | 2.2.5-5.1 | — |
| Debian 9 | libgd2 | 2.2.4-2+deb9u4 | DSA-4384-1 |
| Debian 8 | libgd2 | 2.1.0-5+deb8u12 | DLA-1651-1 |
| Debian 8 | php5 | 5.6.40+dfsg-0+deb8u1 | DLA-1679-1 |
Ubuntu
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Ubuntu 18.04 LTS | libgd2 | 2.2.5-4ubuntu0.3 | USN-3900-1 |
| Ubuntu 16.04 LTS | libgd2 | 2.1.1-4ubuntu0.16.04.11 | USN-3900-1 |
| Ubuntu 14.04 LTS | libgd2 | 2.1.0-3ubuntu0.11 | USN-3900-1 |
Red Hat
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| RHEL 8 | gd +1 | 2.2.5-7.el8 | RHSA-2020:4659 |
| RHEL 3 | rh-php71-php +27 | 7.1.30-1.el7 | RHSA-2019:2519 |
| RHEL 3 | rh-php72-php +27 | 7.2.24-1.el7 | RHSA-2019:3299 |
AlmaLinux
Errata ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| AlmaLinux 8 | gd +1 | 2.2.5-7.el8 | ALSA-2020:4659 |
Rocky Linux
Errata ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Rocky Linux 8 | gd | 2.2.5-7.el8 | RLSA-2020:4659 |
SUSE
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| SLES 15 | gd | 2.2.5-4.6.1 | SUSE-SU-2019:0771-1 |
| SLES 12 SP4 | gd | 2.1.0-24.12.1 | SUSE-SU-2019:0747-1 |
| SLES 12 SP4 | php5 | 5.5.14-109.48.1 | SUSE-SU-2019:0449-1 |
| SLES 12 SP4 | php7 | 7.0.7-50.63.1 | SUSE-SU-2019:0333-1 |
| SLES 12 SP3 | gd | 2.1.0-24.12.1 | SUSE-SU-2019:0747-1 |
| SLES 12 SP3 | php5 | 5.5.14-109.48.1 | SUSE-SU-2019:0449-1 |
| SLES 12 SP3 | php7 | 7.0.7-50.63.1 | SUSE-SU-2019:0333-1 |
| SLES 12 | php5 | 5.5.14-109.48.1 | SUSE-SU-2019:0449-1 |
| SLES 12 | php7 | 7.0.7-50.63.1 | SUSE-SU-2019:0333-1 |
| SLES 11 SP4 | php53 | 5.3.17-112.53.1 | SUSE-SU-2019:13961-1 |
Show 3 more (older releases, extended support, other products)Fewer releases
| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| SLES for SAP 12 SP4 | gd | 2.1.0-24.12.1 | SUSE-SU-2019:0747-1 |
| SLES for SAP 12 SP3 | gd | 2.1.0-24.12.1 | SUSE-SU-2019:0747-1 |
| SLES for SAP 11 SP4 | php53 | 5.3.17-112.53.1 | SUSE-SU-2019:13961-1 |
openSUSE
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| openSUSE Tumbleweed | gd | 2.3.3-1.1 | openSUSE-SU-2024:10777-1 |
| openSUSE Tumbleweed | perl-GD | 2.76-1.1 | openSUSE-SU-2024:11852-1 |
| openSUSE Leap 15.0 | gd | 2.2.5-lp150.8.1 | openSUSE-SU-2019:1148-1 |
Alpine
Security tracker ↗| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Alpine v3.24 | gd | 2.2.5-r2 | — |
| Alpine v3.23 | gd | 2.2.5-r2 | — |
| Alpine v3.22 | gd | 2.2.5-r2 | — |
| Alpine v3.21 | gd | 2.2.5-r2 | — |
| Alpine v3.20 | gd | 2.2.5-r2 | — |
Show 14 more (older releases, extended support, other products)Fewer releases
| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Alpine v3.19 | gd | 2.2.5-r2 | — |
| Alpine v3.18 | gd | 2.2.5-r2 | — |
| Alpine v3.17 | gd | 2.2.5-r2 | — |
| Alpine v3.16 | gd | 2.2.5-r2 | — |
| Alpine v3.15 | gd | 2.2.5-r2 | — |
| Alpine v3.14 | gd | 2.2.5-r2 | — |
| Alpine v3.13 | gd | 2.2.5-r2 | — |
| Alpine v3.12 | gd | 2.2.5-r2 | — |
| Alpine v3.11 | gd | 2.2.5-r2 | — |
| Alpine v3.10 | gd | 2.2.5-r2 | — |
| Alpine v3.9 | gd | 2.2.5-r2 | — |
| Alpine v3.8 | gd | 2.2.5-r2 | — |
| Alpine v3.7 | gd | 2.2.5-r2 | — |
| Alpine v3.7 | php7 | 7.1.29-r0 | — |
| Alpine v3.6 | gd | 2.2.5-r2 | — |
Oracle Linux
| Release | Package | Fixed in | Advisory |
|---|---|---|---|
| Oracle Linux 8 | gd +1 | 2.2.5-7.el8 | ELSA-2020-4659 |
Public exploits
Exploit or proof-of-concept code for this vulnerability is publicly available, which lowers the bar for attackers. Treat it as a reason to patch sooner.
Exploit-DB 1
- PHP 7.2 - 'imagecolormatch()' Out of Band Heap Write EDB-46677 · remote · Feb 27, 2019
GitHub 1 repository
-
HORKimhab/CVE-2022-31626-CVE-2024-2961-CVE-2019-6977 ★ 0 · Aug 6, 2026
CVE-2022-31626, CVE-2024-2961, CVE-2019-6977, PHP security research
Sources: PoC-in-GitHub, Metasploit Framework, Exploit-DB — updated daily. Only links are listed; no exploit code is hosted here.
Advisories 18
- ALSA-2020:4659 Moderate: gd security update AlmaLinux Security Advisories · Oct 29, 2026
- RHSA-2020:4659 Red Hat Security Advisory: gd security update Red Hat Security Advisories (RHSA) · Jun 29, 2026
- RHSA-2019:3299 Red Hat Security Advisory: rh-php72-php security update Red Hat Security Advisories (RHSA) · Jun 29, 2026
- RHSA-2019:2519 Red Hat Security Advisory: rh-php71-php security, bug fix, and enhancement update Red Hat Security Advisories (RHSA) · Jun 29, 2026
- USN-3900-1 libgd2 vulnerabilities Ubuntu Security Notices (USN) · Apr 22, 2026
- DSA-4384-1 libgd2 - security update Debian Security (DSA / DLA) · Mar 9, 2026
- DLA-1679-1 php5 - security update Debian Security (DSA / DLA) · Mar 9, 2026
- DLA-1651-1 libgd2 - security update Debian Security (DSA / DLA) · Mar 9, 2026
- RLSA-2020:4659 Moderate: gd security update Rocky Linux Security Advisories · Feb 5, 2026
- SUSE-SU-2019:13961-1 Security update for php53 SUSE / openSUSE Security Updates · Feb 4, 2026
- SUSE-SU-2019:0771-1 Security update for gd SUSE / openSUSE Security Updates · Feb 4, 2026
- SUSE-SU-2019:0747-1 Security update for gd SUSE / openSUSE Security Updates · Feb 4, 2026
- openSUSE-SU-2024:11852-1 perl-GD-2.76-1.1 on GA media SUSE / openSUSE Security Updates · Feb 4, 2026
- SUSE-SU-2019:0333-1 Security update for php7 SUSE / openSUSE Security Updates · Feb 4, 2026
- openSUSE-SU-2019:1148-1 Security update for gd SUSE / openSUSE Security Updates · Feb 4, 2026
- SUSE-SU-2019:0449-1 Security update for php5 SUSE / openSUSE Security Updates · Feb 4, 2026
- openSUSE-SU-2024:10777-1 gd-2.3.3-1.1 on GA media SUSE / openSUSE Security Updates · Feb 4, 2026
- ELSA-2020-4659 Moderate: gd security update (Oracle Linux 8) Oracle Linux Security Advisories (ELSA) · Nov 10, 2020
References
- 106731 vdb-entry
- https://security.netapp.com/advisory/ntap-20190315-0003/
- http://php.net/ChangeLog-5.php
- http://php.net/ChangeLog-7.php
- USN-3900-1 vendor-advisory
- [debian-lts-announce] 20190130 [SECURITY] [DLA 1651-1] libgd2 security update mailing-list
- https://bugs.php.net/bug.php?id=77270
- DSA-4384 vendor-advisory
- GLSA-201903-18 vendor-advisory
- openSUSE-SU-2019:1148 vendor-advisory
- openSUSE-SU-2019:1140 vendor-advisory
- 46677 exploit
- http://packetstormsecurity.com/files/152459/PHP-7.2-imagecolormatch-Out-Of-Band-Heap-Write.html
- RHSA-2019:2519 vendor-advisory
- RHSA-2019:3299 vendor-advisory
- FEDORA-2019-ab7d22a466 vendor-advisory
- FEDORA-2019-d7f8995451 vendor-advisory
- FEDORA-2019-7a06c0e6b4 vendor-advisory
- FEDORA-2020-e795f92d79 vendor-advisory