CVE-2016-10166
Critical · 9.8CVSS
9.8
EPSS
10.7%
Published
Mar 15, 2017
CISA due date
—
Cloudanix analysis
A flaw in a common graphics library lets attackers potentially take over computers by sending specially made image files.
- Exploitation
- Remote Unauthenticated
- Attacker needs
- None
- Complexity
- Low
- Impact
- Remote Code Execution
- Component
- Library
- Class
- Memory Corruption
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
Integer underflow in _gdContributionsAlloc in gd_interpolation.c allows remote attackers to trigger memory corruption via crafted image data that decrements the u variable below zero.
Why it matters to the business
Enables remote compromise of systems that process user-supplied images through libgd, risking data exposure, service outages, or full system takeover in web servers and applications across many Linux distributions.
How an attack unfolds
An attacker supplies a malicious image to any application linked against a vulnerable libgd build; the image triggers the integer underflow during interpolation, corrupting heap memory that an attacker can then leverage for arbitrary code execution.
How to fix it
Upgrade libgd to 2.2.4 or newer. Apply the exact package updates listed for each distribution: Debian 11/12/13 to 4.9.30-1; Ubuntu 14.04 LTS kernels to 3.13.0-129.178 or 4.4.0-83.106~14.04.1 variants; Ubuntu 16.04 LTS kernels to 4.4.0-83.106, 4.4.0-1022.31, 4.11.0-1009.9, 4.10.0-33.37~16.04.1, 4.13.0-1008.9, 4.4.0-1061.69 or 4.4.0-1063.68 as applicable.
How to confirm the fix worked
Confirm installed libgd version reports 2.2.4 or later; verify package manager output matches the fixed versions for the running distribution and kernel; re-test image-processing code paths with known-good inputs.
Typical attack path
- Deliver crafted image file to a network service that invokes libgd image functions
- Trigger _gdContributionsAlloc with input that causes u to underflow
- Achieve memory corruption leading to control-flow hijacking or data leakage
How to detect it
Review web-server and application logs for crashes or segmentation faults during image handling; monitor process memory usage anomalies around libgd-linked binaries; search historic logs for unexpected terminations of services that call gd interpolation routines.
What your security team should do
- Immediately apply the distribution-specific package updates listed in remediation guidance
- Inventory all systems using libgd and prioritize those reachable from untrusted image sources
- Disable image-processing features that rely on libgd until patches are deployed where feasible
The record
Integer underflow in the _gdContributionsAlloc function in gd_interpolation.c in the GD Graphics Library (aka libgd) before 2.2.4 allows remote attackers to have unspecified impact via vectors related to decrementing the u variable.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| Alpine:v3.3 | gd | 0 | 2.2.4-r0 |
| Alpine:v3.4 | gd | 0 | 2.2.4-r0 |
| Alpine:v3.5 | gd | 0 | 2.2.4-r0 |
| Alpine:v3.5 | php5 | 0 | 5.6.40-r0 |
| Debian:11 | libgd2 | 0 | 2.2.4-1 |
| Debian:12 | libgd2 | 0 | 2.2.4-1 |
| Debian:13 | libgd2 | 0 | 2.2.4-1 |
| Debian:14 | libgd2 | 0 | 2.2.4-1 |
| Debian:8 | libgd2 | 0 | 2.1.0-5+deb8u9 |
| Mageia:5 | libgd | 0 | 2.2.4-1.1.mga5 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-bcmath | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-cli | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-common | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-dba | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-dbg | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-debuginfo | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-devel | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-embedded | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-enchant | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-fpm | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-gd | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-gmp | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-intl | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-json | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-ldap | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-mbstring | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-mysqlnd | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-odbc | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-opcache | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-pdo | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-pgsql | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-process | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-pspell | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-recode | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-snmp | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-soap | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-xml | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-xmlrpc | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php71-php-zip | 0 | 0:7.1.30-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-bcmath | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-cli | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-common | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-dba | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-dbg | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-debuginfo | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-devel | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-embedded | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-enchant | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-fpm | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-gd | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-gmp | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-intl | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-json | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-ldap | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-mbstring | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-mysqlnd | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-odbc | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-opcache | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-pdo | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-pgsql | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-process | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-pspell | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-recode | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-snmp | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-soap | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-xml | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-xmlrpc | 0 | 0:7.2.24-1.el7 |
| Red Hat:rhel_software_collections:3::el7 | rh-php72-php-zip | 0 | 0:7.2.24-1.el7 |
| SUSE:Linux Enterprise Desktop 12 SP1 | gd | 0 | 2.1.0-23.1 |
| SUSE:Linux Enterprise Desktop 12 SP2 | gd | 0 | 2.1.0-23.1 |
| SUSE:Linux Enterprise Module for Web and Scripting 12 | php5 | 0 | 5.5.14-96.1 |
| SUSE:Linux Enterprise Module for Web and Scripting 12 | php7 | 0 | 7.0.7-35.1 |
| SUSE:Linux Enterprise Point of Sale 11 SP3 | php53 | 0 | 5.3.17-101.1 |
| SUSE:Linux Enterprise Server 11 SP3-LTSS | php53 | 0 | 5.3.17-101.1 |
| SUSE:Linux Enterprise Server 11 SP3-TERADATA | php53 | 0 | 5.3.17-101.1 |
| SUSE:Linux Enterprise Server 11 SP4 | php53 | 0 | 5.3.17-101.1 |
| SUSE:Linux Enterprise Server 12 SP1 | gd | 0 | 2.1.0-23.1 |
| SUSE:Linux Enterprise Server 12 SP2 | gd | 0 | 2.1.0-23.1 |
| SUSE:Linux Enterprise Server for Raspberry Pi 12 SP2 | gd | 0 | 2.1.0-23.1 |
| SUSE:Linux Enterprise Server for SAP Applications 11 SP4 | php53 | 0 | 5.3.17-101.1 |
| SUSE:Linux Enterprise Server for SAP Applications 12 SP1 | gd | 0 | 2.1.0-23.1 |
| SUSE:Linux Enterprise Server for SAP Applications 12 SP2 | gd | 0 | 2.1.0-23.1 |
| SUSE:Linux Enterprise Software Development Kit 11 SP4 | php53 | 0 | 5.3.17-101.1 |
| SUSE:Linux Enterprise Software Development Kit 12 SP1 | gd | 0 | 2.1.0-23.1 |
| SUSE:Linux Enterprise Software Development Kit 12 SP1 | php5 | 0 | 5.5.14-96.1 |
| SUSE:Linux Enterprise Software Development Kit 12 SP1 | php7 | 0 | 7.0.7-35.1 |
| SUSE:Linux Enterprise Software Development Kit 12 SP2 | gd | 0 | 2.1.0-23.1 |
| SUSE:Linux Enterprise Software Development Kit 12 SP2 | php5 | 0 | 5.5.14-96.1 |
| SUSE:Linux Enterprise Software Development Kit 12 SP2 | php7 | 0 | 7.0.7-35.1 |
| SUSE:Linux Enterprise Workstation Extension 12 SP1 | gd | 0 | 2.1.0-23.1 |
| SUSE:Linux Enterprise Workstation Extension 12 SP2 | gd | 0 | 2.1.0-23.1 |
| SUSE:Manager 2.1 | php53 | 0 | 5.3.17-101.1 |
| SUSE:Manager Proxy 2.1 | php53 | 0 | 5.3.17-101.1 |
| SUSE:OpenStack Cloud 5 | php53 | 0 | 5.3.17-101.1 |
| Ubuntu:14.04:LTS | libgd2 | 0 | 2.1.0-3ubuntu0.6 |
| Ubuntu:16.04:LTS | libgd2 | 0 | 2.1.1-4ubuntu0.16.04.6 |
| openSUSE:Tumbleweed | gd | 0 | 2.3.3-1.1 |
Related vulnerabilities
- CVE-2016-3074 Integer signedness error in GD Graphics Library 2.1.1 (aka libgd or libgd2) allows remote… Also affects gd
- CVE-2017-6362 Double free vulnerability in the gdImagePngPtr function in libgd2 before 2.2.5 allows… Also affects gd
- CVE-2017-7890 The GIF decoding function gdImageCreateFromGifCtx in gd_gif_in.c in the GD Graphics… Also affects gd
- CVE-2016-6132 The gdImageCreateFromTgaCtx function in the GD Graphics Library (aka libgd) before 2.2.3… Also affects gd
- CVE-2016-6911 The dynamicGetbuf function in the GD Graphics Library (aka libgd) before 2.2.4 allows… Also affects libgd2
- CVE-2013-7456 gd_interpolation.c in the GD Graphics Library (aka libgd) before 2.1.1, as used in PHP… Also affects libgd2
- CVE-2014-9709 The GetCode_ function in gd_gif_in.c in GD 2.1.1 and earlier, as used in PHP before… Also affects libgd2
- CVE-2014-2497 The gdImageCreateFromXpm function in gdxpm.c in libgd, as used in PHP 5.4.26 and earlier… Also affects libgd2