Cloudanix VulnDB

CVE-2016-9189

Medium · 5.5

CVSS

5.5

EPSS

1.9%

Published

Nov 4, 2016

CISA due date

—

Cloudanix analysis

Schedule a fix SSVC: Track

A flaw in a widely-used software library for handling images could allow an attacker to steal sensitive application data by tricking the software into processing a specially crafted image file.

Chainable
Exploitation
Requires User Interaction
Attacker needs
User Interaction
Complexity
Low
Impact
Data Exposure
Component
Library
Class
Information Disclosure
Remediation
Upgrade
Effort
Medium
Patch risk
Low

What it actually does

An integer overflow vulnerability in the memory mapping function (Image.core.map_buffer) of the Pillow library allows for an out-of-bounds read. When processing a specially crafted image file, an application using a vulnerable version of the library can be forced to read from arbitrary memory locations within its own process space. This results in the disclosure of potentially sensitive information that should be protected.

Why it matters to the business

If your application processes images from untrusted sources (e.g., user uploads), it could be tricked into leaking sensitive data from its memory. This data may include user credentials, API keys, internal configuration, or other secrets. A successful exploit could lead to a data breach, regulatory fines, and a loss of customer trust. The vulnerability requires user interaction, such as uploading a malicious file, which is a common scenario for web applications.

How an attack unfolds

An attacker first creates a malicious image file with specific header values that, when parsed by the Pillow library, cause an integer overflow during a memory allocation calculation for a buffer. The attacker then delivers this file to a target application that uses a vulnerable version of Pillow for image processing, for instance, by uploading it to a website's profile picture feature. When the application attempts to open and map the image, the overflow leads to an out-of-bounds read. This copies sensitive data from the application's memory into a buffer, which may then be exposed to the attacker, for example, by being embedded in a resulting thumbnail image.

How to fix it

Upgrade the Python Pillow library to version 3.3.2 or later. Use your package manager to update the library, for example, by running `pip install --upgrade Pillow`. If Pillow is a dependency of another application or is installed via a system package manager (e.g., apt, yum), ensure the entire system or the specific package is updated to a version that includes the patched library. For environments using the affected `go-fips` packages listed, upgrade to version `1.21.10-r0` or newer.

How to confirm the fix worked

To confirm remediation, verify the version of the Pillow library installed in your application environments. You can check the version using `pip show Pillow` or `pip list | grep Pillow` in your virtual environment or container. Ensure the reported version is 3.3.2 or higher. Additionally, use a software composition analysis (SCA) tool to scan your codebase, dependencies, and container images to detect and confirm the absence of vulnerable Pillow versions.

Typical attack path

  1. An attacker crafts a malicious image file designed to trigger an integer overflow.
  2. The attacker identifies a target application that uses a vulnerable version of the Pillow library to process images.
  3. The attacker uploads the malicious image file to the target application or tricks a user into opening it.
  4. The application's Pillow library attempts to process the image, triggering the vulnerability.
  5. The application reads from an unintended memory location due to the out-of-bounds read.
  6. Sensitive data from the application's memory is leaked, potentially back to the attacker through the processed output.

How to detect it

Detecting a successful exploit is challenging as it may not cause a crash. Monitor application logs for crashes or segmentation faults specifically from image processing workers or threads, especially after handling an image file. A sudden crash in a process using `libImaging.so` could be an indicator. If possible, enable detailed logging for image processing functions to record metadata about processed files, which may help identify a malicious input file after a suspected incident. Analyzing memory dumps from a crashed process may reveal the malformed image data that triggered the memory corruption.

What your security team should do

  • Immediately patch any internet-facing systems that use the Pillow library to process images from untrusted sources.
  • Use software composition analysis (SCA) tools to scan all applications and container images to identify all instances of vulnerable Pillow versions (prior to 3.3.2).
  • Update all identified vulnerable instances to version 3.3.2 or later and redeploy the affected applications.
  • As a defense-in-depth measure, consider running image processing workloads in sandboxed, low-privilege environments to limit the potential impact of this and similar vulnerabilities.

The record

Pillow before 3.3.2 allows context-dependent attackers to obtain sensitive information by using the "crafted image file" approach, related to an "Integer Overflow" issue affecting the Image.core.map_buffer in map.c component.

Affected packages

Ecosystem Package Introduced Fixed
PyPI pillow 0 3.3.2
Debian:11 pillow 0 3.4.2-1
Debian:12 pillow 0 3.4.2-1
Debian:13 pillow 0 3.4.2-1
Debian:7 python-imaging 0 1.1.7-4+deb7u3
Debian:8 pillow 0 2.6.1-2+deb8u3
Mageia:5 python-pillow 0 2.6.2-2.6.mga5
SUSE:Enterprise Storage 4 python-Pillow 0 2.8.1-4.6.1
SUSE:Enterprise Storage 5 python-Pillow 0 2.8.1-3.3.1
SUSE:OpenStack Cloud 7 python-Pillow 0 2.8.1-4.6.1
Ubuntu:14.04:LTS pillow 0 2.3.0-1ubuntu3.4
Ubuntu:16.04:LTS pillow 0 3.1.2-0ubuntu1.1

Related vulnerabilities