Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2026-61861

CVE-2026-61861: ImageMagick Use-After-Free Vulnerability

CVE-2026-61861 is a use-after-free flaw in ImageMagick's FormatMagickCaption method that attackers can exploit to cause denial of service or execute code. This article covers technical details, affected versions, and mitigations.

Published:

CVE-2026-61861 Overview

CVE-2026-61861 is a use-after-free vulnerability [CWE-416] in ImageMagick versions before 7.1.2-26. The flaw resides in the FormatMagickCaption method and triggers when memory allocation fails during caption formatting. When allocation fails, a dangling pointer continues to reference freed memory, creating conditions for denial of service or potential code execution.

ImageMagick is widely deployed in image processing pipelines, web applications, and content management systems. Attackers can craft inputs that induce allocation failures to reach the vulnerable code path.

Critical Impact

Exploitation may lead to denial of service or arbitrary code execution in processes that use ImageMagick to render captioned images from untrusted sources.

Affected Products

  • ImageMagick versions prior to 7.1.2-26
  • Applications and services embedding ImageMagick for image caption rendering
  • Linux distributions shipping vulnerable ImageMagick packages

Discovery Timeline

  • 2026-07-11 - CVE-2026-61861 published to NVD
  • 2026-07-13 - Last updated in NVD database

Technical Details for CVE-2026-61861

Vulnerability Analysis

The vulnerability resides in the FormatMagickCaption function within ImageMagick's caption rendering logic. This function formats and lays out text captions to be drawn onto images. During processing, the function performs heap allocations to hold intermediate caption data.

When a memory allocation call fails and returns NULL, the surrounding code does not correctly reset or invalidate pointers that referenced the previously freed memory region. A subsequent read or write through the stale pointer accesses freed memory, satisfying the classic use-after-free condition [CWE-416].

Because the vulnerable path is reached during normal caption operations, attackers who can supply crafted images, fonts, or caption strings to a service using ImageMagick can trigger the flaw remotely.

Root Cause

The root cause is improper error handling in FormatMagickCaption when memory allocation fails. The function frees a resource but leaves a dangling pointer in scope. Later logic dereferences this pointer, resulting in access to memory that has been released back to the allocator.

Attack Vector

An attacker delivers a crafted image or caption payload to an application that invokes ImageMagick. The payload is designed to induce an allocation failure or exhaust available memory during caption formatting. Once the allocation fails, control flow reaches the dangling pointer dereference. This may crash the process or, under specific heap layouts, be leveraged for code execution.

The vulnerability requires network-accessible functionality that passes untrusted input to ImageMagick's captioning APIs, and attack complexity is high because it depends on triggering allocation failure conditions.

No verified public proof-of-concept code is available. Refer to the GitHub Security Advisory and the VulnCheck ImageMagick Advisory for technical details.

Detection Methods for CVE-2026-61861

Indicators of Compromise

  • Unexpected crashes or segmentation faults in processes invoking convert, magick, or ImageMagick library calls
  • Core dumps containing stack frames referencing FormatMagickCaption
  • Elevated memory pressure or allocation failure log entries preceding ImageMagick process termination
  • Upload of unusually large or malformed image and caption files to services using ImageMagick

Detection Strategies

  • Inventory installed ImageMagick versions across servers and container images and flag any release earlier than 7.1.2-26
  • Monitor application logs for repeated ImageMagick crashes or abnormal exit codes correlated with user-supplied image uploads
  • Enable AddressSanitizer or heap allocator diagnostics in test environments to surface use-after-free conditions before production impact

Monitoring Recommendations

  • Alert on ImageMagick worker process restarts and unhandled signals from image processing services
  • Track file upload endpoints for high volumes of caption operations from single source addresses
  • Correlate ImageMagick errors with subsequent anomalous child process creation on the host

How to Mitigate CVE-2026-61861

Immediate Actions Required

  • Upgrade ImageMagick to version 7.1.2-26 or later on all systems and container images
  • Rebuild application containers and redeploy services that statically link or bundle ImageMagick
  • Restrict image upload endpoints to authenticated users where feasible until patching is complete
  • Enforce resource limits on ImageMagick worker processes to reduce the likelihood of allocation failure exploitation

Patch Information

The fix is included in ImageMagick 7.1.2-26. Refer to the GitHub Security Advisory GHSA-qvxh-prvr-85w2 for the upstream patch and release notes. Linux distribution maintainers typically backport fixes; verify package versions against distribution security advisories.

Workarounds

  • Disable or block caption operations in ImageMagick policy configuration (policy.xml) where captioning is not required
  • Apply strict resource limits via ImageMagick policy.xml to constrain memory, map, and disk usage per operation
  • Sandbox ImageMagick execution using seccomp, containers, or dedicated low-privilege service accounts
bash
# Example ImageMagick policy.xml restriction to disable caption processing
# Place inside <policymap> in /etc/ImageMagick-7/policy.xml
<policy domain="coder" rights="none" pattern="CAPTION" />
<policy domain="resource" name="memory" value="256MiB" />
<policy domain="resource" name="map" value="512MiB" />
<policy domain="resource" name="disk" value="1GiB" />

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.