CVE-2026-32741: libheif has a heap buffer overflow in decode_mask_image()
Last updated 19 June 2026
Other sources
libheif is a HEIF and AVIF file format decoder and encoder. Versions 1.21.2 and below contain a heap buffer overflow in MaskImageCodec::decodemaskimage(). When decoding a HEIF file containing a mask image (mski), the function copies the full iloc extent data into a pixel buffer using memcpy(dst, data.data(), data.size()). The copy length data.size() is determined by the iloc extent in the file (attacker-controlled), while the destination buffer is sized based on the declared image dimensions. Because no upper-bound check exists on the data length, a crafted file whose iloc extent exceeds the pixel buffer allocation overflows the heap. The vulnerable single-memcpy branch is reached when the mskC property specifies bitsperpixel = 8 and the ispe property declares an even width ≥ 64 (so that stride == width), with no changes to default security limits or external codec plugins required. This issue has been fixed in version 1.22.0.
— NVD
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
libheifto a version that resolves this vulnerability.Fixed in 1.22.0 - Compensating control
If you cannot upgrade yet, restrict decoding of untrusted HEIF/AVIF mask images (mski) to reduce exposure to MaskImageCodec::decode_mask_image() heap buffer overflow reachable via crafted iloc extents.
Event History
Frequently Asked Questions
What is the severity of CVE-2026-32741?
The severity of CVE-2026-32741 is high with a CVSS score of 7.1.
How do I fix CVE-2026-32741?
To fix CVE-2026-32741, upgrade to libheif version 1.22.0 or later.
What is CVE-2026-32741 about?
CVE-2026-32741 describes a heap buffer overflow in the libheif library's decode_mask_image function.
What versions of libheif are affected by CVE-2026-32741?
Libheif versions 1.21.2 and below are affected by CVE-2026-32741.
What could happen if CVE-2026-32741 is exploited?
If exploited, CVE-2026-32741 could lead to arbitrary code execution due to a heap buffer overflow.