CVE-2026-62291 Overview
CVE-2026-62291 is an out-of-bounds write vulnerability in libheif, an open-source HEIF and AVIF file format decoder and encoder maintained by Struktur AG. The flaw exists in versions 1.23.0 and earlier. A crafted image sequence containing a 2x2 primary plane and a 256x256 auxiliary alpha plane triggers heap corruption during a normal decode and re-encode workflow. The root cause is missing dimension validation between the main frame and the auxiliary alpha plane in Track_Visual::decode_next_image_sample(). The issue is fixed in version 1.23.1.
Critical Impact
Attacker-controlled heap corruption via a malformed HEIF image sequence can lead to out-of-bounds read and write primitives during standard decode and re-encode operations.
Affected Products
- libheif versions 1.23.0 and earlier
- Applications and services embedding libheif for HEIF/AVIF processing
- Image processing pipelines that decode and re-encode HEIF sequences
Discovery Timeline
- 2026-08-18 - CVE-2026-62291 published to NVD
- 2026-08-18 - Last updated in NVD database
Technical Details for CVE-2026-62291
Vulnerability Analysis
The vulnerability is classified as an out-of-bounds read/write [CWE-125] in the libheif uncompressed encoder path. During decoding of an image sequence track, Track_Visual::decode_next_image_sample() calls transfer_channel_from_image_as() without verifying that the auxiliary alpha plane dimensions match the main frame dimensions. The resulting HeifPixelImage object holds inconsistent component plane sizes when it reaches heif_track_decode_next_image() and subsequently heif_context_encode_image().
Inside unc_encoder::encode(), the function unc_encoder_component_interleave::encode_tile() allocates its output buffer using compute_tile_data_size_bytes() sized from the primary image dimensions. It then copies each component using the actual plane dimensions of that component. When the alpha plane is 256x256 while the primary is 2x2, the copy operation writes far beyond the buffer allocation, corrupting adjacent heap memory. The inverse case, where the alpha plane is smaller than the primary, produces an out-of-bounds read.
Root Cause
The root cause is a missing consistency check between component plane dimensions and the primary image dimensions in the uncompressed encoder. Buffer sizing and buffer population use two different sources of truth, violating the invariant that every component plane must match the primary image dimensions (or the expected chroma subsampling).
Attack Vector
Exploitation requires an attacker to supply a crafted HEIF image sequence that a target application decodes and re-encodes using libheif. User interaction is required to open or process the malicious file. The impact is local: attacker-controlled heap corruption within the process handling the image.
// Patch: libheif/codecs/uncompressed/unc_encoder.cc
// Reject uncompressed encode of images with mismatched component plane sizes (GHSA-xpw3-9rhw-482x)
Error unc_encoder::check_component_sizes(const std::shared_ptr<const HeifPixelImage>& src_image)
{
uint32_t image_width = src_image->get_width();
uint32_t image_height = src_image->get_height();
heif_chroma chroma = src_image->get_chroma_format();
for (uint32_t id : src_image->get_used_planar_component_ids()) {
heif_channel channel = src_image->get_component_channel(id);
uint32_t expected_width = image_width;
uint32_t expected_height = image_height;
if (channel == heif_channel_Cb || channel == heif_channel_Cr) {
if (chroma == heif_chroma_420) {
expected_width = (image_width + 1) / 2;
expected_height = (image_height + 1) / 2;
}
else if (chroma == heif_chroma_422) {
expected_width = (image_width + 1) / 2;
}
}
if (src_image->get_component_width(id) != expected_width ||
src_image->get_component_height(id) != expected_height) {
return {heif_error_Invalid_input,
heif_suberror_Unspecified,
"Image component plane size does not match the image dimensions"};
}
}
}
Source: libheif commit ac5521a
Detection Methods for CVE-2026-62291
Indicators of Compromise
- Process crashes or heap corruption reports in applications embedding libheif when processing HEIF sequences
- HEIF files containing image sequences with mismatched primary and auxiliary alpha plane dimensions
- Unexpected heif_error_Invalid_input errors after upgrading to 1.23.1, indicating previously mishandled malformed inputs
Detection Strategies
- Inventory all applications, container images, and services that statically or dynamically link libheif and identify versions at or below 1.23.0
- Instrument image processing workflows with AddressSanitizer or heap protection during testing to catch out-of-bounds writes
- Log and alert on abnormal terminations of image processing services that ingest untrusted HEIF content
Monitoring Recommendations
- Monitor endpoints and servers for crashes in processes that handle user-supplied HEIF/AVIF files
- Track file uploads containing HEIF sequences with auxiliary alpha channels and route them through sandboxed conversion services
- Correlate image decode failures with subsequent anomalous memory allocation or child process activity
How to Mitigate CVE-2026-62291
Immediate Actions Required
- Upgrade libheif to version 1.23.1 or later across all systems, containers, and dependent applications
- Rebuild and redistribute any statically linked binaries that embed libheif
- Restrict processing of untrusted HEIF image sequences until patched builds are deployed
Patch Information
The fix is available in libheif v1.23.1. The patch adds unc_encoder::check_component_sizes(), which validates that every component plane matches the primary image dimensions (accounting for chroma subsampling) before encoding proceeds. Full details are published in GitHub Security Advisory GHSA-xpw3-9rhw-482x.
Workarounds
- Disable HEIF sequence decode-and-re-encode workflows on unpatched systems
- Process untrusted HEIF content in isolated, sandboxed environments with strict resource limits
- Reject HEIF inputs that contain auxiliary alpha planes with dimensions differing from the primary plane
# Verify installed libheif version and update on Debian/Ubuntu
dpkg -l | grep libheif
sudo apt-get update && sudo apt-get install --only-upgrade libheif1
# Verify installed libheif version and update on RHEL/Fedora
rpm -q libheif
sudo dnf upgrade libheif
# Build from source (ensure 1.23.1 or later)
git clone --branch v1.23.1 https://github.com/strukturag/libheif.git
cd libheif && mkdir build && cd build
cmake --preset=release ..
make && sudo make install
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

