Loading...
Skip to main content

CVE-2026-23874

MEDIUM

ImageMagick MSL: Stack overflow via infinite recursion in ProcessMSLScript

Published January 21, 2026Updated May 9, 2026Source: osv

Summary

## Summary Stack overflow via infinite recursion in MSL (Magick Scripting Language) `<write>` command when writing to MSL format. ## Version - ImageMagick 7.x (tested on current main branch) - Commit: HEAD - Requires: libxml2 support (for MSL parsing) ## Steps to Reproduce ### Method 1: Using ImageMagick directly ```bash magick MSL:recursive.msl out.png ``` ### Method 2: Using OSS-Fuzz reproduce ```bash python3 infra/helper.py build_fuzzers imagemagick python3 infra/helper.py reproduce imagemagick msl_fuzzer recursive.msl ``` Or run the fuzzer directly: ```bash ./msl_fuzzer recursive.msl ``` ## Expected Behavior ImageMagick should handle recursive MSL references gracefully by detecting the loop and returning an error. ## Actual Behavior Stack overflow causes process crash: ``` AddressSanitizer:DEADLYSIGNAL ==PID==ERROR: AddressSanitizer: stack-overflow #0 MSLStartElement /src/imagemagick/coders/msl.c:7045 #1 xmlParseStartTag /src/libxml2/parser.c #2 xmlParseChunk /src/libxml2/parser.c:11273 #3 ProcessMSLScript /src/imagemagick/coders/msl.c:7405 #4 WriteMSLImage /src/imagemagick/coders/msl.c:7867 #5 WriteImage /src/imagemagick/MagickCore/constitute.c:1346 #6 MSLStartElement /src/imagemagick/coders/msl.c:7045 ... (infinite recursion, 287+ frames) ``` ## Root Cause Analysis In `coders/msl.c`, the `<write>` command handler in `MSLStartElement()` (line ~7045) calls `WriteImage()`. When the output filename specifies MSL format (`msl:filename`), `WriteMSLImage()` is called, which parses the MSL file again via `ProcessMSLScript()`. If the MSL file references itself (directly or indirectly), this creates an infinite recursion loop: ``` MSLStartElement() → WriteImage() → WriteMSLImage() → ProcessMSLScript() → xmlParseChunk() → MSLStartElement() → ... (infinite loop) ``` ## Impact - **DoS**: Guaranteed crash via stack exhaustion - **Affected**: Any application using ImageMagick to process user-supplied MSL files ## Additional Trigger Paths The `<read>` command can also trigger recursion: Indirect recursion is also possible (a.msl → b.msl → a.msl). ## Fuzzer This issue was discovered using a custom MSL fuzzer: ```cpp #include <cstdint> #include <Magick++/Blob.h> #include <Magick++/Image.h> #include "utils.cc" extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { if (IsInvalidSize(Size)) return(0); try { const Magick::Blob blob(Data, Size); Magick::Image image; image.magick("MSL"); image.fileName("MSL:"); image.read(blob); } catch (Magick::Exception) { } return(0); } ``` This issue was found by Team FuzzingBrain @ Texas A&M University

Remediation

Upgrade to the fixed version using your package manager.

NuGet
Update Magick.NET-Q8-x64 to 14.10.2 or later
dotnet add package Magick.NET-Q8-x64 --version 14.10.2
NuGet
Update Magick.NET-Q16-HDRI-OpenMP-x64 to 14.10.2 or later
dotnet add package Magick.NET-Q16-HDRI-OpenMP-x64 --version 14.10.2
NuGet
Update Magick.NET-Q8-AnyCPU to 14.10.2 or later
dotnet add package Magick.NET-Q8-AnyCPU --version 14.10.2
NuGet
Update Magick.NET-Q16-HDRI-OpenMP-arm64 to 14.10.2 or later
dotnet add package Magick.NET-Q16-HDRI-OpenMP-arm64 --version 14.10.2
NuGet
Update Magick.NET-Q16-OpenMP-arm64 to 14.10.2 or later
dotnet add package Magick.NET-Q16-OpenMP-arm64 --version 14.10.2
NuGet
Update Magick.NET-Q16-HDRI-arm64 to 14.10.2 or later
dotnet add package Magick.NET-Q16-HDRI-arm64 --version 14.10.2
NuGet
Update Magick.NET-Q8-x86 to 14.10.2 or later
dotnet add package Magick.NET-Q8-x86 --version 14.10.2
NuGet
Update Magick.NET-Q16-x86 to 14.10.2 or later
dotnet add package Magick.NET-Q16-x86 --version 14.10.2
NuGet
Update Magick.NET-Q16-arm64 to 14.10.2 or later
dotnet add package Magick.NET-Q16-arm64 --version 14.10.2
NuGet
Update Magick.NET-Q8-OpenMP-x64 to 14.10.2 or later
dotnet add package Magick.NET-Q8-OpenMP-x64 --version 14.10.2
NuGet
Update Magick.NET-Q16-HDRI-x64 to 14.10.2 or later
dotnet add package Magick.NET-Q16-HDRI-x64 --version 14.10.2
NuGet
Update Magick.NET-Q8-arm64 to 14.10.2 or later
dotnet add package Magick.NET-Q8-arm64 --version 14.10.2
NuGet
Update Magick.NET-Q16-HDRI-x86 to 14.10.2 or later
dotnet add package Magick.NET-Q16-HDRI-x86 --version 14.10.2
NuGet
Update Magick.NET-Q8-OpenMP-arm64 to 14.10.2 or later
dotnet add package Magick.NET-Q8-OpenMP-arm64 --version 14.10.2
NuGet
Update Magick.NET-Q16-AnyCPU to 14.10.2 or later
dotnet add package Magick.NET-Q16-AnyCPU --version 14.10.2
NuGet
Update Magick.NET-Q16-OpenMP-x64 to 14.10.2 or later
dotnet add package Magick.NET-Q16-OpenMP-x64 --version 14.10.2
NuGet
Update Magick.NET-Q16-x64 to 14.10.2 or later
dotnet add package Magick.NET-Q16-x64 --version 14.10.2
NuGet
Update Magick.NET-Q16-HDRI-AnyCPU to 14.10.2 or later
dotnet add package Magick.NET-Q16-HDRI-AnyCPU --version 14.10.2

