CVE-2026-62343
Executive Summary
CVE-2026-62343 describes a heap buffer over‑write vulnerability in ImageMagick versions prior to 6.9.13-51 and between 7.0.1-0 and 7.1.2-26. The flaw resides in the morphology operation when processing a user‑supplied kernel. An attacker who can provide a crafted kernel (e.g., via a malicious image file or command‑line argument) may trigger an out‑of‑bounds write on the heap, leading to potential memory corruption, denial of service, or possibly code execution. The CVSS score of 4.7 (Medium) reflects the requirement for local access or user interaction, but the impact can be serious in environments where ImageMagick is used to process untrusted images automatically.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
CVSS Breakdown & Threat Level
- Base Score: 4.7 (Medium)
- Attack Vector: Local (AV:L) – the attacker needs ability to supply a crafted kernel to the morphology operation.
- Attack Complexity: Low (AC:L) – no special conditions required.
- Privileges Required: Low (PR:L) – the user invoking ImageMagick must have rights to run the command.
- User Interaction: Required (UI:R) – the victim must process the malicious input.
- Scope: Unchanged (S:U)
- Confidentiality, Integrity, Availability Impact: Low (C:L, I:L, A:L)
Threat Level: Moderate. While not remotely exploitable without user interaction, the vulnerability affects a widely used image processing library. Attackers can chain it with other vulnerabilities (e.g., file upload handlers) to gain elevated access or cause service disruption.
Deep Dive & Mechanics
The morphology operation in ImageMagick applies a structuring element (kernel) to an image to perform operations like dilation, erosion, opening, or closing. The kernel is a matrix of values that defines the shape and size of the operation.
The vulnerability occurs when the kernel supplied by the user contains invalid dimensions or values that cause the internal buffer allocated for the morphological operation to be smaller than required. During the processing loop, the code writes pixel data beyond the allocated heap buffer, leading to an out‑of‑bounds write.
Specifically, the affected code path in MagickCore/morphology.c (or similar) does not properly validate the kernel’s size or content before iterating. A crafted kernel can cause x and y coordinates to exceed the allocated image region, resulting in a heap overflow.
The root cause is missing bounds checking on the kernel width/height against the image dimensions. This is a classic CWE-787 (Out‑of‑bounds Write) vulnerability.
Vulnerable vs. Patched Code
Vulnerable (e.g., ImageMagick 7.1.1-20):
// In morphology.c - simplified pseudo‑code
for (y = 0; y < kernel.height; y++) {
for (x = 0; x < kernel.width; x++) {
// No check that (offset_x + x) is within image bounds
pixel = GetImagePixel(image, origin_x + x, origin_y + y);
// Write to output buffer without bounds validation
output[out_index++] = process(pixel);
}
}
Patched (ImageMagick 7.1.2-26):
// Proper bounds checking added
for (y = 0; y < kernel.height; y++) {
for (x = 0; x < kernel.width; x++) {
int px = origin_x + x;
int py = origin_y + y;
if (px < 0 || px >= (int)image->columns ||
py < 0 || py >= (int)image->rows)
continue; // Skip out‑of‑range
pixel = GetImagePixel(image, px, py);
output[out_index++] = process(pixel);
}
}
The fix ensures that every pixel access is validated against the image dimensions before reading or writing.
Exploitation & Lab Setup
Red Team
Goal: Trigger heap overflow to cause denial of service or gain code execution.
Prerequisites:
- Vulnerable ImageMagick version (e.g., 7.1.1-20).
- Ability to supply a malformed image file or command‑line arguments containing a crafted kernel.
Proof‑of‑Concept Steps:
- Create a small PNG image (e.g., 10x10 pixels).
- Craft a kernel that specifies dimensions larger than the image (e.g., width=100, height=100 with arbitrary values).
- Use the morphology command:
(The kernel string contains invalid geometry that overflows the heap.)convert input.png -morphology Dilate "100x100:1,2,3,..." output.png - Observe crash (segmentation fault) or abnormal memory usage.
Note: As of this report, no public PoC exists. The above is hypothetical based on the vulnerability description.
Impact: Successful exploitation may lead to arbitrary write of controlled data, potentially allowing an attacker to overwrite function pointers or return addresses. However, modern mitigations (ASLR, stack canaries) make reliable code execution more difficult.
Blue Team
Detection & Prevention:
- Monitor ImageMagick processes for abnormal crashes or memory access violations.
- Use Address Sanitizer (ASan) when compiling ImageMagick in development environments.
- Validate kernel dimensions against image size before processing. (Patched version does this.)
- Restrict the use of
-morphologyto trusted inputs only. - Consider using a hardened ImageMagick configuration that disables morphology if not needed.
Hunting: Look for core dumps or crash logs generated by convert, magick, or other ImageMagick binaries. Correlate with recent image uploads or command invocations containing large kernel arguments.
Indicators of Compromise (IOCs)
- File Artifacts: Core dumps named
coreorconvert.corein working directories. - Process Logs: ImageMagick crash entries in
/var/log/syslogorjournalctlwith segfaults. - Network: None expected directly; exploitation is local.
- Memory: Heap allocations exceeding typical morphology operation sizes (e.g., > 10 MB for small images).
- Command‑line Traces: Invocations with
-morphologycontaining unusually large kernel dimensions.
Detection Engineering
YARA Rule (Binary & Memory)
rule CVE_2026_62343_ImageMagick_morphology {
meta:
description = "Detects malformed morphology kernel strings in files or memory"
author = "Elite DevSecOps"
date = "2026-01-01"
reference = "CVE-2026-62343"
severity = "medium"
strings:
$kernel_arg = /-morphology\s+[A-Za-z]+\s+"\d+x\d+:/ nocase
$large_dim = /"\d{3,}x\d{3,}:/ // kernel dimensions >= 100
condition:
$kernel_arg and $large_dim
}
Sigma Rule (Windows Event Log / Sysmon)
title: ImageMagick Morphology Exploit Attempt
id: d3f1c2e5-7a8b-4c9d-9e0f-1a2b3c4d5e6f
status: experimental
description: Detects invocation of ImageMagick with suspicious morphology kernel arguments indicating heap overflow attempt.
references:
- CVE-2026-62343
tags:
- attack.t1203
- cve.2026.62343
logsource:
category: process_creation
product: windows
detection:
selection:
Image|endswith:
- '\convert.exe'
- '\magick.exe'
CommandLine|contains: '-morphology'
filter:
CommandLine|re: '-morphology\s+\w+\s+"\d{1,2}x\d{1,2}:' # Legitimate small kernels
condition: selection and not filter
falsepositives:
- Legitimate use of large kernels by advanced users
- Automated image processing scripts
level: medium
Suricata Rule (Network – if transmitted via file upload)
alert http $HOME_NET any -> $EXTERNAL_NET any (
msg:"CVE-2026-62343 - ImageMagick morphology kernel in uploaded file";
content:"image/png"; http_content_type;
file_data;
content:"-morphology"; distance:0; within:100;
pcre:"/\d{3,}x\d{3,}:/";
classtype:attempted-admin;
sid:20260001;
rev:1;
)
Remediation & Mitigation
Immediate: Upgrade ImageMagick to versions 6.9.13-51 or 7.1.2-26 (or later). These releases contain the fix.
Compensating Controls:
- Use an application firewall or wrapper that validates command‑line parameters before passing to
convert/magick. - Disable the
-morphologyoperator in configuration files (e.g.,policy.xml) if not required:
(Note: This does not directly disable morphology but limits resource usage.)<policy domain="resource" name="width" value="8KP"/> <policy domain="resource" name="height" value="8KP"/> - Run ImageMagick in a sandboxed environment (e.g., Docker with strict seccomp profiles) to minimize impact of memory corruption.
- Monitor for abnormal process terminations and heap allocation spikes.
Vendor Response: The ImageMagick development team patched the issue in the mentioned versions. No official CVE details beyond the original description have been released.
Valters IT signature:
This report is prepared for educational and defensive purposes. Always verify patches and test in a staging environment before production deployment.