TL;DR
Security researchers have publicly disclosed technical details and working proof-of-concept (PoC) exploit code for two critical libheif vulnerabilities. These memory corruption flaws allow attackers to achieve remote code execution by uploading crafted HEIC or AVIF images. System administrators must upgrade libheif to version 1.23.3 or newer immediately to protect their image-processing pipelines.
Why It Matters
The libheif library is an open-source ISO/IEC 23008-12 HEIF and AVIF file format decoder and encoder maintained by Struktur AG. While exact global installation figures are not specified in the vendor advisories, millions of web servers, Linux distributions, and content management systems rely on libheif through wrappers like ImageMagick, libvips, and sharp.
Because the full vulnerability details and a reproducible PoC exploit chain are now public, unpatched applications that process user-supplied images face immediate risk. Specifically, security researchers at Fortbridge published an exploit chain demonstrating how an authenticated user with media upload permissions can compromise WordPress servers running PHP-FPM and ImageMagick. However, although the public PoC exploit confirms remote code execution in targeted Ubuntu and Debian lab builds, no active exploitation in the wild has been confirmed.
How the Attack Works
Both libheif vulnerabilities stem from improper memory bounds validation when processing image planes and derived item structures.
Heap Buffer Overflow in Mixed-Interleave Decoding
First, the GHSA-x8r2-mggj-j6wr security advisory details a critical 9.8 CVSS heap-based buffer overflow (CWE-787) in the built-in ISO/IEC 23001-17 uncompressed-image (unci) decoder. In the mixed-interleave YCbCr decoding path, the parser allows paired Cb and Cr chroma components to declare different bit depths. For example, a crafted image can specify a 16-bit Cb channel alongside an 8-bit Cr channel.
During initialization, unc_decoder_legacybase::buildChannelListEntry() allocates each destination plane based on its own bit depth, giving the 8-bit Cr plane one byte per sample. However, unc_decoder_mixed_interleave::processTile() reuses the first chroma entry’s two-byte sample width and column offset when writing to both destinations. Consequently, the second chroma write overruns the smaller Cr heap buffer with attacker-controlled component data. This flaw is internal to libheif when compiled with WITH_UNCOMPRESSED_CODEC=ON and does not require external codecs.
Derived-Item Out-of-Bounds Read and Write
Second, the GHSA-2jg2-4ch7-h545 security advisory addresses a critical collection of 11 out-of-bounds read and write flaws reported via Meta’s Product Security team. These bugs occur in derived-item (iden and auxl) and pixel-plane handling. Specifically, they arise when mismatched plane sizes reach functions such as crop(), scale_nearest_neighbor(), and extract_area_plane() without proper size validation.
Chaining the Flaws for Remote Code Execution
In the publicly disclosed PoC exploit chain, attackers combine both vulnerability families to bypass Address Space Layout Randomization (ASLR) and execute commands. First, the attacker uploads disclosure images that abuse GHSA-2jg2-4ch7-h545 plane-geometry flaws to leak heap bytes and pointer relationships into generated thumbnail pixels. After downloading the thumbnails, attackers calculate the exact glibc and library base addresses. Then, the exploit generates a request-specific unci payload targeting GHSA-x8r2-mggj-j6wr. When uploaded, the heap overflow overwrites a live channel vector and installs a fake C++ dispatch structure. As a result, this hijacks control flow to run operating system commands as the www-data user.
Affected Versions
These libheif vulnerabilities impact different release ranges. GHSA-2jg2-4ch7-h545 affects all libheif versions up to and including 1.23.1. Meanwhile, GHSA-x8r2-mggj-j6wr affects libheif versions from 1.18.0 through 1.23.2 when built with the uncompressed codec enabled. Version 1.23.3 and later releases are not affected.
Patch and Mitigation Steps
Struktur AG patched GHSA-2jg2-4ch7-h545 in libheif version 1.23.2 and resolved GHSA-x8r2-mggj-j6wr in version 1.23.3. System administrators and developers must upgrade their underlying libheif packages and bundled dependencies (such as sharp or ImageMagick) to version 1.23.3 or newer immediately. If an immediate upgrade is impossible, defenders should recompile libheif without WITH_UNCOMPRESSED_CODEC=ON. In addition, they should block HEIC and AVIF file uploads at the web application level and restrict media upload privileges to trusted accounts.
Support Our Threat Intelligence
Find our vulnerability reports and weekly recaps helpful? Support our work today and unlock a 100% ad-free reading experience!