CVE-2026-23874: ImageMagick MSL Stack Overflow Vulnerability

MODERATE
Advisory Identifier: GHSA-9vj4-wc7r-p844
CVSS 5.5
CWE-835
Published
Advisory Summary

CVE-2026-23874 is a MODERATE (CVSS 5.5) stack overflow vulnerability (CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')) affecting ImageMagick MSL libraries in the NuGet ecosystem. The issue involves stack overflow via infinite recursion in processmslscript. Remediation is available by upgrading affected packages to version 14.10.2.

CVE-2026-23874 at a Glance

CVE Identifier CVE-2026-23874
GHSA Identifier GHSA-9vj4-wc7r-p844
Severity MODERATE
CVSS v3.1 Base Score 5.5
CWE Classification CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')
Affected Product ImageMagick MSL
Package Ecosystem NuGet
Published Date
Last Updated

Security Impact

CVSS: 5.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2026-23874

To remediate this vulnerability, upgrade all affected ImageMagick MSL dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

Magick.NET-Q8-x64 fixed: 14.10.2
Upgrade Magick.NET-Q8-x64 to 14.10.2
Magick.NET-Q8-arm64 fixed: 14.10.2
Upgrade Magick.NET-Q8-arm64 to 14.10.2
Magick.NET-Q8-x86 fixed: 14.10.2
Upgrade Magick.NET-Q8-x86 to 14.10.2
Magick.NET-Q8-OpenMP-x64 fixed: 14.10.2
Upgrade Magick.NET-Q8-OpenMP-x64 to 14.10.2
Magick.NET-Q8-OpenMP-arm64 fixed: 14.10.2
Upgrade Magick.NET-Q8-OpenMP-arm64 to 14.10.2
Magick.NET-Q16-x64 fixed: 14.10.2
Upgrade Magick.NET-Q16-x64 to 14.10.2
Magick.NET-Q16-arm64 fixed: 14.10.2
Upgrade Magick.NET-Q16-arm64 to 14.10.2
Magick.NET-Q16-x86 fixed: 14.10.2
Upgrade Magick.NET-Q16-x86 to 14.10.2
Magick.NET-Q16-OpenMP-x64 fixed: 14.10.2
Upgrade Magick.NET-Q16-OpenMP-x64 to 14.10.2
Magick.NET-Q16-OpenMP-arm64 fixed: 14.10.2
Upgrade Magick.NET-Q16-OpenMP-arm64 to 14.10.2
Magick.NET-Q16-HDRI-x64 fixed: 14.10.2
Upgrade Magick.NET-Q16-HDRI-x64 to 14.10.2
Magick.NET-Q16-HDRI-arm64 fixed: 14.10.2
Upgrade Magick.NET-Q16-HDRI-arm64 to 14.10.2
Magick.NET-Q16-HDRI-x86 fixed: 14.10.2
Upgrade Magick.NET-Q16-HDRI-x86 to 14.10.2
Magick.NET-Q16-HDRI-OpenMP-x64 fixed: 14.10.2
Upgrade Magick.NET-Q16-HDRI-OpenMP-x64 to 14.10.2
Magick.NET-Q16-HDRI-OpenMP-arm64 fixed: 14.10.2
Upgrade Magick.NET-Q16-HDRI-OpenMP-arm64 to 14.10.2
Magick.NET-Q8-AnyCPU fixed: 14.10.2
Upgrade Magick.NET-Q8-AnyCPU to 14.10.2
Magick.NET-Q16-AnyCPU fixed: 14.10.2
Upgrade Magick.NET-Q16-AnyCPU to 14.10.2
Magick.NET-Q16-HDRI-AnyCPU fixed: 14.10.2
Upgrade Magick.NET-Q16-HDRI-AnyCPU to 14.10.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for Magick.NET-Q8-x64

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-23874, inspect your project dependencies for ImageMagick MSL:

inspect dependencies for Magick.NET-Q8-x64

Analyze the terminal output to locate any version of ImageMagick MSL in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 14.10.2), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop'), where the product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop. In ImageMagick MSL, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## 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

CVE-2026-23874 Affected ImageMagick MSL Versions