After upgrading, run your dependency scanner again to confirm the vulnerability is resolved.

Affected Packages (18)

PackageEcosystemAffectedFixed In
Magick.NET-Q8-x64
nuget
10.0.0, 10.1.0, 11.0.0, 11.1.0 (+220 more)14.10.2
Magick.NET-Q16-HDRI-OpenMP-x64
nuget
10.0.0, 10.1.0, 11.0.0, 11.1.0 (+101 more)14.10.2
Magick.NET-Q8-AnyCPU
nuget
10.0.0, 10.1.0, 11.0.0, 11.1.0 (+204 more)14.10.2
Magick.NET-Q16-HDRI-OpenMP-arm64
nuget
10.0.0, 10.1.0, 11.0.0, 11.1.0 (+49 more)14.10.2
Magick.NET-Q16-OpenMP-arm64
nuget
10.0.0, 10.1.0, 11.0.0, 11.1.0 (+49 more)14.10.2
Magick.NET-Q16-HDRI-arm64
nuget
10.0.0, 10.1.0, 11.0.0, 11.1.0 (+49 more)14.10.2
Magick.NET-Q8-x86
nuget
10.0.0, 10.1.0, 11.0.0, 11.1.0 (+220 more)14.10.2
Magick.NET-Q16-x86
nuget
10.0.0, 10.1.0, 11.0.0, 11.1.0 (+220 more)14.10.2
Magick.NET-Q16-arm64
nuget
10.0.0, 10.1.0, 11.0.0, 11.1.0 (+49 more)14.10.2
Magick.NET-Q8-OpenMP-x64
nuget
10.0.0, 10.1.0, 11.0.0, 11.1.0 (+101 more)14.10.2
Magick.NET-Q16-HDRI-x64
nuget
10.0.0, 10.1.0, 11.0.0, 11.1.0 (+201 more)14.10.2
Magick.NET-Q8-arm64
nuget
10.0.0, 10.1.0, 11.0.0, 11.1.0 (+49 more)14.10.2
Magick.NET-Q16-HDRI-x86
nuget
10.0.0, 10.1.0, 11.0.0, 11.1.0 (+201 more)14.10.2
Magick.NET-Q8-OpenMP-arm64
nuget
10.0.0, 10.1.0, 11.0.0, 11.1.0 (+49 more)14.10.2
Magick.NET-Q16-AnyCPU
nuget
10.0.0, 10.1.0, 11.0.0, 11.1.0 (+204 more)14.10.2
Magick.NET-Q16-OpenMP-x64
nuget
10.0.0, 10.1.0, 11.0.0, 11.1.0 (+101 more)14.10.2
Magick.NET-Q16-x64
nuget
10.0.0, 10.1.0, 11.0.0, 11.1.0 (+220 more)14.10.2
Magick.NET-Q16-HDRI-AnyCPU
nuget
10.0.0, 10.1.0, 11.0.0, 11.1.0 (+201 more)14.10.2

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 5.5 score means for each attack dimension.

Attack Vector
Local
Attack Complexity
Low
Privileges Required
Low
User Interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H

Frequently Asked Questions

What is CVE-2026-23874?
ImageMagick MSL: Stack overflow via infinite recursion in ProcessMSLScript This vulnerability has been assigned a severity rating of MEDIUM (CVSS score: 5.5/10).
How do I check if my project is affected by CVE-2026-23874?
CVE-2026-23874 affects Magick.NET-Q8-x64, Magick.NET-Q16-HDRI-OpenMP-x64 and Magick.NET-Q8-AnyCPU (and 15 more). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-23874 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
5.5

Exploitation requires specific conditions or has limited impact. Remediate within weeks.

Also Known As

GHSA-9vj4-wc7r-p844

Related CVEs

  • CVE-2026-46520
    HIGH

    ImageMagick: Heap Buffer Over-Write in IPL decoder when reading multiple images of different dimensions

  • CVE-2026-46522
    HIGH

    ImageMagick: Infinite Loop in the MIFF decoder can lead to CPU exhaustion

  • CVE-2026-22770
    MEDIUM

    ImageMagick releases an invalid pointer in BilateralBlur when memory allocation fails

  • CVE-2026-28690
    MEDIUM

    ImageMagick has stack write buffer overflow in MNG encoder

  • CVE-2025-68950
    MEDIUM

    ImageMagick's failure to limit MVG mutual causes Stack Overflow

  • CVE-2026-25796
    MEDIUM

    ImageMagick has memory leak of watermark Image object in ReadSTEGANOImage on multiple error/early-return paths

  • CVE-2026-25795
    MEDIUM

    ImageMagick has NULL pointer dereference in ReadSFWImage after DestroyImageInfo (sfw.c)

  • CVE-2026-25797
    MEDIUM

    ImageMagick: Code Injection via PostScript header in ps coders

Check if you're affected

Scan your dependencies to see if this vulnerability affects your projects.

Scan Your Dependencies