CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



CVE-2026-40312

CVE-2026-40312: Off-by-One Heap Memory Corruption in ImageMagick MSL Decoder

Alon Barad
Alon Barad
Software Engineer

Apr 14, 2026·4 min read·69 visits

Executive Summary (TL;DR)

An off-by-one array index in ImageMagick's MSL decoder causes an out-of-bounds memory increment, resulting in heap corruption and application crash when parsing crafted files.

ImageMagick versions prior to 7.1.2-19 contain an off-by-one vulnerability in the Magick Scripting Language (MSL) decoder. Processing a maliciously crafted MSL file triggers an out-of-bounds heap increment, leading to memory corruption and denial of service.

Vulnerability Overview

ImageMagick relies on various decoder modules to process numerous image formats and scripting languages. The Magick Scripting Language (MSL) module, implemented in coders/msl.c, handles XML-based scripts used to automate image processing tasks. This module exposes an attack surface when applications automatically parse user-supplied files.

A vulnerability tracked as CVE-2026-40312 exists within this MSL decoder component. The flaw is classified as an off-by-one error (CWE-193), which manifests as a heap-based buffer overflow (CWE-122). This occurs during the parsing of specific XML structures related to image groups.

The primary impact of this vulnerability is a denial of service. Exploitation corrupts heap memory structures, which reliably causes the ImageMagick process to crash when subsequent memory allocation or deallocation routines run. The vulnerability affects ImageMagick versions prior to 7.1.2-19 and Magick.NET versions prior to 14.12.0.

Root Cause Analysis

The root cause lies in the MSLPushImage function responsible for tracking images within defined groups. The decoder maintains a dynamic array of group_info structures inside the MSLInfo context object. This array is indexed sequentially as new groups are processed during MSL parsing.

A logic error occurs when the code attempts to increment the image count for the currently active group. The implementation uses the total count of groups (msl_info->number_groups) as the array index. In the C programming language, arrays are zero-indexed, meaning the highest valid index for an array of size N is N-1.

By accessing group_info[number_groups], the decoder targets the memory address immediately following the allocated group_info buffer. The subsequent increment operator (++) modifies this out-of-bounds memory location. This action corrupts data on the heap adjacent to the targeted buffer.

Code Analysis

The vulnerability is located in coders/msl.c at line 272. The unpatched code directly uses number_groups as the index without subtracting one. This flaw is triggered whenever msl_info->number_groups is greater than zero during an image push operation.

The fix, introduced in commit 2a06c7be3bba3326caf8b7a8d1fa2e0d4b88998d, requires a single-line modification. The patch corrects the index offset by subtracting one from the number_groups variable.

--- a/coders/msl.c
+++ b/coders/msl.c
@@ -272,7 +272,7 @@ static ssize_t MSLPushImage(MSLInfo *msl_info,Image *image)
       (msl_info->attributes[n] == (Image *) NULL))
     ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed")
   if (msl_info->number_groups != 0)
-    msl_info->group_info[msl_info->number_groups].numImages++;
+    msl_info->group_info[msl_info->number_groups-1].numImages++;
   return(n);
 }

This change ensures the increment operation targets the numImages member of the final valid element within the allocated group_info array. The fix completely resolves the off-by-one calculation, preventing the out-of-bounds heap access on this specific code path.

Exploitation and Impact Assessment

Exploitation requires an attacker to supply a crafted MSL file to an application utilizing ImageMagick. The vulnerability is local in nature (AV:L), meaning the malicious file must be delivered to and processed by the target system. No user interaction or elevated privileges are required once the parsing routine begins.

The out-of-bounds operation performs a blind increment on memory adjacent to the group_info array. This corrupts 1 to 8 bytes of heap metadata or adjacent application data, depending on the underlying architecture and compiler padding. When the glibc memory allocator (or equivalent) later attempts to read the corrupted chunk headers during free() or malloc(), it detects the inconsistency and aborts the process.

This behavior leads directly to a high availability impact (A:H), as defined by the CVSS 6.2 score. Applications relying on ImageMagick to process untrusted user uploads are susceptible to denial-of-service attacks. Currently, no public proof-of-concept exploits or active exploitation campaigns exist for this vulnerability.

Remediation Guidance

The definitive remediation for CVE-2026-40312 is upgrading the ImageMagick binary and associated libraries. System administrators must deploy ImageMagick version 7.1.2-19 or later. Software developers integrating Magick.NET must update their NuGet package dependencies to version 14.12.0 or higher.

In environments where immediate patching is not feasible, administrators can disable the vulnerable MSL coder entirely. This is achieved by modifying the ImageMagick policy.xml configuration file to restrict access to the MSL module.

<policymap>
  <policy domain="coder" rights="none" pattern="MSL" />
</policymap>

Implementing this policy configuration instructs the ImageMagick core engine to reject any files identified as MSL scripts. This workaround provides complete protection against the vulnerability without requiring a binary update, though it breaks legitimate MSL script processing.