18 component(s)
Fixed Versions:
14.10.2
Product / Package Ecosystem Affected Versions Fixed Version
Magick.NET-Q8-x64
NuGet
< 14.10.2
14.10.2
Magick.NET-Q8-arm64
NuGet
< 14.10.2
14.10.2
Magick.NET-Q8-x86
NuGet
< 14.10.2
14.10.2
Magick.NET-Q8-OpenMP-x64
NuGet
< 14.10.2
14.10.2
Magick.NET-Q8-OpenMP-arm64
NuGet
< 14.10.2
14.10.2
Magick.NET-Q16-x64
NuGet
< 14.10.2
14.10.2
Magick.NET-Q16-arm64
NuGet
< 14.10.2
14.10.2
Magick.NET-Q16-x86
NuGet
< 14.10.2
14.10.2
Magick.NET-Q16-OpenMP-x64
NuGet
< 14.10.2
14.10.2
Magick.NET-Q16-OpenMP-arm64
NuGet
< 14.10.2
14.10.2
Magick.NET-Q16-HDRI-x64
NuGet
< 14.10.2
14.10.2
Magick.NET-Q16-HDRI-arm64
NuGet
< 14.10.2
14.10.2
Magick.NET-Q16-HDRI-x86
NuGet
< 14.10.2
14.10.2
Magick.NET-Q16-HDRI-OpenMP-x64
NuGet
< 14.10.2
14.10.2
Magick.NET-Q16-HDRI-OpenMP-arm64
NuGet
< 14.10.2
14.10.2
Magick.NET-Q8-AnyCPU
NuGet
< 14.10.2
14.10.2
Magick.NET-Q16-AnyCPU
NuGet
< 14.10.2
14.10.2
Magick.NET-Q16-HDRI-AnyCPU
NuGet
< 14.10.2
14.10.2

References

Frequently Asked Questions

