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 package | Versions | Reported by |
|---|---|---|
| codeigniter4 CodeIgniter4 | < 4.6.2 | CVE List |
| codeigniter4/framework (Packagist) | before 4.6.2 | GitHub Advisory Database |
| codeigniter codeigniter | from 4.0.0 before 4.6.2 | NVD |
All scores
| GitHub_M | 9.8critical CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
| GitHub | 9.8critical CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
Classification
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 (
imagickas 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
- Allow file uploads with user-controlled filenames and process uploaded images using the
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 themove()method, or use thestore()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
| https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-9952-gv64-x94c | mitigation, vendor-advisory, web | |
| https://github.com/codeigniter4/CodeIgniter4/commit/e18120bff1da691e1d15ffc1bf553ae7411762c0 | patch, web | |
| https://cwe.mitre.org/data/definitions/78.html | not-applicable, web | |
| https://owasp.org/www-community/attacks/Command_Injection | not-applicable, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2025-54418 | advisory | |
| https://github.com/codeigniter4/CodeIgniter4 | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2025-54418 changed 2025-07-28 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-9952-gv64-x94c changed 2025-07-28 | CC-BY-4.0 |
| NVD | CVE-2025-54418 changed 2026-06-17 | Public domain |