Official Patches

ImageMagickFix Commit in ImageMagick repository
GitHubGitHub Security Advisory

Fix Analysis (1)

Technical Appendix

CVSS Score
6.2/ 10
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
EPSS Probability
0.01%
Top 100% most exploited

Affected Systems

ImageMagickMagick.NET

Affected Versions Detail

Product
Affected Versions
Fixed Version
ImageMagick
ImageMagick Studio LLC
< 7.1.2-197.1.2-19
Magick.NET
Magick.NET
< 14.12.014.12.0
AttributeDetail
CWE IDCWE-193
Attack VectorLocal
CVSS Score6.2 (Medium)
EPSS Score0.00012
ImpactDenial of Service
Exploit StatusNone
CISA KEVNot Listed

MITRE ATT&CK Mapping

T1499Endpoint Denial of Service
Impact
CWE-193
Off-by-one Error

Off-by-one Error

Vulnerability Timeline

Vulnerability fixed in ImageMagick source code
2026-04-09
CVE-2026-40312 published to NVD and CVE.org
2026-04-13
Security advisory GHSA-5xg3-585r-9jh5 published by ImageMagick
2026-04-13
OSV data updated with affected NuGet package ranges
2026-04-14

References & Sources

  • [1]NVD Detail: CVE-2026-40312
  • [2]GitHub Security Advisory: GHSA-5xg3-585r-9jh5
  • [3]ImageMagick Fix Commit
  • [4]ImageMagick Release 7.1.2-19
  • [5]Magick.NET Release 14.12.0

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•about 1 hour ago•CVE-2026-72810
8.6

CVE-2026-72810: Publish-Boundary Bypass and Real-Time Data Leakage via WebSocket Session Pollution in SiYuan

CVE-2026-72810 is a critical publish-boundary bypass vulnerability in the SiYuan personal knowledge management system before version 3.7.4. The flaw lies in the backend real-time WebSocket broadcast mechanism. When configured in public publish mode, the system fails to differentiate between unauthenticated public reader sessions and authorized administrative sessions within its global connection pool. This architectural oversight allows unauthenticated remote attackers connecting to the public WebSocket endpoint on port 6808 to passively receive real-time, raw workspace modification events, including keystroke logs, block updates, and content from protected or forbidden documents.

Amit Schendel
Amit Schendel
0 views•7 min read
•about 2 hours ago•CVE-2026-72809
8.0

CVE-2026-72809: Authentication Bypass in SiYuan via Localhost Trust Spoofing

An authentication bypass vulnerability exists in the SiYuan personal knowledge management system (versions <= v3.7.2). The flaw occurs because the kernel's authorization validation handler trusts loopback connection origins blindly, allowing remote network attackers to gain administrative privileges via an exposed local reverse proxy.

Alon Barad
Alon Barad
1 views•6 min read
•about 3 hours ago•CVE-2026-72808
6.9

CVE-2026-72808: Unauthorized PDF Annotation Access in SiYuan Knowledge Management System

An information disclosure vulnerability in the SiYuan knowledge management system versions up to and including v3.7.2 allows remote unauthorized attackers to retrieve PDF annotations via the /api/asset/getFileAnnotation endpoint due to missing authorization checks.

Alon Barad
Alon Barad
7 views•6 min read
•about 4 hours ago•CVE-2026-72807
8.8

CVE-2026-72807: Second-Order SQL Injection via Attribute View Templates in SiYuan

CVE-2026-72807 is a second-order SQL injection vulnerability in SiYuan versions prior to v3.7.4. It resides in the dynamic evaluation of Attribute View (AV) template columns, which expose unsafe template functions. An attacker can exploit this by distributing a malicious SiYuan package that executes arbitrary SQL queries on the victim's local database.

Amit Schendel
Amit Schendel
5 views•7 min read
•about 5 hours ago•CVE-2026-72806
5.8

CVE-2026-72806: Missing Authorization in SiYuan Attribute View Rendering Leads to Information Disclosure

An authorization bypass vulnerability in SiYuan prior to v3.7.4 allows unauthenticated remote attackers to access rows, block IDs, and custom attributes of password-protected documents via the attribute view rendering endpoint.

Alon Barad
Alon Barad
3 views•7 min read
•about 6 hours ago•CVE-2026-72805
6.9

CVE-2026-72805: Missing Authorization in SiYuan Note Block APIs Leads to Information Disclosure

SiYuan Note versions before v3.7.4 fail to enforce publish-access checks on several block API endpoints. This vulnerability allows anonymous readers or authorized accounts with low-privileged roles to retrieve sensitive document titles, ancestor block content snippets, reference text, and path metadata for publish-forbidden or password-protected documents by supplying target block IDs.

Alon Barad
Alon Barad
5 views•6 min read