CVE-2025-54418: CodeIgniter4's ImageMagick Handler has Command Injection Vulnerability

Published Jul 28, 2025
·
Updated

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: pregreplace('/[^a-zA-Z0-9\s.,!?-]/', '', $text) and validate/restrict text options

References OWASP Command Injection Prevention CWE-78: OS Command Injection

Other sources

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.

— MITRE

CodeIgniter4's ImageMagick Handler has Command Injection Vulnerability

— Packagist

Affected Software

4 affected componentsFixes available
CodeIgniter Codeigniter<4.6.2
composer/codeigniter4/framework<4.6.2
4.6.2
CodeIgniter Codeigniter>=4.0.0<4.6.2
composer/codeigniter4/framework<4.6.2
4.6.2

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade composer/codeigniter4/framework to a version that resolves this vulnerability.

    Fixed in 4.6.2
  2. Upgrade

    Upgrade CodeIgniter4 ImageMagick Handler to a version that resolves this vulnerability.

    Fixed in 4.6.2
  3. Configuration

    Switch to the GD image handler (`gd`), which is not affected by the vulnerability.

    CodeIgniter4 image processing image handler = gd
  4. Compensating control

    For file uploads, avoid user-provided filenames: generate random names with `getRandomName()` when using `move()`, or use `store()`, which automatically generates safe filenames.

  5. Compensating control

    For ImageMagick text operations with user-controlled text, sanitize input using `preg_replace('/[^a-zA-Z0-9\s.,!?-]/', '', $text)` and validate or restrict text options.

Event History

Jul 28, 2025
CVE Published
via MITRE·02:47 PM
Data Sourced
via MITRE·02:47 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·03:15 PM
RemedyDescriptionSeverityWeaknessAffected Software
Advisory Published
via GitHub·04:08 PM
Data Sourced
via GitHub·04:08 PM
DescriptionSeverityWeaknessAffected Software
Data Sourced
via Packagist·04:08 PM
DescriptionSeverityAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2025-54418?

CVE-2025-54418 is considered a high severity vulnerability due to its potential for command injection.

2

How do I fix CVE-2025-54418?

To fix CVE-2025-54418, upgrade your CodeIgniter framework to version 4.6.2 or later.

3

What versions are affected by CVE-2025-54418?

CVE-2025-54418 affects all versions of CodeIgniter prior to 4.6.2.

4

What is the impact of CVE-2025-54418 on my application?

CVE-2025-54418 can allow an attacker to execute arbitrary commands on the server, potentially compromising the entire system.

5

Does CVE-2025-54418 only affect file uploads?

Yes, CVE-2025-54418 specifically affects applications using the ImageMagick handler with unvalidated user-controlled filenames.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203