Skip to main content
Vulnerability Database/CVE-2025-52994

CVE-2025-52994: phpThumb gif_outputAsJpeg RCE Vulnerability

CVE-2025-52994 is a remote code execution vulnerability in phpThumb that allows OS command injection through the gif_outputAsJpeg function. This article covers technical details, affected versions, and mitigation.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2025-52994 Overview

CVE-2025-52994 is an OS command injection vulnerability in phpThumb versions through 1.7.23. The flaw resides in the gif_outputAsJpeg function within phpthumb.gif.php, which passes user-controlled file name parameters directly to the exec() call without sanitization. An authenticated attacker can inject shell metacharacters through crafted parameter values to execute arbitrary operating system commands on the underlying host. The issue is classified under [CWE-78] Improper Neutralization of Special Elements used in an OS Command. The maintainer JamesHeinrich addressed the vulnerability in release 1.7.23-202506081709.

Critical Impact

Attackers with low privileges can achieve arbitrary command execution on servers running vulnerable phpThumb deployments, potentially leading to web shell placement, data theft, or lateral movement.

Affected Products

  • phpThumb versions up to and including 1.7.23
  • The phpthumb.gif.php component (gif_outputAsJpeg function)
  • Fixed in phpThumb release 1.7.23-202506081709

Discovery Timeline

  • 2025-07-11 - CVE-2025-52994 published to the National Vulnerability Database
  • 2026-06-17 - Last updated in the NVD database

Technical Details for CVE-2025-52994

Vulnerability Analysis

phpThumb is a widely deployed PHP thumbnail generation library. The gif_outputAsJpeg function in phpthumb.gif.php converts GIF images to JPEG format by invoking the external cjpeg binary through PHP's exec() function. The vulnerable code passes a file name variable directly into the shell command string without escaping. When an attacker controls the file name value via HTTP request parameters, they can inject arbitrary shell metacharacters. The injected payload runs in the context of the web server user, giving attackers a foothold to install web shells, exfiltrate database credentials, or pivot to internal systems.

Root Cause

The root cause is missing shell argument escaping when constructing the cjpeg command. The original implementation concatenates $lpszFileName directly into the command string, allowing characters such as ;, |, &, and backticks to break out of the intended argument and execute additional commands.

Attack Vector

Exploitation requires network access to a phpThumb endpoint and the ability to influence the file name parameter passed to gif_outputAsJpeg. Because the sink executes through exec(), attackers can chain arbitrary commands. The attack complexity is elevated because the deployment must run on a non-Windows host with cjpeg available at /usr/local/bin/cjpeg or in the system PATH.

php
// Vulnerable code (before patch) in phpthumb.gif.php
if ((strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') && (file_exists('/usr/local/bin/cjpeg') || shell_exec('which cjpeg'))) {

    if (gif_outputAsBmp($gif, $lpszFileName.'.bmp', $bgColor)) {
        exec('cjpeg '.$lpszFileName.'.bmp >'.$lpszFileName.' 2>/dev/null');
        @unlink($lpszFileName.'.bmp');

        if (@file_exists($lpszFileName)) {

Source: GitHub phpThumb Commit Changes

Stop Remote Code Execution Before It Runs

Singularity™ Endpoint detects and blocks exploit attempts at machine speed, including zero-days and novel attack techniques.

Stop Exploit Attempts

Detection Methods for CVE-2025-52994

Indicators of Compromise

  • Unexpected child processes spawned by the PHP-FPM or Apache worker process, particularly shell interpreters or network utilities such as bash, sh, curl, wget, or nc.
  • HTTP requests targeting phpthumb.php or endpoints invoking gif_outputAsJpeg that contain shell metacharacters (;, |, &, backticks, $()) in file name or output parameters.
  • Creation of new files with .php, .jsp, or unusual extensions in web-accessible directories following a phpThumb request.

Detection Strategies

  • Monitor process creation events on web servers for cjpeg invocations that spawn additional shell processes or interpreters.
  • Deploy web application firewall rules that block shell metacharacters in query parameters directed at phpThumb endpoints.
  • Inspect web server access logs for anomalously long or encoded query strings referencing GIF conversion parameters.

Monitoring Recommendations

  • Enable audit logging of execve syscalls originating from web server user accounts and forward the events to a central log platform.
  • Baseline the expected argument patterns for cjpeg execution and alert on deviations that include command separators or redirection operators.
  • Track outbound network connections initiated by the web server process to detect post-exploitation callbacks.

How to Mitigate CVE-2025-52994

Immediate Actions Required

  • Upgrade phpThumb to release 1.7.23-202506081709 or later, which introduces escapeshellarg() around all attacker-influenced command arguments.
  • Restrict web server user permissions and remove write access to directories outside the intended thumbnail cache.
  • Review recent web server and application logs for evidence of shell metacharacter injection in phpThumb requests.

Patch Information

The upstream fix is available in the phpThumb repository at GitHub phpThumb Commit Changes. The patch wraps both the input and output file name parameters with escapeshellarg() and updates the version string from 1.7.23-202503281052 to 1.7.23-202506081709. Downloads and release notes are published on the GitHub phpThumb Releases Page.

Workarounds

  • Remove or restrict access to the phpthumb.gif.php component if GIF-to-JPEG conversion is not required by the application.
  • Uninstall or make cjpeg unavailable in the PATH so the vulnerable code branch is not reachable.
  • Front phpThumb with a reverse proxy or WAF rule that rejects requests containing shell metacharacters in image processing parameters.
bash
# Patched code applies escapeshellarg() to both arguments
# exec('cjpeg '.escapeshellarg($lpszFileName.'.bmp').' > '.escapeshellarg($lpszFileName).' 2>/dev/null');

# Verify the deployed phpThumb version
grep -R "phpthumb_version" /var/www/ | grep -E "1\.7\.23-2025060817"

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.