CVE-2026-40310: 
C# vulnerability analysis and mitigation

Overview

CVE-2026-40310 is a heap out-of-bounds write vulnerability in the JP2 (JPEG 2000) encoder of ImageMagick, triggered when a user specifies an invalid sampling index. It affects all ImageMagick versions prior to 6.9.13-44 (6.x branch) and prior to 7.1.2-19 (7.x branch). The vulnerability was disclosed on April 13, 2026, with patches released the same day. It carries a CVSS v3.1 base score of 5.5 (Medium) (GitHub Advisory, Red Hat Bugzilla).

Technical details

The root cause is improper validation of a user-supplied sampling index in the JP2 encoder (coders/jp2.c), classified as CWE-122 (Heap-based Buffer Overflow), CWE-787 (Out-of-bounds Write), and CWE-1285 (Improper Validation of Specified Index, Position, or Offset in Input). The fix, applied in commit 3d653be, wraps the subsampling_dx and subsampling_dy assignments with MagickMax(..., 1.0) to enforce a minimum valid value, preventing out-of-bounds heap writes when an invalid (e.g., zero or negative) sampling factor is provided (GitHub Commit). Exploitation requires local access and user interaction — specifically, a user must process a maliciously crafted image file with an invalid sampling index through the JP2 encoder (GitHub Advisory).

Impact

Successful exploitation results in a denial of service through a crash of the ImageMagick process due to the heap out-of-bounds write. There is no confidentiality or integrity impact — the vulnerability's availability impact is rated High, while confidentiality and integrity impacts are None. The attack scope is unchanged, meaning the impact is confined to the ImageMagick process itself without lateral movement potential (GitHub Advisory, Red Hat Bugzilla).

Exploitability

There is no public proof-of-concept exploit and no evidence of in-the-wild exploitation at this time. The EPSS score is approximately 0.012% (0.000120), indicating a very low probability of exploitation in the near term. The vulnerability is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog. No threat actor attribution has been reported (Feedly, GitHub Advisory).

Exploitation steps

  1. Craft a malicious image file: Create or modify a JP2/JPEG 2000 image file that, when processed by ImageMagick, specifies an invalid (e.g., zero or negative) sampling index via the sampling_factor parameter.
  2. Deliver the file: Provide the crafted image to a target user or system that will process it with a vulnerable version of ImageMagick (below 6.9.13-44 or 7.1.2-19).
  3. Trigger encoding: Cause the target to invoke ImageMagick's JP2 encoder on the malicious file (e.g., via a command like convert malicious.jp2 output.png or through an application that uses ImageMagick for image processing).
  4. Achieve denial of service: The invalid sampling index bypasses validation, causing a heap out-of-bounds write in coders/jp2.c, which crashes the ImageMagick process (GitHub Commit, GitHub Advisory).

Indicators of compromise

  • Process: Unexpected crashes or segmentation faults in the ImageMagick process (convert, magick, or application processes embedding ImageMagick) when processing JP2/JPEG 2000 files.
  • Logs: Application or system logs showing ImageMagick process termination with signals such as SIGSEGV or SIGABRT, particularly when handling JP2 image files.
  • File System: Presence of suspicious or unexpected JP2 image files in directories processed by ImageMagick, especially files with unusual or minimal content.
  • System: Core dump files generated by ImageMagick crashes, potentially located in the working directory or system core dump path.

Mitigation and workarounds

Update ImageMagick to version 6.9.13-44 or later (6.x branch) or 7.1.2-19 or later (7.x branch). For .NET users, Magick.NET 14.12.0 incorporates the fix. As a workaround, restrict user access to JP2 encoding functionality if not required, and implement input validation to prevent processing of untrusted image files. Distribution-specific packages have been updated for openSUSE, Debian, and Amazon Linux 2/2023 (GitHub Advisory, Magick.NET Release, Red Hat Bugzilla).

Community reactions

The vulnerability was reported by researcher jakelamberson and published by ImageMagick maintainer dlemstra via GitHub Security Advisories on April 13, 2026. Red Hat tracked the issue as medium severity in their Bugzilla system. Downstream Linux distributions including openSUSE, Debian, and Amazon Linux issued security updates shortly after disclosure. No significant broader media coverage or notable community controversy has been observed (GitHub Advisory, Red Hat Bugzilla).

Additional resources

Linux Distribution fix status

Fix availability across major Linux distributions and their releases.

Debian

Fixed

bookworm

imagemagick: 8:6.9.11.60+dfsg-1.6+deb12u9

Fixed

sid

imagemagick: 8:7.1.2.19+dfsg1-1

Fixed

trixie

imagemagick: 8:7.1.1.43+dfsg1-1+deb13u8

Fixed

Ubuntu

Fixed

bionic (esm-infra)

imagemagick: 8:6.9.7.4+dfsg-16ubuntu6.15+esm17

Fixed

devel

imagemagick

Not Affected

focal (esm-apps)

imagemagick: 8:6.9.10.23+dfsg-2.1ubuntu11.11+esm15

Fixed

jammy

imagemagick

Affected

jammy (esm-apps)

imagemagick: 8:6.9.11.60+dfsg-1.3ubuntu0.22.04.5+esm15

Fixed

noble

imagemagick

Affected

noble (esm-apps)

imagemagick: 8:6.9.12.98+dfsg1-5.2ubuntu0.1~esm14

Fixed

resolute

imagemagick

Affected

RHEL / CentOS

Unknown

Alpine

Fixed

edge

imagemagick: 7.1.2.19-r0

Fixed

v3.23

imagemagick: 7.1.2.19-r0

Fixed

Source: This report was generated using AI

Related C# vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2026-106118HIGH7.5
  • C# logoC#
  • ImageSharp
NoYesOct 06, 2026
CVE-2026-106117HIGH7.5
  • C# logoC#
  • ImageSharp
NoYesOct 06, 2026
CVE-2026-106115HIGH7.5
  • C# logoC#
  • SixLabors.ImageSharp
NoYesOct 06, 2026
CVE-2026-106116MEDIUM5.3
  • C# logoC#
  • SixLabors.ImageSharp
NoYesOct 06, 2026
CVE-2026-106114MEDIUM5.3
  • C# logoC#
  • SixLabors.ImageSharp
NoYesOct 06, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management