CVE-2026-112892: Pillow MSP RLE Decoder Memory Exhaustion Vulnerability
Summary
CVE-2026-112892: Pillow: MSP RLE decoder expands a tiny file into unbounded memory. Affects pillow versions >= 4.1.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 adds image processing capabilities to your Python interpreter. It supports opening, manipulating, and saving many different image file formats. The library is known for its ease of use and extensive functionality, making it a popular choice among developers. However, a recent vulnerability in the MSP RLE decoder has raised concerns regarding memory management, potentially allowing crafted images to exhaust system memory.
Vulnerability Detail
The vulnerability arises from the MSP RLE decoder's handling of run-length encoded data, which expands into an in-memory buffer without a cap based on the declared image size. This means that a small, specially crafted image file can lead to excessive memory allocation, potentially exhausting system resources and causing a denial of service. The issue is located in the MspImagePlugin.py file, where the decoder writes each run into an unbounded io.BytesIO object. The expansion factor can be as high as 85 times per run, making it possible for a tiny image to consume hundreds of megabytes of memory.
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, you can implement checks in your application to limit the size of images being processed. For example, you can set a maximum pixel count or restrict the types of images that can be uploaded or processed. Here is a sample code snippet to limit image size:
from PIL import Image
MAX_IMAGE_PIXELS = 1000000 # Set a maximum pixel limit
def load_image(file_path):
img = Image.open(file_path)
if img.size[0] * img.size[1] > MAX_IMAGE_PIXELS:
raise ValueError('Image exceeds maximum allowed size')
return img
Conclusion
In summary, CVE-2026-112892 is a significant vulnerability in the Pillow library that can lead to memory exhaustion through crafted image files. It is crucial for developers using Pillow to update to the latest version to mitigate this risk. Implementing additional checks can also help safeguard applications against potential exploitation.
See every vulnerability recorded for pillow →
FAQ
CVE-2026-112892 is a vulnerability in the Pillow library that allows a crafted image to cause excessive memory allocation, leading to potential denial of service.
If your application uses Pillow to process images, a malicious user could upload a specially crafted image that exhausts system memory, potentially crashing your application.
The vulnerability affects Pillow versions from 4.1.0 up to, but not including, 13.0.0.
You can use Vulert to monitor your application for vulnerabilities. It analyzes your Pipfile.lock to alert you in real-time about any open-source vulnerabilities.
The CVSS score for this vulnerability is 8.7, indicating a high severity level.
References
Related vulnerabilities
Recent vulnerabilities recorded for pillow.