Cloudanix VulnDB

CVE-2016-0740

Medium · 6.5

CVSS

6.5

EPSS

2.7%

Published

Apr 13, 2016

CISA due date

—

Cloudanix analysis

Next patch cycle SSVC: Track

A flaw in a common software component for processing images could allow an attacker to compromise an application by tricking it into opening a malicious TIFF image file.

Exploitation
Requires User Interaction
Attacker needs
User Interaction
Complexity
Low
Impact
Data Tampering
Component
Library
Class
Memory Corruption
Remediation
Upgrade
Effort
Medium
Patch risk
Low

What it actually does

A buffer overflow vulnerability exists in the TIFF image decoding functionality of the Pillow library. When parsing a specially crafted TIFF file, the `ImagingLibTiffDecode` function fails to properly validate buffer sizes, allowing an attacker to write data beyond the intended memory boundaries. This memory corruption can lead to modification of application data and potentially arbitrary code execution in the context of the user running the application.

Why it matters to the business

Applications that process user-supplied TIFF images, such as those with file upload features, are at risk. An attacker could exploit this vulnerability to alter application data, disrupt service, or potentially take control of the application server. This can lead to data integrity loss, unauthorized actions performed by the application, and a stepping stone for further attacks within the network. Given the library's age, systems still vulnerable are likely unmaintained and pose a significant latent risk.

How an attack unfolds

An attacker crafts a malicious TIFF image file containing a payload designed to trigger a buffer overflow. They then submit this file to an application that uses a vulnerable version of the Pillow library for image processing, typically through a web-based file upload feature. When the application's backend attempts to decode the image, the overflow is triggered. This overwrites adjacent memory on the heap, which can corrupt application state or, with a carefully constructed payload, hijack the program's control flow to execute arbitrary code supplied by the attacker.

How to fix it

To remediate this vulnerability, upgrade the Pillow library to version 3.1.1 or later. For dependent products like Chainguard's cert-manager-fips-1.12, upgrade to version 1.12.9-r0 or newer. If an immediate upgrade is not possible, consider implementing mitigations such as disallowing TIFF file uploads or using a sandboxed, external service to convert or validate images before they are processed by the vulnerable application.

How to confirm the fix worked

To verify the vulnerability has been remediated, check the installed version of the Pillow library in your application's environment. Ensure it is version 3.1.1 or higher. This can typically be checked using package management tools like `pip list | grep Pillow`. You can also perform a security scan of your application's dependencies to detect any outdated and vulnerable versions of the library. Testing with a known proof-of-concept exploit file against a non-production instance should result in a safe error rather than a crash.

Typical attack path

  1. An attacker creates a malicious TIFF image file.
  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 file to the application, for example, as a profile picture or document.
  4. The application's backend attempts to parse the malicious TIFF file.
  5. The buffer overflow is triggered in the Pillow library, causing memory corruption.
  6. The attacker's payload executes, leading to data modification or arbitrary code execution within the application's process.

How to detect it

Detecting past exploitation can be challenging. Monitor for application crashes, segmentation faults, or unexpected restarts that correlate with image processing tasks, particularly involving TIFF files. Review application and system logs (e.g., syslog, Windows Event Viewer) for memory access violation errors or crashes originating from the application process. Forensic analysis of systems that have crashed may reveal malformed TIFF files in temporary directories or upload folders that were the root cause.

What your security team should do

  • Immediately upgrade all instances of the Pillow library to version 3.1.1 or later.
  • Use software composition analysis (SCA) tools to scan your environments and code repositories for any use of the vulnerable library.
  • If patching is delayed, implement strict input validation to block or sanitize TIFF files from untrusted sources as a temporary mitigation.
  • Prioritize patching internet-facing applications that allow image uploads from anonymous or untrusted users.

The record

Buffer overflow in the ImagingLibTiffDecode function in libImaging/TiffDecode.c in Pillow before 3.1.1 allows remote attackers to overwrite memory via a crafted TIFF file.

Affected packages

Ecosystem Package Introduced Fixed
PyPI pillow 0 3.1.1
Debian:11 pillow 0 3.1.1-1
Debian:12 pillow 0 3.1.1-1
Debian:13 pillow 0 3.1.1-1
Debian:8 pillow 0 2.6.1-2+deb8u2
Mageia:5 python-pillow 0 2.6.2-2.5.mga5
SUSE:Enterprise Storage 1.0 python-Pillow 0 2.7.0-7.1
SUSE:Enterprise Storage 2 python-Pillow 0 2.7.0-3.2
SUSE:Enterprise Storage 2.1 python-Pillow 0 2.7.0-3.1
SUSE:OpenStack Cloud 5 python-Pillow 0 2.7.0-9.1
SUSE:OpenStack Cloud 6 python-Pillow 0 2.7.0-3.1
Ubuntu:14.04:LTS pillow 0 2.3.0-1ubuntu3.2
Ubuntu:16.04:LTS pillow 0 3.1.1-1
openSUSE:Tumbleweed python-Pillow 0 3.4.2-1.1
openSUSE:Tumbleweed python-Pillow 0 3.1.1-4.1
openSUSE:Tumbleweed python-Pillow 0 8.3.2-1.2
openSUSE:Tumbleweed python-Pillow 0 10.3.0-1.1

Related vulnerabilities