CVE-2025-54418·PHP vulnerability
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.
- Severity
- critical
- Software
- PHP
- Fixed in
- 4.6.2
- Published
- 2025-07-28
Affected versions
From: 4.0.0
Until: 4.6.2
Fixed in: 4.6.2
How to fix this CVE
Upgrade CodeIgniter to version 4.6.2 or later to patch a critical command injection vulnerability in the ImageMagick image handler. If immediate patching is not possible, disable ImageMagick and switch to the GD image library (the default handler), or implement strict input validation and filename sanitization for file uploads and text operations.
sudo dnf update php php-pecl-imagickDefensia detects this vulnerability
What an exploitation attempt looks like
Sample log line indicative of exploitation attempts:
POST requests with file uploads containing shell metacharacters in filenames (e.g., `$(command)`, `` `backticks` ``, `|pipe|`, `&ersand&`, `;semicolon;`) combined with ImageMagick processing, or POST/GET parameters with command substitution patterns passed to text() method; look for error logs showing ImageMagick/convert process execution with unexpected argumentsWAF mitigation (if patching is not yet possible)
Add this rule to your WAF to block exploitation attempts while you schedule the patch.
Implement WAF rules to reject file uploads with names containing shell metacharacters (regex: `[;&|$`()\[\]{}]`) and validate image processing text parameters against a whitelist of safe characters, blocking requests containing command substitution patterns like `$()`, backticks, or pipe operators.How to check if you are affected
- Check the CodeIgniter version: grep -r "const VERSION" application/Config/Constants.php or composer show codeigniter4/framework | grep '^codeigniter4'
- Verify if ImageMagick handler is configured: grep -E "'image'.*=>.*'imagick'" application/Config/Images.php
- Search application logs for ImageMagick processing errors or shell metacharacter patterns in uploaded filenames: grep -i 'imagick\|convert\|identify' /var/log/php-errors.log
- Confirm the patch by verifying CodeIgniter version is >= 4.6.2: composer show codeigniter4/framework | grep 'versions'
FAQ
What is CVE-2025-54418?
CVE-2025-54418 is a critical command injection vulnerability in CodeIgniter's ImageMagick image handler that allows attackers to execute arbitrary system commands through malicious filenames in file uploads or unsanitized text content passed to image processing methods.
Is CVE-2025-54418 being actively exploited?
As of the latest NVD data, CVE-2025-54418 is not listed on the CISA Known Exploited Vulnerabilities (KEV) catalog and no public exploits are currently documented, though the critical CVSS score warrants immediate patching.
What versions of CodeIgniter are affected by CVE-2025-54418?
CodeIgniter versions 4.0.0 through 4.6.1 are vulnerable when using the ImageMagick handler. Version 4.6.2 and later contain the patch.
How do I check if my CodeIgniter application is vulnerable to CVE-2025-54418?
Run `composer show codeigniter4/framework` to check your version, and inspect application/Config/Images.php for `'image' => 'imagick'` configuration. If both conditions are true and your version is below 4.6.2, you are vulnerable.
Does Defensia detect CVE-2025-54418?
Yes — Defensia's CVE advisory scanner compares installed package versions against the NVD database. If PHP and CodeIgniter are installed on a monitored server, CVE-2025-54418 will appear in your dashboard with remediation steps.
Related PHP CVEs
References
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2025-54418. Free for 1 server.
Get started free