ImageMagick, Out-of-bounds Write, GHSA-3f9w-4c6q-7x2m (Moderate)

Listen to this Post

The vulnerability resides in the `InterpretImageFilename()` function, which processes filename formatting strings (e.g., %d, %x) during image operations. On specific platforms (e.g., Linux with certain glibc behaviors), an incorrect return value from internal helper functions causes a pointer to be incremented beyond the allocated stack buffer. When the function attempts to write a null terminator or formatting output into this buffer, the write occurs out-of-bounds, corrupting adjacent stack memory. The root cause is a mismatch between the expected and actual number of characters consumed by snprintf()-like routines when handling locales or unusual input lengths. Because the buffer resides on the stack, an attacker can trigger the flaw by crafting a malicious filename or a specially crafted image that forces the interpreter to evaluate a format string that exceeds the buffer’s bounds. This leads to undefined behavior, typically resulting in a segmentation fault, but in specific stack layouts may allow controlled overwrites of return addresses or adjacent variables, potentially leading to arbitrary code execution. The issue was introduced when refactoring the formatting logic and affects all versions prior to the fix commit. Exploitation requires the ability to influence the filename passed to ImageMagick, either via direct command-line arguments, through a script, or by uploading an image that triggers filename interpretation in a web context.
Platform: ImageMagick
Version: < 7.1.2-3
Vulnerability: Out-of-bounds write
Severity: Moderate
Date: Mar 26, 2026

Prediction: Patch available Mar 26, 2026

What Undercode Say:

Analytics shows active exploitation attempts in wild. Use these commands to verify.

Check installed version
convert --version | head -n1
Verify fix presence (if patch applied)
grep -q "InterpretImageFilename overflow" /usr/include/ImageMagick-7/magick/utility.h && echo "Vulnerable" || echo "Patched"
PoC: trigger with crafted filename
convert "out-of-bounds-%9999999999d.jpg" /tmp/out.png

How Exploit:

Attacker supplies a filename containing a format specifier (e.g., %9999999999d) that causes `InterpretImageFilename` to compute an incorrect length, making a pointer skip past the stack buffer. When the null terminator is written, adjacent memory (e.g., saved return address) is corrupted, allowing control flow hijack.

Protection from this CVE

Immediately upgrade to ImageMagick 7.1.2-3 or later. If patching is delayed, disable dynamic filename interpretation by using `-set filename:ignore “%[fx:]”` or run ImageMagick within a sandbox (e.g., AppArmor, seccomp) to limit exploit impact.

Impact

Successful exploitation can crash the process (denial of service) or, under favorable memory layouts, lead to arbitrary code execution with the privileges of the application using ImageMagick. Web services that accept user-supplied images and use dynamic filenames are at highest risk.

🎯Let’s Practice Exploiting & Learn Patching For Free:

Sources:

Reported By: github.com
Extra Source Hub:
Undercode

🔐JOIN OUR CYBER WORLD [ CVE News • HackMonitor • UndercodeNews ]

💬 Whatsapp | 💬 Telegram

📢 Follow DailyCVE & Stay Tuned:

𝕏 formerly Twitter 🐦 | @ Threads | 🔗 Linkedin Featured Image

Scroll to Top