CVE-2025-54418

9.8 CRITICAL

📋 TL;DR

This CVE describes a command injection vulnerability in CodeIgniter's ImageMagick handler that allows remote code execution. Applications using ImageMagiter with user-controlled filenames or text content are affected. Attackers can execute arbitrary commands on the server by uploading malicious files or providing crafted text inputs.

💻 Affected Systems

Products:
  • CodeIgniter 4
Versions: Versions prior to 4.6.2
Operating Systems: All operating systems running PHP with ImageMagick
Default Config Vulnerable: ✅ No
Notes: Only affects applications using ImageMagick handler (imagick) instead of default GD handler, and only when processing user-controlled filenames or text content.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Full server compromise allowing attacker to execute arbitrary commands with web server privileges, potentially leading to data theft, system takeover, or lateral movement.

🟠

Likely Case

Remote code execution leading to web shell installation, data exfiltration, or server resource abuse.

🟢

If Mitigated

Limited impact with proper input validation and filename sanitization, potentially only causing image processing failures.

🌐 Internet-Facing: HIGH - Web applications accepting file uploads or user text input are directly exposed to exploitation.
🏢 Internal Only: MEDIUM - Internal applications with authenticated users could still be exploited by malicious insiders or compromised accounts.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation requires specific conditions but is straightforward when those conditions are met. No public exploit code is known at this time.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 4.6.2

Vendor Advisory: https://github.com/codeigniter4/CodeIgniter4/security/advisories/GHSA-9952-gv64-x94c

Restart Required: No

Instructions:

1. Update CodeIgniter to version 4.6.2 or later using composer: composer require codeigniter4/framework:^4.6.2
2. Clear any cached files and verify the update.

🔧 Temporary Workarounds

Switch to GD image handler

all

Change from ImageMagick to GD library which is not vulnerable

In app/Config/Images.php, set $library = 'gd'

Use safe filename generation

all

Generate random filenames instead of using user-provided names

$file->getRandomName()
$file->store()

🧯 If You Can't Patch

  • Switch to GD image handler immediately as temporary mitigation
  • Implement strict input validation and sanitization for all user-controlled filenames and text inputs

🔍 How to Verify

Check if Vulnerable:

Check if using CodeIgniter <4.6.2 with ImageMagick handler and processing user-controlled filenames or text

Check Version:

composer show codeigniter4/framework | grep version

Verify Fix Applied:

Verify CodeIgniter version is 4.6.2 or higher and confirm ImageMagick handler is either not used or inputs are properly sanitized

📡 Detection & Monitoring

Log Indicators:

  • Unusual ImageMagick command executions
  • Shell commands in image processing logs
  • Failed image processing with suspicious filenames

Network Indicators:

  • Outbound connections from web server to unexpected destinations following image uploads

SIEM Query:

search 'ImageMagick' AND ('command injection' OR 'shell metacharacters' OR suspicious filename patterns) in web application logs

🔗 References

📤 Share & Export