Critical Double Free Vulnerability in GD Package: Remote Code Execution Risk

gd Updated 02 Oct 2025

Summary

20/08/2018
N/A
Yes i
High
8.8

ALPINE-CVE-2018-1000222: Libgd version 2.2.5 contains a Double Free Vulnerability vulnerability in gdImageBmpPtr Function that can result in Remote Code Execution . Affects gd versions < 2.2.5-r1. Fixed in 2.2.5-r1. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

The GD package is a widely used library for the dynamic creation of images in various formats, including PNG, JPEG, and GIF. It is commonly utilized in web applications for image processing tasks. The library provides developers with the ability to manipulate images on the server side, making it an essential tool for many PHP applications. However, a critical vulnerability has been identified in version 2.2.5, which could allow attackers to exploit the library through specially crafted JPEG images.

Vulnerability Detail

Libgd version 2.2.5 contains a Double Free Vulnerability in the gdImageBmpPtr function. This vulnerability can lead to Remote Code Execution (RCE), allowing an attacker to execute arbitrary code on the server. The issue arises from improper memory management, where the same memory is freed multiple times, potentially leading to exploitation. The vulnerability was introduced in earlier versions and has been fixed in subsequent releases after commit ac16bdf2d41724b5a65255d4c28fb0ec46bc42f5.

How To Fix

Minimum fixed version

2.2.5-r1

This is the first release that contains the fix.

sudo apk add --upgrade gd

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If an immediate update is not feasible, consider disabling image processing features that utilize the GD library until the patch can be applied. This may involve modifying your application code to bypass image handling functionalities temporarily.

Conclusion

The identified double free vulnerability in the GD package poses a significant risk of remote code execution. It is crucial for developers to update to the patched version 2.2.5-r1 to mitigate this risk. Additionally, utilizing tools like Vulert can help in monitoring and managing vulnerabilities in open-source software effectively.

See every vulnerability recorded for gd →

Share this vulnerability

FAQ

The CVSS score for this vulnerability is 8.8, indicating a high severity level.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without requiring any signup.

If exploited, this vulnerability could allow an attacker to execute arbitrary code on the server, potentially leading to data breaches or complete system compromise.

Yes, Vulert can monitor and alert you in real-time for open-source vulnerabilities in your software using just a manifest file like package-lock.json.

If an immediate update is not possible, consider disabling features that rely on the GD library until you can apply the patch.

Related vulnerabilities

Recent vulnerabilities recorded for gd.

How To Fix

Minimum fixed version

2.2.5-r1

This is the first release that contains the fix.

sudo apk add --upgrade gd

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback