Pillow: Heap buffer overflow in FlashPix JPEG decoding leads to code execution
Summary
Pillow, the Python imaging library, contains a heap buffer overflow in its FlashPix (FPX) JPEG-tile decoder. A crafted OLE2 FlashPix file can cause decoded image data to be written beyond the allocated tile buffer, which can corrupt heap memory and may allow arbitrary code execution. The flaw is triggered when an application opens untrusted files with Pillow while the optional olefile dependency is installed, for example upload, thumbnailing or conversion services. A public proof of concept exists.
Affected
- Pillow versions before 13.0.0 (GitHub advisory lists affected versions as <= 12.3.0)
- Only installations with the optional olefile dependency are affected by the FPX code path
- Minimum affected version: Unknown.
Fixed in
- Fixed in Pillow 13.0.0
- Upgrade command: pip install -U "Pillow>=13.0.0"
- Pillow 13 requires Python 3.11 or newer.
Workaround
- No official workaround is documented.
- Removing the optional olefile package removes the trigger path, but this is an unverified inference and must be tested first.
- Do not process untrusted uploads in privileged processes; isolate image processing in a minimally privileged container.
Exploitation
- Public proof of concept: Yes, included in the GitHub advisory.
- Known exploitation in the wild: Not reported.
- CISA SSVC: Exploitation poc, automatable no, technical impact total.
- Not listed in CISA KEV.
Our recommendation
- Identify all Pillow installations, including containers, images and transitive dependencies.
- Upgrade to Pillow 13.0.0 or later and rebuild affected containers and bundles.
- Where a downstream package pins Pillow below 13, ask the vendor for a fix and apply interim isolation.
- Check whether olefile is installed and whether it is needed.
- Prioritise internet-facing services that process uploads.
Public exploits
Links to third-party sites, not checked by us – exploit code can contain malware. Only use it in isolated test environments.
- Proof of concept on GitHub (1 repositories)
mcpmark-eval-liuhezi/security-advisory-research
Research sources
- GHSA-5x8w-8jj5-q52h Security Advisory github.com
- Pillow 13.0.0 Release github.com
- Fix commit 242a059 github.com
- Pillow 13.0.0 Release Notes pillow.readthedocs.io
- GitLab Advisory Database entry advisories.gitlab.com
- Strix CVE summary www.strix.ai
Researched and written up in English and German by an AI (Claude by Anthropic) based on NVD, CISA, EPSS and the sources listed. The vendor information is authoritative. Researched on 31 Oct 2026, 04:14.
Original description (NVD)
Pillow is a Python imaging library. Prior to 13.0.0, Pillow's FlashPix JPEG-tile decoder can write decoded scanlines beyond the allocated tile buffer. FlashPix (FPX) JPEG decoding selects raw mode LA with two bytes per pixel, while an unrecognized JPEG mode can be decoded as JCS_UNKNOWN with four components, causing ImagingJpegDecode to write four-component scanlines into the two-byte tile buffer. An attacker can supply a crafted OLE2 FlashPix file to an application with the optional olefile dependency installed that opens or thumbnails untrusted input. This can corrupt heap memory and may allow arbitrary code execution. This issue is fixed in version 13.0.0.
NVD references (4)
- https://github.com/python-pillow/Pillow/commit/242a059aedc1935097d9aa1dc3f099750467ba75
- https://github.com/python-pillow/Pillow/releases/tag/13.0.0
- https://github.com/python-pillow/Pillow/security/advisories/GHSA-5x8w-8jj5-q52h
- https://github.com/python-pillow/Pillow/security/advisories/GHSA-5x8w-8jj5-q52h
Sources
The tracker combines official, freely usable data sources – updated continuously:
- NVD (NIST) – CVEs, rating (CVSS), affected products
- CISA KEV – vulnerabilities confirmed by CISA as actively exploited
- CISA Vulnrichment – CISA assessment (SSVC) in the official CVE record
- FIRST EPSS – probability of exploitation
- Microsoft MSRC – Patch Tuesday: vulnerabilities, severity, updates
- PoC-in-GitHub – public proof-of-concept repositories
- Metasploit (Rapid7) – modules of the Metasploit Framework
- Exploit-DB (OffSec) – archive of public exploits (links only)
- Patch days: official vendor pages (linked per vendor) (Vendor patch days)
This product uses data from the NVD API but is not endorsed or certified by the NVD. EPSS data © FIRST.org.
Affected? We can help.
We check whether your systems are affected, install updates and close the gap – continuously with the System Health Checker if you wish.
