CVE-2026-112396: Pillow: Heap use-after-free when encoding TIFF to an in-memory buffer
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.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
Pillowto a version that resolves this vulnerability.Fixed in 13.0.0
Event History
Frequently Asked Questions
Which deployments are exposed to this issue?
Applications using Pillow versions from 11.3.0 up to, but not including, 13.0.0 are affected when they encode TIFF data to an in-memory BytesIO buffer with attacker-influenced TIFF tags.
What must an attacker be able to control to trigger the flaw?
The attacker needs to influence TIFF tag data supplied to an application’s TIFF-saving operation. The vulnerable path requires libtiff to reject a tag during encoding to BytesIO.
What is the impact if exploitation succeeds?
The use-after-free can crash the affected process. The advisory also states that it may enable code execution.
What version remediates the issue?
Upgrade Pillow to version 13.0.0, which contains the fix.