CVE-2025-54418
JSON

9.8critical

CodeIgniter4's ImageMagick Handler has Command Injection Vulnerability

Severity
9.8critical CVSS:3.1 by GitHub_M
Exploit likelihood
1.50% (higher than 75% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-9952-gv64-x94c

Description

CodeIgniter is a PHP full-stack web framework. A command injection vulnerability present in versions prior to 4.6.2 affects applications that use the ImageMagick handler for image processing (`imagick` as the image library) and either allow file uploads with user-controlled filenames and process uploaded images using the `resize()` method or use the `text()` method with user-controlled text content or options. An attacker can upload a file with a malicious filename containing shell metacharacters that get executed when the image is processed or provide malicious text content or options that get executed when adding text to images Users should upgrade to v4.6.2 or later to receive a patch. As a workaround, switch to the GD image handler (`gd`, the default handler), which is not affected by either vulnerability. For file upload scenarios, instead of using user-provided filenames, generate random names to eliminate the attack vector with `getRandomName()` when using the `move()` method, or use the `store()` method, which automatically generates safe filenames. For text operations, if one must use ImageMagick with user-controlled text, sanitize the input to only allow safe characters and validate/restrict text options.

Affected

Product or packageVersionsReported by
codeigniter4 CodeIgniter4< 4.6.2CVE List
codeigniter4/framework (Packagist)before 4.6.2GitHub Advisory Database
codeigniter codeigniterfrom 4.0.0 before 4.6.2NVD

All scores

GitHub_M9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
GitHub9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Classification

CWE-78

SSVC (CISA-ADP): exploitation none, automatable no, technical impact total.

What each source says

CVE List

CodeIgniter is a PHP full-stack web framework. A command injection vulnerability present in versions prior to 4.6.2 affects applications that use the ImageMagick handler for image processing (`imagick` as the image library) and either allow file uploads with user-controlled filenames and process uploaded images using the `resize()` method or use the `text()` method with user-controlled text content or options. An attacker can upload a file with a malicious filename containing shell metacharacters that get executed when the image is processed or provide malicious text content or options that get executed when adding text to images Users should upgrade to v4.6.2 or later to receive a patch. As a workaround, switch to the GD image handler (`gd`, the default handler), which is not affected by either vulnerability. For file upload scenarios, instead of using user-provided filenames, generate random names to eliminate the attack vector with `getRandomName()` when using the `move()` method, or use the `store()` method, which automatically generates safe filenames. For text operations, if one must use ImageMagick with user-controlled text, sanitize the input to only allow safe characters and validate/restrict text options.

GitHub Advisory Database
Impact

This vulnerability affects applications that:

  • Use the ImageMagick handler for image processing (imagick as the image library)
  • AND either:
    • Allow file uploads with user-controlled filenames and process uploaded images using the resize() method
    • OR use the text() method with user-controlled text content or options

An attacker can:

  • Upload a file with a malicious filename containing shell metacharacters that get executed when the image is processed
  • OR provide malicious text content or options that get executed when adding text to images
Patches

Upgrade to v4.6.2 or later.

Workarounds
  • Switch to the GD image handler (gd, the default handler), which is not affected by either vulnerability
  • For file upload scenarios: Instead of using user-provided filenames, generate random names to eliminate the attack vector with getRandomName() when using the move() method, or use the store() method, which automatically generates safe filenames
  • For text operations: If you must use ImageMagick with user-controlled text, sanitize the input to only allow safe characters: preg_replace('/[^a-zA-Z0-9\s.,!?-]/', '', $text) and validate/restrict text options
References
NVD (es)

CodeIgniter es un framework web PHP full-stack. Una vulnerabilidad de inyección de comandos presente en versiones anteriores a la 4.6.2 afecta a las aplicaciones que usan el manejador ImageMagick para el procesamiento de imágenes (`imagick` como librería de imágenes) y que permiten la carga de archivos con nombres controlados por el usuario y procesan las imágenes cargadas usando el método `resize()` o usan el método `text()` con contenido de texto u opciones controlados por el usuario. Un atacante puede cargar un archivo con un nombre malicioso que contenga metacaracteres de shell que se ejecuten cuando se procese la imagen o proporcionar contenido de texto malicioso u opciones que se ejecuten al agregar texto a las imágenes. Los usuarios deben actualizar a la v4.6.2 o posterior para recibir un parche. Como solución alternativa, cambie al manejador de imágenes GD (`gd`, el manejador predeterminado), que no se ve afectado por ninguna de las vulnerabilidades. Para la carga de archivos, en lugar de usar nombres de archivo proporcionados por el usuario, genere nombres aleatorios para eliminar el vector de ataque con `getRandomName()` al usar el método `move()`, o use el método `store()`, que genera automáticamente nombres de archivo seguros. Para operaciones de texto, si es necesario usar ImageMagick con texto controlado por el usuario, depure la entrada para permitir solo caracteres seguros y valide/restringa las opciones de texto.

References

Sources

SourceRecordLicence
CVE ListCVE-2025-54418 changed 2025-07-28CVE Terms of Use
GitHub Advisory DatabaseGHSA-9952-gv64-x94c changed 2025-07-28CC-BY-4.0
NVDCVE-2025-54418 changed 2026-06-17Public domain