What is CVE-2026-23874?
CVE-2026-23874 is a security vulnerability in ImageMagick MSL involving Stack overflow via infinite recursion in ProcessMSLScript under CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop').
Which ImageMagick MSL versions are affected?
Affected versions include releases prior to 14.10.2 across affected packages: Magick.NET-Q8-x64, Magick.NET-Q8-arm64, Magick.NET-Q8-x86, Magick.NET-Q8-OpenMP-x64, Magick.NET-Q8-OpenMP-arm64, Magick.NET-Q16-x64, Magick.NET-Q16-arm64, Magick.NET-Q16-x86, Magick.NET-Q16-OpenMP-x64, Magick.NET-Q16-OpenMP-arm64, Magick.NET-Q16-HDRI-x64, Magick.NET-Q16-HDRI-arm64, Magick.NET-Q16-HDRI-x86, Magick.NET-Q16-HDRI-OpenMP-x64, Magick.NET-Q16-HDRI-OpenMP-arm64, Magick.NET-Q8-AnyCPU, Magick.NET-Q16-AnyCPU, Magick.NET-Q16-HDRI-AnyCPU.
What version fixes CVE-2026-23874?
Upgrading to 14.10.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is Magick.NET-Q8-x64 affected?
Yes, Magick.NET-Q8-x64 is affected in releases prior to 14.10.2. Upgrade your dependency to 14.10.2 or later.
Is Magick.NET-Q8-arm64 affected?
Yes, Magick.NET-Q8-arm64 is affected in releases prior to 14.10.2. Upgrade your dependency to 14.10.2 or later.
What is the CVSS score of CVE-2026-23874?
CVE-2026-23874 has a CVSS v3.1 base score of 5.5 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2026-23874?
CVE-2026-23874 is classified under CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop') (The product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.).
How can I check NuGet dependencies for CVE-2026-23874?
Run the dependency tree command: 'inspect dependencies for Magick.NET-Q8-x64'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-9vj4-wc7r-p844",
  "modified" : "2026-01-21T01:05:23Z",
  "published" : "2026-01-21T01:05:23Z",
  "aliases" : [ "CVE-2026-23874" ],
  "summary" : "ImageMagick MSL: Stack overflow via infinite recursion in ProcessMSLScript",
  "details" : "## Summary\n\nStack overflow via infinite recursion in MSL (Magick Scripting Language) `<write>` command when writing to MSL format.\n\n## Version\n\n- ImageMagick 7.x (tested on current main branch)\n- Commit: HEAD\n- Requires: libxml2 support (for MSL parsing)\n\n## Steps to Reproduce\n\n### Method 1: Using ImageMagick directly\n\n```bash\nmagick MSL:recursive.msl out.png\n```\n\n### Method 2: Using OSS-Fuzz reproduce\n\n```bash\npython3 infra/helper.py build_fuzzers imagemagick\npython3 infra/helper.py reproduce imagemagick msl_fuzzer recursive.msl\n```\n\nOr run the fuzzer directly:\n```bash\n./msl_fuzzer recursive.msl\n```\n\n## Expected Behavior\n\nImageMagick should handle recursive MSL references gracefully by detecting the loop and returning an error.\n\n## Actual Behavior\n\nStack overflow causes process crash:\n\n```\nAddressSanitizer:DEADLYSIGNAL\n==PID==ERROR: AddressSanitizer: stack-overflow\n    #0 MSLStartElement /src/imagemagick/coders/msl.c:7045\n    #1 xmlParseStartTag /src/libxml2/parser.c\n    #2 xmlParseChunk /src/libxml2/parser.c:11273\n    #3 ProcessMSLScript /src/imagemagick/coders/msl.c:7405\n    #4 WriteMSLImage /src/imagemagick/coders/msl.c:7867\n    #5 WriteImage /src/imagemagick/MagickCore/constitute.c:1346\n    #6 MSLStartElement /src/imagemagick/coders/msl.c:7045\n    ... (infinite recursion, 287+ frames)\n```\n\n## Root Cause Analysis\n\nIn `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()`.\n\nIf the MSL file references itself (directly or indirectly), this creates an infinite recursion loop:\n\n```\nMSLStartElement() → WriteImage() → WriteMSLImage() → ProcessMSLScript()\n    → xmlParseChunk() → MSLStartElement() → ... (infinite loop)\n```\n\n## Impact\n\n- **DoS**: Guaranteed crash via stack exhaustion\n- **Affected**: Any application using ImageMagick to process user-supplied MSL files\n\n## Additional Trigger Paths\n\nThe `<read>` command can also trigger recursion:\n\nIndirect recursion is also possible (a.msl → b.msl → a.msl).\n\n## Fuzzer\n\nThis issue was discovered using a custom MSL fuzzer:\n\n```cpp\n#include <cstdint>\n#include <Magick++/Blob.h>\n#include <Magick++/Image.h>\n#include \"utils.cc\"\n\nextern \"C\" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)\n{\n  if (IsInvalidSize(Size))\n    return(0);\n  try\n  {\n    const Magick::Blob blob(Data, Size);\n    Magick::Image image;\n    image.magick(\"MSL\");\n    image.fileName(\"MSL:\");\n    image.read(blob);\n  }\n  catch (Magick::Exception)\n  {\n  }\n  return(0);\n}\n```\n\nThis issue was found by Team FuzzingBrain @ Texas A&M University",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Magick.NET-Q8-x64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "14.10.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Magick.NET-Q8-arm64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "14.10.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Magick.NET-Q8-x86"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "14.10.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Magick.NET-Q8-OpenMP-x64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "14.10.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Magick.NET-Q8-OpenMP-arm64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "14.10.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Magick.NET-Q16-x64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "14.10.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Magick.NET-Q16-arm64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "14.10.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Magick.NET-Q16-x86"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "14.10.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Magick.NET-Q16-OpenMP-x64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "14.10.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Magick.NET-Q16-OpenMP-arm64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "14.10.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Magick.NET-Q16-HDRI-x64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "14.10.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Magick.NET-Q16-HDRI-arm64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "14.10.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Magick.NET-Q16-HDRI-x86"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "14.10.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Magick.NET-Q16-HDRI-OpenMP-x64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "14.10.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Magick.NET-Q16-HDRI-OpenMP-arm64"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "14.10.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Magick.NET-Q8-AnyCPU"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "14.10.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Magick.NET-Q16-AnyCPU"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "14.10.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "NuGet",
      "name" : "Magick.NET-Q16-HDRI-AnyCPU"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "14.10.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ImageMagick/ImageMagick/security/advisories/GHSA-9vj4-wc7r-p844"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-23874"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ImageMagick/ImageMagick"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/dlemstra/Magick.NET/releases/tag/14.10.2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-835" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-01-21T01:05:23Z",
    "nvd_published_at" : "2026-01-20T01:15:57Z"
  }
}