Vulnerability DatabaseCVE-2026-112396

CVE-2026-112396: 
Python vulnerability analysis and mitigation

Overview

CVE-2026-112396 is a heap use-after-free vulnerability in Pillow, the Python imaging library, affecting versions 11.3.0 through 12.3.0 (fixed in 13.0.0). The flaw occurs when libtiff rejects a tag during TIFF encoding to an in-memory buffer (e.g., BytesIO): the error path frees the output buffer without closing the TIFF handle, and subsequent cleanup flushes through the write callback into freed memory. This can crash the process and may enable remote code execution. It carries a CVSS v3.1 base score of 5.9 (Medium), classified under CWE-416 (Use After Free) and CWE-825 (Expired Pointer Dereference) (GitHub Advisory, Red Hat CVE).

Technical details

The root cause lies in ImagingLibTiffEncode in src/libImaging/TiffDecode.c: when TIFFWriteScanline fails (e.g., because libtiff rejects an invalid Predictor tag), the error path frees clientstate->data (the in-memory output buffer) but does not close or null out the TIFF handle (clientstate->tiff). During encoder teardown, ImagingLibTiffEncodeCleanup calls TIFFClose(tiff) because tiff is still set, which triggers a flush through _tiffWriteProc — writing into the already-freed buffer. The Predictor tag value 3 (floating-point predictor) on integer sample data is a convenient trigger, as libtiff will reject it and abort the write. The fix (commit dc95da2) restructures cleanup to call TIFFClose/TIFFCleanup before freeing clientstate->data, and removes premature free() calls from the encode error paths (GitHub Advisory, Fix Commit).

Impact

Successful exploitation causes a process crash (denial of service) and, depending on heap state, may enable memory corruption leading to arbitrary code execution. Any service that re-encodes attacker-influenced images to TIFF in memory — such as image thumbnailing, conversion pipelines, or web upload handlers — is at risk. There is no confidentiality or integrity impact per the CVSS scoring, but availability is fully compromised, and the potential for code execution introduces a broader risk to the hosting environment (GitHub Advisory).

Exploitability

A proof-of-concept is publicly documented in the GitHub Security Advisory, demonstrating that a minimal Python script using Image.save() with a crafted tiffinfo dictionary (Predictor tag set to 3) reliably triggers a segmentation fault or heap corruption. No exploit kits or in-the-wild exploitation have been reported as of the disclosure date. The EPSS score is 0.0, and the vulnerability is not listed in the CISA Known Exploited Vulnerabilities catalog. Exploitation requires no authentication or user interaction but has high attack complexity due to heap layout dependencies (GitHub Advisory, Red Hat CVE).

Exploitation steps

  1. Identify target: Find a web service or application that accepts image uploads and re-encodes them as TIFF to an in-memory buffer (e.g., using BytesIO) with Pillow versions 11.3.0–12.3.0.
  2. Craft malicious input: Prepare an image (any mode, e.g., grayscale L) to be saved as TIFF with LZW compression and a crafted tiffinfo dictionary setting tag 317 (Predictor) to value 3 (floating-point predictor, invalid for integer data).
  3. Trigger the vulnerability: Submit the crafted image to the target service, causing it to execute code equivalent to:
import io
from PIL import Image
im = Image.new("L", (64, 64))
buf = io.BytesIO()
im.save(buf, format="TIFF", compression="tiff_lzw", tiffinfo={317: 3})
  1. Observe outcome: libtiff rejects the Predictor tag, TIFFWriteScanline fails, the encoder frees clientstate->data, and subsequent TIFFClose during cleanup writes into freed memory — resulting in a segfault, heap corruption error, or (under favorable heap conditions) controlled memory write enabling code execution.
  2. Achieve objective: Depending on heap layout, the attacker may achieve denial of service (crash) or escalate to remote code execution within the process context of the image-processing service (GitHub Advisory).

Indicators of compromise

  • Logs: Application logs showing OSError: encoder error -2 when writing image file followed by unexpected process termination or crash reports when processing TIFF images.
  • Process: Segmentation fault (SIGSEGV) or corrupted double-linked list abort signals from the Python process handling image encoding; AddressSanitizer reports of heap-use-after-free in _tiffWriteProc / ImagingLibTiffEncodeCleanup.
  • File System: Core dump files generated by the image-processing service process after handling a TIFF save operation.
  • Network: Repeated upload requests containing TIFF images or images with unusual tiffinfo metadata (particularly tag 317 with value 3) from the same source IP (GitHub Advisory).

Mitigation and workarounds

Upgrade Pillow to version 13.0.0 or later, which contains the fix in commit dc95da2 that restructures the TIFF encoder cleanup to close the TIFF handle before freeing the output buffer. No configuration-based workaround is available; the only effective mitigation is upgrading. As an interim measure, applications can avoid saving TIFF images to in-memory buffers (BytesIO) with untrusted tiffinfo data, or validate/sanitize TIFF tag values (particularly tag 317/Predictor) before passing them to Pillow (Pillow 13.0.0 Release, Fix Commit).

Community reactions

The vulnerability was reported by security researcher MegaManSec and credited in the GitHub Security Advisory. The Pillow maintainers (radarhere, Andrew Murray, and others) addressed it promptly in the 13.0.0 release alongside numerous other security fixes. No significant broader media coverage or notable social media discussion has been identified beyond the standard advisory publication (GitHub Advisory, Pillow 13.0.0 Release).

Additional resources

Linux Distribution fix status

Fix availability across major Linux distributions and their releases.

Debian

Fixed

bookworm

pillow

Affected

sid

pillow: 13.0.0-1

Fixed

trixie

pillow

Affected

Ubuntu

Unknown

bionic (esm-infra)

pillow

Unknown

devel

pillow

Unknown

focal (esm-apps)

pillow-python2

Unknown

focal (esm-infra)

pillow

Unknown

jammy

pillow

Unknown

noble

pillow

Unknown

resolute

pillow

Unknown

trusty (esm-infra-legacy)

pillow

Unknown

RHEL / CentOS

Affected

RHEL 8

python-pillow.src

Affected

Source: This report was generated using AI

Related Python vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

GHSA-mpqx-q82w-9x46HIGH7.5
  • Python logoPython
  • graphql-core
NoYesOct 25, 2026
GHSA-4gm2-62xx-xwvxMEDIUM5.3
  • Python logoPython
  • aynops
NoYesOct 25, 2026
GHSA-jm75-qwf5-vg52MEDIUMN/A
  • Python logoPython
  • exmergo-dex-core
NoYesOct 25, 2026
GHSA-f3jf-cv9h-7c3gHIGHN/A
  • Python logoPython
  • exmergo-dex-core
NoYesOct 25, 2026
GHSA-28xv-9wpg-c42rHIGHN/A
  • Python logoPython
  • exmergo-dex-core
NoYesOct 25, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Additional Wiz resources

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management