CVE-2026-109277 Overview
CVE-2026-109277 is a policy bypass vulnerability affecting ImageMagick versions prior to 7.1.2-32. The flaw resides in the -script operation, which fails to properly validate file descriptor handling. Attackers with local access can use the -script operation to close file descriptors not opened by the current operation, circumventing configured security policies. The vulnerability is classified under CWE-404: Improper Resource Shutdown or Release.
Critical Impact
A local attacker with low privileges can bypass ImageMagick security policy enforcement, leading to limited availability impact on affected systems processing untrusted scripts.
Affected Products
- ImageMagick versions prior to 7.1.2-32
- Applications and services embedding vulnerable ImageMagick libraries
- Image processing pipelines invoking the -script operation
Discovery Timeline
- 2026-10-12 - CVE-2026-109277 published to NVD
- 2026-10-15 - Last updated in NVD database
Technical Details for CVE-2026-109277
Vulnerability Analysis
The vulnerability resides in MagickWand/script-token.c, which handles script token parsing within ImageMagick. The -script operation accepts a filename and opens it for reading. When the file open succeeds, the code must track ownership of the descriptor so the resource is released correctly later. The pre-patch logic did not consistently set the opened flag after opening a file via fopen_utf8. As a result, when ImageMagick later closed the stream, it could operate on file descriptors that the current operation did not open.
This improper resource shutdown behavior ([CWE-404]) allows an attacker who controls script input to close arbitrary file descriptors inherited by the ImageMagick process. Closing descriptors referenced by security policy enforcement, logging, or sandbox mechanisms undermines the configured policy framework. The vulnerability requires local access and low privileges, with no user interaction required.
Root Cause
The root cause is a missing state assignment on the success path of fopen_utf8. Without marking the stream as opened, downstream close logic incorrectly handled file descriptors not owned by the current script-token context. The patch commit ce92ae07c2ca2c20c131eaf6da6da734c1cafce0 sets token_info->opened=MagickTrue immediately after a successful open.
Attack Vector
An attacker supplies a crafted script file processed by the ImageMagick -script operation. Through the flawed descriptor handling, the attacker triggers closure of file descriptors associated with ImageMagick's policy or sandbox enforcement, enabling actions that the configured policy would otherwise block.
// Security patch in MagickWand/script-token.c
}
else {
token_info->stream=fopen_utf8(filename, "r");
+ if (token_info->stream != (FILE *) NULL)
+ token_info->opened=MagickTrue;
}
if ( token_info->stream != (FILE *) NULL )
token_info->opened=MagickTrue;
Detect Identity Attacks the Moment Authentication Fails
Singularity™ Identity surfaces credential misuse, lateral movement, and privilege escalation in real time, so you can contain the breach before it spreads.
Stop Identity AttacksDetection Methods for CVE-2026-109277
Indicators of Compromise
- Execution of ImageMagick binaries (magick, convert) with the -script argument from untrusted contexts
- Unexpected closure of file descriptors held by processes invoking ImageMagick
- Policy enforcement failures or sandbox escape events coinciding with image processing jobs
Detection Strategies
- Inventory installed ImageMagick versions and flag any build earlier than 7.1.2-32
- Audit command-line telemetry for -script invocations referencing user-supplied files
- Correlate ImageMagick process activity with changes to security policy enforcement state
Monitoring Recommendations
- Enable process execution logging on hosts running ImageMagick to capture command lines and parent processes
- Monitor web application and batch processing workflows that pass user content to ImageMagick
- Alert on new or anonymous users invoking -script operations against the image processing service
How to Mitigate CVE-2026-109277
Immediate Actions Required
- Upgrade ImageMagick to version 7.1.2-32 or later across all affected hosts and container images
- Restrict access to the -script operation and refuse script inputs sourced from untrusted users
- Review and tighten policy.xml to disable high-risk coders and operations not required by workloads
Patch Information
The fix is included in ImageMagick 7.1.2-32. The patch (commit ce92ae07c2ca2c20c131eaf6da6da734c1cafce0) correctly sets token_info->opened=MagickTrue immediately after a successful fopen_utf8 call. Reference the GitHub Security Advisory GHSA-vv56-wmgw-m36w and the VulnCheck Advisory for ImageMagick for additional context.
Workarounds
- Disable the -script operation in environments that do not require it by hardening the ImageMagick policy.xml
- Run ImageMagick under a dedicated low-privileged account with reduced file descriptor inheritance
- Isolate ImageMagick processing in a container or sandbox that limits access to policy-critical resources
# Example policy.xml hardening to block MSL/script processing
# /etc/ImageMagick-7/policy.xml
<policymap>
<policy domain="delegate" rights="none" pattern="*" />
<policy domain="coder" rights="none" pattern="MSL" />
<policy domain="coder" rights="none" pattern="MVG" />
<policy domain="path" rights="none" pattern="@*" />
</policymap>
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

