CVE-2026-112396

Pillow: Heap use-after-free when encoding TIFF to an in-memory buffer

Published Oct 19, 2026 CVSS 3.1 · 5.9 Medium EPSS < 1% KEV · Not listed
Description
Pillow is a Python imaging library. From 11.3.0 until 13.0.0, Pillow has a heap use-after-free when libtiff rejects a tag while encoding TIFF data to an in-memory buffer. When an application saves attacker-influenced TIFF tags to BytesIO, libtiff can reject a tag during encoding in ImagingLibTiffEncode; the error path then frees the output buffer without closing or clearing the TIFF handle, and later cleanup flushes through the write callback into freed memory, which can crash the process and may enable code execution. This issue is fixed in version 13.0.0.

Analysis

AI-generated

Technical impact

A heap use‑after‑free occurs in Pillow between the 11.3.0 and 13.0.0 releases when libtiff rejects a tag during encoding TIFF data to an in‑memory buffer. The error path frees the output buffer, then cleanup writes through the callback into freed memory, which can crash the process and may lead to code execution. The weakness is classified as CWE‑416.

Affected Systems

The vulnerability affects the Pillow imaging library released by python‑pillow. Any installation of Pillow from version 11.3.0 up to and including 13.0.0 that uses the in‑memory buffer encoding path is susceptible. These versions are in active use in many Python applications that process TIFF images.

Risk and Exploitability

The CVSS score of 5.9 indicates moderate severity. No EPSS data is available, and the vulnerability is not listed in the CISA KEV catalog. Based on the description, it is inferred that an attacker must supply a TIFF document that contains malicious or malformed tags to the library while it writes to a BytesIO buffer. The attack is likely local to the process; if the application runs with elevated, the resulting code execution could be far more damaging. Detection of exploitation would typically be a crash or abnormal termination of the Python process.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade Pillow to version 13.0.0 or later.
  • If an upgrade is not immediately possible, avoid processing untrusted TIFF files with the in‑memory encoding path; validate or sanitize tags before passing them to Pillow.
  • If the application must continue using the affected version, isolate the TIFF encoding operation in a separate, restricted process or container so that a crash or code execution does not compromise the whole system.

Generated by OpenCVE AI on October 20, 2026 at 06:33 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Github GHSA Github GHSA GHSA-4rr5-89j8-mwwm Pillow: Heap use-after-free when encoding TIFF to an in-memory buffer
History
Type Values Removed Values Added
First Time appeared Python
Python pillow
CPEs cpe:2.3:a:python:pillow:*:*:*:*:*:*:*:*
Vendors & Products Python
Python pillow
Type Values Removed Values Added
Metrics ssvc

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

Type Values Removed Values Added
First Time appeared Python-pillow
Python-pillow pillow
Vendors & Products Python-pillow
Python-pillow pillow
Type Values Removed Values Added
Description Pillow is a Python imaging library. From 11.3.0 until 13.0.0, Pillow has a heap use-after-free when libtiff rejects a tag while encoding TIFF data to an in-memory buffer. When an application saves attacker-influenced TIFF tags to BytesIO, libtiff can reject a tag during encoding in ImagingLibTiffEncode; the error path then frees the output buffer without closing or clearing the TIFF handle, and later cleanup flushes through the write callback into freed memory, which can crash the process and may enable code execution. This issue is fixed in version 13.0.0.
Title Pillow: Heap use-after-free when encoding TIFF to an in-memory buffer
Weaknesses CWE-416
References
Metrics cvssV3_1

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

Weaknesses

Sources

Status
PUBLISHED
Assigner
GitHub_M
Published
Updated
Oct 20, 2026, 4:09 PM
Reserved
Oct 19, 2026, 4:58 PM
Status
Analyzed
Published
Oct 19, 2026, 10:17 PM
Modified
Oct 26, 2026, 9:00 PM
Severity
Moderate
Public date
Oct 19, 2026, 9:02 PM