# CVE-2026-40312: ImageMagick off-by-one error in MSL decoder

Source: https://junglewise.ai/threats/cve-2026-40312-imagemagick-off-by-one-error-in-msl-decoder  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-04-14. Updated: 2026-05-10  
License: CC BY 4.0 with a link back

CVE-2026-40312 · Severity: medium · CVSS 6.2 · Published 2026-04-14

ImageMagick, a widely used suite for displaying and converting images, is vulnerable to a flaw when processing specific script files. An attacker can provide a specially crafted Magick Scripting Language (MSL) file that causes the application to crash. This can lead to a denial-of-service, interrupting business operations that rely on automated image processing.

Technologies: [Magick.NET-Q16-AnyCPU (NuGet)](https://junglewise.ai/threats/technologies/magick-net-q16-anycpu), [Magick.NET-Q16-arm64 (NuGet)](https://junglewise.ai/threats/technologies/magick-net-q16-arm64), [Magick.NET-Q16-HDRI-AnyCPU (NuGet)](https://junglewise.ai/threats/technologies/magick-net-q16-hdri-anycpu), [Magick.NET-Q16-HDRI-arm64 (NuGet)](https://junglewise.ai/threats/technologies/magick-net-q16-hdri-arm64), [Magick.NET-Q16-HDRI-OpenMP-arm64 (NuGet)](https://junglewise.ai/threats/technologies/magick-net-q16-hdri-openmp-arm64), [Magick.NET-Q16-HDRI-x64 (NuGet)](https://junglewise.ai/threats/technologies/magick-net-q16-hdri-x64), [Magick.NET-Q16-HDRI-x86 (NuGet)](https://junglewise.ai/threats/technologies/magick-net-q16-hdri-x86), [Magick.NET-Q16-OpenMP-arm64 (NuGet)](https://junglewise.ai/threats/technologies/magick-net-q16-openmp-arm64), [Magick.NET-Q16-OpenMP-x64 (NuGet)](https://junglewise.ai/threats/technologies/magick-net-q16-openmp-x64), [Magick.NET-Q16-x64 (NuGet)](https://junglewise.ai/threats/technologies/magick-net-q16-x64), [Magick.NET-Q16-x86 (NuGet)](https://junglewise.ai/threats/technologies/magick-net-q16-x86), [Magick.NET-Q8-AnyCPU (NuGet)](https://junglewise.ai/threats/technologies/magick-net-q8-anycpu), [Magick.NET-Q8-arm64 (NuGet)](https://junglewise.ai/threats/technologies/magick-net-q8-arm64), [Magick.NET-Q8-OpenMP-arm64 (NuGet)](https://junglewise.ai/threats/technologies/magick-net-q8-openmp-arm64), [Magick.NET-Q8-OpenMP-x64 (NuGet)](https://junglewise.ai/threats/technologies/magick-net-q8-openmp-x64), [Magick.NET-Q8-x64 (NuGet)](https://junglewise.ai/threats/technologies/magick-net-q8-x64), [Magick.NET-Q8-x86 (NuGet)](https://junglewise.ai/threats/technologies/magick-net-q8-x86). Vendors: [NuGet](https://junglewise.ai/threats/vendors/nuget).

## Quick answers

**Is CVE-2026-40312 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-40312 being exploited in the wild.

**How severe is CVE-2026-40312?** Medium severity, with a CVSS score of 6.2, published 14 April 2026.

**Which products and versions are affected?** Magick.NET-Q16-AnyCPU (NuGet) < 14.12.0, ECOSYSTEM:introduced=0,fixed=14.12.0; Magick.NET-Q16-arm64 (NuGet) < 14.12.0, ECOSYSTEM:introduced=0,fixed=14.12.0; Magick.NET-Q16-HDRI-AnyCPU (NuGet) < 14.12.0, ECOSYSTEM:introduced=0,fixed=14.12.0; Magick.NET-Q16-HDRI-arm64 (NuGet) < 14.12.0, ECOSYSTEM:introduced=0,fixed=14.12.0; and 13 more.

**Is there a fix for CVE-2026-40312?** Yes. Magick.NET-Q16-AnyCPU (NuGet): upgrade to 14.12.0 or later; Magick.NET-Q16-arm64 (NuGet): upgrade to 14.12.0 or later; Magick.NET-Q16-HDRI-AnyCPU (NuGet): upgrade to 14.12.0 or later; Magick.NET-Q16-HDRI-arm64 (NuGet): upgrade to 14.12.0 or later; Magick.NET-Q16-HDRI-OpenMP-arm64 (NuGet): upgrade to 14.12.0 or later; Magick.NET-Q16-HDRI-x64 (NuGet): upgrade to 14.12.0 or later; Magick.NET-Q16-HDRI-x86 (NuGet): upgrade to 14.12.0 or later; Magick.NET-Q16-OpenMP-arm64 (NuGet): upgrade to 14.12.0 or later; Magick.NET-Q16-OpenMP-x64 (NuGet): upgrade to 14.12.0 or later; Magick.NET-Q16-x64 (NuGet): upgrade to 14.12.0 or later; Magick.NET-Q16-x86 (NuGet): upgrade to 14.12.0 or later; Magick.NET-Q8-AnyCPU (NuGet): upgrade to 14.12.0 or later; Magick.NET-Q8-arm64 (NuGet): upgrade to 14.12.0 or later; Magick.NET-Q8-OpenMP-arm64 (NuGet): upgrade to 14.12.0 or later; Magick.NET-Q8-OpenMP-x64 (NuGet): upgrade to 14.12.0 or later; Magick.NET-Q8-x64 (NuGet): upgrade to 14.12.0 or later; Magick.NET-Q8-x86 (NuGet): upgrade to 14.12.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-40312 attacked?** It is attacked with local access, in a software library.

**Am I affected by CVE-2026-40312?** Check whether you run Magick.NET-Q16-AnyCPU (NuGet), Magick.NET-Q16-arm64 (NuGet), Magick.NET-Q16-HDRI-AnyCPU (NuGet) or one of the others listed at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- Magick.NET-Q16-AnyCPU (NuGet): upgrade to 14.12.0 or later

  ```sh
  dotnet add package Magick.NET-Q16-AnyCPU --version 14.12.0
  ```

- Magick.NET-Q16-arm64 (NuGet): upgrade to 14.12.0 or later

  ```sh
  dotnet add package Magick.NET-Q16-arm64 --version 14.12.0
  ```

- Magick.NET-Q16-HDRI-AnyCPU (NuGet): upgrade to 14.12.0 or later

  ```sh
  dotnet add package Magick.NET-Q16-HDRI-AnyCPU --version 14.12.0
  ```

- Magick.NET-Q16-HDRI-arm64 (NuGet): upgrade to 14.12.0 or later

  ```sh
  dotnet add package Magick.NET-Q16-HDRI-arm64 --version 14.12.0
  ```

- Magick.NET-Q16-HDRI-OpenMP-arm64 (NuGet): upgrade to 14.12.0 or later

  ```sh
  dotnet add package Magick.NET-Q16-HDRI-OpenMP-arm64 --version 14.12.0
  ```

- Magick.NET-Q16-HDRI-x64 (NuGet): upgrade to 14.12.0 or later

  ```sh
  dotnet add package Magick.NET-Q16-HDRI-x64 --version 14.12.0
  ```

- Magick.NET-Q16-HDRI-x86 (NuGet): upgrade to 14.12.0 or later

  ```sh
  dotnet add package Magick.NET-Q16-HDRI-x86 --version 14.12.0
  ```

- Magick.NET-Q16-OpenMP-arm64 (NuGet): upgrade to 14.12.0 or later

  ```sh
  dotnet add package Magick.NET-Q16-OpenMP-arm64 --version 14.12.0
  ```

- Magick.NET-Q16-OpenMP-x64 (NuGet): upgrade to 14.12.0 or later

  ```sh
  dotnet add package Magick.NET-Q16-OpenMP-x64 --version 14.12.0
  ```

- Magick.NET-Q16-x64 (NuGet): upgrade to 14.12.0 or later

  ```sh
  dotnet add package Magick.NET-Q16-x64 --version 14.12.0
  ```

- Magick.NET-Q16-x86 (NuGet): upgrade to 14.12.0 or later

  ```sh
  dotnet add package Magick.NET-Q16-x86 --version 14.12.0
  ```

- Magick.NET-Q8-AnyCPU (NuGet): upgrade to 14.12.0 or later

  ```sh
  dotnet add package Magick.NET-Q8-AnyCPU --version 14.12.0
  ```

- Magick.NET-Q8-arm64 (NuGet): upgrade to 14.12.0 or later

  ```sh
  dotnet add package Magick.NET-Q8-arm64 --version 14.12.0
  ```

- Magick.NET-Q8-OpenMP-arm64 (NuGet): upgrade to 14.12.0 or later

  ```sh
  dotnet add package Magick.NET-Q8-OpenMP-arm64 --version 14.12.0
  ```

- Magick.NET-Q8-OpenMP-x64 (NuGet): upgrade to 14.12.0 or later

  ```sh
  dotnet add package Magick.NET-Q8-OpenMP-x64 --version 14.12.0
  ```

- Magick.NET-Q8-x64 (NuGet): upgrade to 14.12.0 or later

  ```sh
  dotnet add package Magick.NET-Q8-x64 --version 14.12.0
  ```

- Magick.NET-Q8-x86 (NuGet): upgrade to 14.12.0 or later

  ```sh
  dotnet add package Magick.NET-Q8-x86 --version 14.12.0
  ```


## Technical details

An off-by-one error (CWE-193) exists in the Magick Scripting Language (MSL) decoder of ImageMagick. The vulnerability is triggered when the library attempts to read and parse a maliciously crafted .msl file. This is a local attack vector requiring no special privileges or user interaction beyond the application attempting to process the file. Successful exploitation results in a memory corruption that leads to an application crash (Denial of Service). The issue has been addressed in ImageMagick version 7.1.2-19 and Magick.NET version 14.12.0.

## Affected products

- ImageMagick ImageMagick < 7.1.2-19
- dlemstra Magick.NET < 14.12.0

## Identifiers

- CVE-2026-40312
- GHSA-5xg3-585r-9jh5

## Timeline

- 2026-04-13: advisory: NVD publication date
- 2026-04-14: disclosed: GitHub Advisory published
- 2026-04-14: patched: GitHub Advisory reviewed and updated with patch information

## References

- [https://api.github.com/users/COCOP1l0t](https://api.github.com/users/COCOP1l0t)
- [https://github.com/COCOP1l0t](https://github.com/COCOP1l0t)
- [https://api.github.com/users/COCOP1l0t/gists%7B/gist_id%7D](https://api.github.com/users/COCOP1l0t/gists%7B/gist_id%7D)
- [https://api.github.com/users/COCOP1l0t/repos](https://api.github.com/users/COCOP1l0t/repos)
- [https://avatars.githubusercontent.com/u/260065109?v=4](https://avatars.githubusercontent.com/u/260065109?v=4)
- [https://api.github.com/users/COCOP1l0t/events%7B/privacy%7D](https://api.github.com/users/COCOP1l0t/events%7B/privacy%7D)

## Related threats

- [ImageMagick integer overflow in JNX decoder](https://junglewise.ai/threats/cve-2026-62946-imagemagick-integer-overflow-in-jnx-decoder)
- [ImageMagick heap buffer overflow in fx operation](https://junglewise.ai/threats/cve-2026-62363-imagemagick-heap-buffer-overflow-in-fx-operation)
- [ImageMagick heap buffer overwrite in morphology operation](https://junglewise.ai/threats/cve-2026-62343-imagemagick-heap-buffer-overwrite-in-morphology-operation)
- [ImageMagick memory leak in magick CLI via invalid options](https://junglewise.ai/threats/cve-2026-66011-imagemagick-memory-leak-in-magick-cli-via-invalid-options)
- [ImageMagick memory leak in TIFF encoder](https://junglewise.ai/threats/cve-2026-61872-imagemagick-memory-leak-in-tiff-encoder)
