CVE-2026-32741

libheif has a heap buffer overflow in decode_mask_image()

Published May 19, 2026 CVSS 3.1 · 7.1 High EPSS < 1% KEV · Not listed
Description
libheif is a HEIF and AVIF file format decoder and encoder. Versions 1.21.2 and below contain a heap buffer overflow in MaskImageCodec::decode_mask_image(). 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 bits_per_pixel = 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.

Analysis

AI-generated

Technical impact

libheif contains a heap buffer overflow in the MaskImageCodec::decode_mask_image() function. When a HEIF file contains a mask image with an attacker‑controlled iloc extent, the copy length supplied to memcpy exceeds the size of the allocated pixel buffer. The resulting memory corruption can lead to arbitrary code execution or a denial‑of‑service. The vulnerability is triggered by a single memcpy branch that is reached when bits_per_pixel equals 8 and the image width is even and at least 64 pixels, without requiring changes to security limits or external plugins. It is inferred that any application that decodes HEIF/AVIF files using libheif is potentially exposed.

Affected Systems

Vendors: strukturag – libheif. Affected product versions: 1.21.2 and all earlier releases. The issue is resolved in libheif version 1.22.0 and later.

Risk and Exploitability

The CVSS score of 7.1 indicates a medium‑to‑high severity vulnerability. The EPSS score is not available, and the vulnerability is not listed in the CISA KEV catalog. It is inferred that the likely attack vector is delivery of a crafted HEIF file to an application that uses libheif for decoding—such as image viewers, editors, or web browsers—allowing an attacker to trigger the overflow by simply opening or processing the malicious file. No additional exploitation prerequisites beyond providing the malformed file are cited in the CVE description.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade libheif to version 1.22.0 or later where the memcpy bounds check has been added.
  • If an upgrade is not immediately possible, disable mask image decoding via the libheif API or configure the application to reject HEIF files containing mski mask images until the patch is applied.
  • Process HEIF files in a restricted, sandboxed environment to limit the impact of any potential memory corruption until a proper fix is deployed.

Generated by OpenCVE AI on May 20, 2026 at 01:21 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Debian DSA Debian DSA DSA-6417-1 libheif security update
Ubuntu USN Ubuntu USN USN-8454-1 libheif vulnerabilities
History
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'poc', 'Technical Impact': 'partial'}, 'version': '2.0.3'}

Type Values Removed Values Added
First Time appeared Struktur
Struktur libheif
Vendors & Products Struktur
Struktur libheif
Type Values Removed Values Added
Description libheif is a HEIF and AVIF file format decoder and encoder. Versions 1.21.2 and below contain a heap buffer overflow in MaskImageCodec::decode_mask_image(). 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 bits_per_pixel = 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.
Title libheif has a heap buffer overflow in decode_mask_image()
Weaknesses CWE-122
References
Metrics cvssV3_1

{'score': 7.1, 'vector': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:H'}

Weaknesses
  • CWE-120

    Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')

  • CWE-122

    Heap-based Buffer Overflow

Sources

Status
PUBLISHED
Assigner
GitHub_M
Published
Updated
Jul 15, 2026, 1:07 AM
Reserved
Mar 13, 2026, 3:02 PM
Status
Deferred
Published
May 19, 2026, 9:16 PM
Modified
Jul 24, 2026, 9:10 AM
Severity
Important
Public date
May 19, 2026, 7:57 PM