WordPress libheif Exploit Chain Turns Malicious HEIC Uploads Into Remote Code Execution

A critical flaw in libheif can allow a malicious HEIC upload to corrupt memory during WordPress image processing, creating a path to remote code execution in tightly matched server environments. The issue affects the unci uncompressed-image decoder and was patched in libheif version 1.23.3.

The vulnerability, tracked as GHSA-x8r2-mggj-j6wr, exists in libheif’s handling of mixed-interleave YCbCr images. An attacker-crafted HEIC file can declare one chroma channel as 16-bit and another as 8-bit.

Libheif allocates memory based on the actual size of each channel. However, the vulnerable decoder uses the 16-bit channel’s width when writing data to both channels.

As a result, it writes beyond the smaller 8-bit Cr plane and causes an attacker-controlled heap buffer overflow.

WordPress HEIC Uploads Enable-RCE

In a WordPress deployment, an authenticated user with permission to upload files typically an Author or higher could submit the malicious image through the Media Library.

The image may then pass through PHP Imagick, ImageMagick, and libheif while WordPress generates thumbnails or other derivatives.

The risk is significant because the upload itself appears normal from the web application’s perspective. The vulnerable operation takes place deeper in the server-side native image-processing stack, beyond the usual PHP and WordPress security controls.

The two validated native stacks (Source: fortbridge)
The two validated native stacks (Source: fortbridge)

Fortbridge researchers described an exploit chain that first uploads specially designed disclosure images, then retrieves WordPress-generated JPEG derivatives.

The returned image pixels can disclose memory data from the processing worker, including addresses needed to overcome Address Space Layout Randomization (ASLR).

The research claimed successful execution of the id command as the PHP-FPM www-data user on two exact lab configurations, Ubuntu 26.04 and Debian 13 systems running specific WordPress, PHP-FPM, ImageMagick, libheif, and glibc builds.

These results should not be interpreted as universal exploitation against all WordPress servers.

The advisory confirms that exploitation depends heavily on the exact environment. Attackers need compatible library versions, CPU architecture, C++ object layouts, heap behavior, worker continuity, and runtime addresses.

The crafted image controls the decoder vptr (Source: fortbridge)
The crafted image controls the decoder vptr (Source: fortbridge)

Wordfence researcher Alex Thomas independently demonstrated file disclosure and code-execution impact in one specific WordPress deployment using PHP Imagick, ImageMagick, and libheif.

The advisory cautioned that this does not establish portable or universal RCE across all libheif users.

A separate libheif advisory, GHSA-2jg2-4ch7-h545, addressed derived-image and pixel-plane handling flaws. It affected versions up to 1.23.1 and was fixed in 1.23.2; the newer mixed-interleave bug remained exploitable in 1.23.2 and required version 1.23.3, Fortbridge said.

Organizations should upgrade libheif to 1.23.3 or a vendor package containing the fix. They should also disable HEIC and AVIF uploads where unnecessary, isolate media processing in least-privileged containers, block script execution in upload directories, and investigate repeated PHP-FPM worker crashes or HTTP 503 responses after image uploads.

Join 16,000+ SOC teams using ANY.RUN to streamline threat investigations and reduce manual effort. Explore for your team 

Varshini
Varshini
Varshini is a Cyber Security expert in Threat Analysis, Vulnerability Assessment, and Research. Passionate about staying ahead of emerging Threats and Technologies..

Trending News

Related Stories