CVE-2016-3076
Medium · 5.5CVSS
5.5
EPSS
2.6%
Published
Apr 24, 2017
CISA due date
—
Cloudanix analysis
A flaw in a popular image-processing software library can allow an attacker to crash an application by tricking it into opening a malicious image file.
- Exploitation
- Requires User Interaction
- Attacker needs
- User Interaction
- Complexity
- Low
- Impact
- Denial Of Service
- Component
- Library
- Class
- Memory Corruption
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
A heap-based buffer overflow exists in the `j2k_encode_entry` function of the Pillow library when processing Jpeg2000 (J2K) image files. An attacker can supply a specially crafted J2K file that causes the function to write data beyond the boundaries of an allocated buffer on the heap. This overwrites adjacent memory, leading to memory corruption and causing the application process to crash, resulting in a denial of service.
Why it matters to the business
Applications using the vulnerable Pillow library to process images can be crashed on demand by an attacker. This can lead to service unavailability and operational disruption. For example, a web application that processes user-uploaded images could be repeatedly taken offline, impacting user experience and business continuity. The primary risk is service availability, not data theft.
How an attack unfolds
An attacker crafts a malicious Jpeg2000 image file designed to trigger the buffer overflow. They then deliver this file to a target system, typically by uploading it to a web service or tricking a user into opening it with an application that uses a vulnerable version of Pillow. When the application attempts to parse or encode the malicious image, the overflow is triggered, corrupting memory and causing the application to crash immediately. This provides the attacker with a simple and reliable method to cause a denial of service.
How to fix it
The vulnerability affects Pillow versions 2.5.0 through 3.1.1 and was fixed in version 3.2.0. Upgrade the Pillow library to version 3.2.0 or later. This can typically be accomplished using a package manager like pip: `pip install --upgrade Pillow` If an immediate upgrade is not feasible, consider implementing controls to block or reject Jpeg2000 files before they are processed by the application as a temporary mitigation.
How to confirm the fix worked
To confirm remediation, verify that the installed version of the Pillow library is 3.2.0 or newer in all relevant application environments. You can check the version using the command `pip show Pillow` or by running `import PIL; print(PIL.__version__)` in a Python shell. To validate exposure, you can test a known proof-of-concept (PoC) file that triggers the vulnerability in a safe, non-production environment. A vulnerable application will crash, while a patched one should handle the file without crashing, possibly by raising an error.
Typical attack path
- An attacker creates a specially crafted Jpeg2000 image file.
- The attacker uploads the malicious file to a web application or sends it to a user via email or other means.
- The user or an automated system opens the file, triggering processing by the vulnerable Pillow library.
- The `j2k_encode_entry` function attempts to process the image, causing a heap buffer overflow.
- The memory corruption leads to an immediate crash of the application, resulting in a denial of service.
How to detect it
Monitor application and system logs for unexpected crashes or segmentation faults associated with image processing workflows. A spike in application restarts or process terminations could indicate exploitation attempts. If a crash is suspected, investigate the input file being processed at the time of the incident. The file is likely to be a malformed Jpeg2000 image. Correlating application crashes with the processing of specific J2K files is the primary method of detecting this attack.
What your security team should do
- Identify all applications in your environment that use the Python Pillow library and determine their version.
- Prioritize patching for internet-facing systems that process user-supplied images, as they represent the most direct attack vector.
- Upgrade all identified instances of Pillow to version 3.2.0 or a more recent stable version.
- If patching is not immediately possible, consider adding input validation logic to reject Jpeg2000 files as a short-term mitigation.
The record
Heap-based buffer overflow in the j2k_encode_entry function in Pillow 2.5.0 through 3.1.1 allows remote attackers to cause a denial of service (memory corruption) via a crafted Jpeg2000 file.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| PyPI | pillow | 2.5.0 | 3.1.2 |
| Debian:10 | pillow | 0 | 3.2.0-1 |
| Debian:11 | pillow | 0 | 3.2.0-1 |
| Debian:12 | pillow | 0 | 3.2.0-1 |
| Debian:13 | pillow | 0 | 3.2.0-1 |
| Debian:14 | pillow | 0 | 3.2.0-1 |
| Mageia:5 | python-pillow | 0 | 2.6.2-2.5.mga5 |
| SUSE:Enterprise Storage 4 | python-Pillow | 0 | 2.8.1-4.3.2 |
| SUSE:Enterprise Storage 5 | python-Pillow | 0 | 2.8.1-3.3.1 |
| SUSE:OpenStack Cloud 6 | python-Pillow | 0 | 2.7.0-4.3.1 |
| SUSE:OpenStack Cloud 7 | python-Pillow | 0 | 2.8.1-4.3.2 |
| Ubuntu:16.04:LTS | pillow | 0 | 3.1.2-0ubuntu1 |
| openSUSE:Tumbleweed | python-Pillow | 0 | 3.4.2-1.1 |
| openSUSE:Tumbleweed | python-Pillow | 0 | 8.3.2-1.2 |
| openSUSE:Tumbleweed | python-Pillow | 0 | 10.3.0-1.1 |
| pypi | Pillow | 2.5.0 | No fix |
Related vulnerabilities
- CVE-2026-25990 Pillow is a Python imaging library. Also affects pillow
- CVE-2025-48379 Pillow is a Python imaging library. Also affects pillow
- CVE-2024-28219 In _imagingcms.c in Pillow before 10.3.0, a buffer overflow exists because strcpy is used… Also affects pillow
- GHSA-4fx9-vc88-q2xc Infinite loop in Pillow Also affects pillow
- GHSA-jgpv-4h4c-xhw3 Uncontrolled Resource Consumption in pillow Also affects pillow
- CVE-2016-9190 Pillow before 3.3.2 allows context-dependent attackers to execute arbitrary code by using… Also affects pillow
- CVE-2016-9189 Pillow before 3.3.2 allows context-dependent attackers to obtain sensitive information by… Also affects pillow
- CVE-2016-4009 Integer overflow in the ImagingResampleHorizontal function in libImaging/Resample.c in… Also affects pillow