CVE-2026-112396: Pillow Heap Use-After-Free Vulnerability in TIFF Encoding
Summary
CVE-2026-112396: Pillow: Heap use-after-free when encoding TIFF to an in-memory buffer. Affects pillow versions >= 11.3.0, < 13.0.0. Fixed in 13.0.0. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
Pillow is a widely used Python Imaging Library that provides extensive capabilities for opening, manipulating, and saving various image file formats. It is particularly known for its ease of use and integration with Python applications. However, it is susceptible to vulnerabilities, particularly when handling untrusted image data, which can lead to severe security issues such as memory corruption and potential remote code execution.
Vulnerability Detail
The vulnerability arises when saving an image as TIFF to an in-memory buffer. If libtiff rejects a tag during encoding, the encoder frees its output buffer but does not close the libtiff handle. This oversight leads to a heap use-after-free condition, where subsequent operations may write to the freed memory, resulting in application crashes or potential remote code execution. The issue is triggered specifically when the Predictor tag is set incorrectly, causing the TIFFWriteScanline function to fail.
How To Fix
Latest published version: 13.0.0 as of 22 Oct 2026
pip install --upgrade "pillow==13.0.0"
The newest release already contains this fix.
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a temporary workaround, avoid using the TIFF format for untrusted images or ensure that any image data being processed does not contain invalid tags that could trigger the vulnerability. Here is an example of code that could potentially trigger the vulnerability:
import io
from PIL import Image
# In-memory TIFF re-encode. Avoid using invalid tags.
im = Image.new("L", (64, 64))
buf = io.BytesIO()
im.save(buf, format="TIFF", compression="tiff_lzw", tiffinfo={317: 3}) # 317 = Predictor
Conclusion
The CVE-2026-112396 vulnerability in Pillow highlights a critical issue with heap use-after-free during TIFF encoding. Users are strongly advised to update to the latest version to mitigate risks associated with this vulnerability. Utilizing tools like Vulert can help monitor and manage open-source vulnerabilities effectively.
See every vulnerability recorded for pillow →
FAQ
The CVSS score of this vulnerability is 5.9, indicating a moderate severity level.
You can use Vulert, which monitors and alerts for open-source vulnerabilities in real-time. Visit Vulert Scanner to check if your application is affected without requiring any signup.
The potential consequences include application crashes and memory corruption, which could lead to remote code execution if exploited by an attacker.
Yes, version 13.0.0 and later of Pillow contains the necessary fixes for this vulnerability.
If you cannot update immediately, avoid processing untrusted images in TIFF format or ensure that the image data does not contain invalid tags that could trigger the vulnerability.
References
Related vulnerabilities
Recent vulnerabilities recorded for pillow.