CVE-2025-53101

7.4 HIGH

📋 TL;DR

A stack overflow vulnerability in ImageMagick's mogrify command allows attackers to crash the application or potentially execute arbitrary code by providing malicious filename templates with multiple consecutive %d format specifiers. This affects all systems running vulnerable versions of ImageMagick that process untrusted image files. The vulnerability is triggered when processing specially crafted filenames through the mogrify command.

💻 Affected Systems

Products:
  • ImageMagick
Versions: All versions prior to 7.1.2-0 and 6.9.13-26
Operating Systems: All operating systems running vulnerable ImageMagick versions
Default Config Vulnerable: ⚠️ Yes
Notes: Vulnerability is triggered specifically when using the mogrify command with filename templates containing multiple consecutive %d format specifiers.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution leading to complete system compromise if the stack overflow can be controlled to execute arbitrary code.

🟠

Likely Case

Application crash (denial of service) when processing malicious filenames, potentially disrupting image processing services.

🟢

If Mitigated

Limited to denial of service if exploit attempts are detected and blocked, or if memory protections prevent code execution.

🌐 Internet-Facing: MEDIUM - Risk exists if ImageMagick processes user-uploaded images with custom filenames, but requires specific filename template usage.
🏢 Internal Only: LOW - Typically requires local access or specific API calls with crafted filenames; lower exposure in controlled environments.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Exploitation requires crafting specific filename templates and likely local access or ability to control input to mogrify command.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: ImageMagick 7.1.2-0 and 6.9.13-26

Vendor Advisory: https://github.com/ImageMagick/ImageMagick/security/advisories/GHSA-qh3h-j545-h8c9

Restart Required: No

Instructions:

1. Update ImageMagick to version 7.1.2-0 or 6.9.13-26 or later. 2. For package managers: 'sudo apt update && sudo apt upgrade imagemagick' (Debian/Ubuntu) or 'sudo yum update imagemagick' (RHEL/CentOS). 3. For source builds: Download latest release from imagemagick.org and recompile.

🔧 Temporary Workarounds

Restrict mogrify command usage

all

Limit or disable use of mogrify command with user-controlled filename templates

# Use application whitelisting to restrict mogrify execution
# Implement input validation to reject filenames with multiple %d specifiers

🧯 If You Can't Patch

  • Implement strict input validation to reject filename templates with multiple consecutive %d format specifiers
  • Sandbox ImageMagick processes to limit potential damage from exploitation attempts

🔍 How to Verify

Check if Vulnerable:

Check ImageMagick version with 'convert --version' or 'mogrify --version' and compare against vulnerable versions

Check Version:

convert --version | head -1

Verify Fix Applied:

Verify version is 7.1.2-0 or higher (for version 7) or 6.9.13-26 or higher (for version 6)

📡 Detection & Monitoring

Log Indicators:

  • Application crashes of ImageMagick processes
  • Error logs containing stack overflow or segmentation fault messages

Network Indicators:

  • Unusual file upload patterns with complex filenames to image processing endpoints

SIEM Query:

source="*imagemagick*" AND ("segmentation fault" OR "stack overflow" OR "mogrify crash")

🔗 References

📤 Share & Export