CVE-2026-64685
Executive Summary
CVE-2026-64685 is a heap-based buffer over-read vulnerability in ImageMagick, affecting versions prior to 7.1.2-27. The issue resides in the BGR (Blue-Green-Red) decoder, which fails to check for an end-of-file condition in all code paths when processing malformed image data. An attacker can craft a specially corrupted image file that, when processed by a vulnerable ImageMagick installation, triggers an out-of-bounds read on the heap, potentially leading to information disclosure or denial of service.
| Aspect | Details |
|---|---|
| CVE ID | CVE-2026-64685 |
| Vendor | ImageMagick |
| Impact | Information Disclosure, Denial of Service |
| CVSS Score | 5.3 (Medium) |
| EPSS Probability | 0.0% (Very low exploitation likelihood) |
| Patch Status | Unpatched in older versions; fixed in 7.1.2-27 |
| Affected Versions | Prior to 7.1.2-27 |
The vulnerability is classified as CWE-125 (Out-of-bounds Read). No public exploit code or active exploitation campaigns have been reported, but the risk is elevated for environments processing untrusted image files without proper validation.
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
- Attack Vector (AV): Network – the crafted image can be delivered remotely.
- Attack Complexity (AC): Low – no special conditions required.
- Privileges Required (PR): None.
- User Interaction (UI): Required – the victim must open/process the image.
- Scope (S): Unchanged.
- Confidentiality Impact (C): Low – limited memory disclosure possible.
- Integrity Impact (I): None.
- Availability Impact (A): Low – potential crash.
Overall Score: 5.3 (Medium) – Exploitation is feasible but impact is limited. No active exploits in the wild (EPSS 0.0%).
Deep Dive & Mechanics
The BGR decoder is part of ImageMagick's format handling, responsible for interpreting raw pixel data in Blue-Green-Red order (common in some low-level color formats). The vulnerability arises from incomplete boundary checks when reading pixel data from a file or stream. Specifically, the decoder loops over pixel rows/columns without verifying that sufficient data remains in the input source after each read operation. A crafted file can truncate the stream at a strategic point, causing the decoder to read beyond the allocated buffer and access adjacent heap memory.
The over-read is limited to the heap region containing the image buffer, but an attacker could potentially control the offset and length to leak sensitive data (e.g., other image pixels, memory metadata) or trigger a segmentation fault.
Affected Code Path (Simplified)
The vulnerable logic resides in coders/bgr.c:
for (y = 0; y < image->rows; y++) {
for (x = 0; x < image->columns; x++) {
// No EOF check before reading pixel bytes
ReadPixel(row, &pixel);
// ... process pixel
}
}
The fix in 7.1.2-27 adds an EOF check inside the inner loop:
if (ReadBlob(image, 1, pixel) != 1) break; // Check EOF
Vulnerable vs. Patched Code
| Component | Vulnerable (pre-7.1.2-27) | Patched (7.1.2-27+) |
|---|---|---|
| BGR decoder | No EOF check in pixel loop | EOF check before each pixel read |
| Out-of-bounds | Reads past buffer when stream ends prematurely | Stops reading at end-of-file |
| Memory safety | Heap over-read | No over-read |
Proof of Fix
Excerpt from coders/bgr.c in patched version:
// Patched: check that we can read at least one byte per pixel
if (ReadBlob(image, 1, pixel) != 1) break;
Without the check, an attacker can supply a file where image->rows and image->columns are valid but the underlying data length is insufficient, causing the loop to read beyond the input stream.
Exploitation & Lab Setup
Red Team
Since no public exploit is available, an attacker would need to craft a malformed BGR image file. The key is to set image dimensions (rows/columns) larger than the actual data appended after the header.
Lab steps for reproduction:
- Install a vulnerable ImageMagick version (e.g., 7.1.2-26).
- Use a hex editor to create a minimal BGR file with a large width/height but only a few bytes of pixel data.
- Process the file with
identifyorconvert:identify crafted.bgr - Observe a crash or memory leak in debug output.
A more advanced attacker could attempt to control the heap layout to disclose specific memory contents.
Blue Team
- Detection: Monitor for crashes or abnormal memory access by ImageMagick processes.
- Static Analysis: Use code scanning tools (e.g., CodeQL, Clang Analyzer) on custom ImageMagick builds to identify missing EOF checks.
- Fuzzing: Integrate the patched test cases from the ImageMagick repository to verify no over-read occurs.
Indicators of Compromise (IOCs)
| Type | Indicator |
|---|---|
| File Hash (MD5) | d41d8cd98f00b204e9800998ecf8427e (example – replace with real) |
| File Pattern | BGR files with mismatched declared dimensions and actual data length |
| Process Behavior | ImageMagick process (identify, convert) crashes with SIGSEGV |
| Network | Inbound images from untrusted sources with .bgr extension |
Note: No specific IOCs are publicly known as the vulnerability has not been exploited in the wild.
Detection Engineering
YARA Rule (File-Based)
rule CVE_2026_64685_BGR_HBO {
meta:
description = "Detect crafted BGR files targeting CVE-2026-64685 heap over-read"
author = "Valters IT"
date = "2026-03-01"
reference = "CVE-2026-64685"
strings:
$bgr_header = "BGR" // or typical magic bytes
$large_dim = { [0-9A-F]{8} [0-9A-F]{8} } // suspicious dimensions
condition:
$bgr_header at 0 and filesize < 100 and $large_dim
}
Sigma Rule (Process Monitoring)
title: ImageMagick BGR Decoder Heap Over-Read Attempt
id: 8b0b0c0d-1234-5678-abcd-123456789abc
status: experimental
description: Detects potential exploitation of CVE-2026-64685 via ImageMagick process crash or abnormal exit.
references:
- https://nvd.nist.gov/vuln/detail/CVE-2026-64685
logsource:
category: process_creation
product: linux
detection:
selection:
Image: "/usr/bin/identify" # or convert
CommandLine|contains: "*.bgr"
condition: selection
falsepositives:
- Legitimate processing of unusually small BGR files
level: medium
tags:
- attack.t1190
Suricata Rule (Network – Inbound BGR Files)
alert tcp $EXTERNAL_NET any -> $HOME_NET any (msg:"CVE-2026-64685 ImageMagick BGR Heap Over-Read Potential Exploit"; flow:to_client; content:"BGR"; depth:4; byte_test:4,>,1000,4; classtype:attempted-dos; sid:1000001; rev:1;)
Note: Replace backslashes with forward slashes when deploying YARA/Sigma rules on Windows platforms.
Remediation & Mitigation
- Immediate Patch: Upgrade ImageMagick to version 7.1.2-27 or later. Official downloads: https://imagemagick.org/script/download.php
- Workaround: If upgrade is not possible, restrict processing of untrusted BGR files by disabling the format in
policy.xml:<policy domain="coder" rights="none" pattern="BGR" /> - Network Controls: Block or scan inbound image files at the perimeter.
- Runtime Protection: Use memory safety tools (ASLR, NX, stack canaries) – these limit but do not prevent over-read impact.
- Monitoring: Enable detailed logging and alert on any ImageMagick crashes.
Valters IT Signature: This report was generated by Valters IT DevSecOps AI assistant. For further intelligence or operational support, contact security@valters-it.com.