CVE-2026-96642
Infinite loop in Pillow's TarIO due to negative octal size causing CPU hang.
- CVSS 7.1
- CWE-835
- Resource Management
- Local
Pillow is a Python imaging library. Prior to 13.0.0, the TarIO initializer in src/PIL/TarIO.py accepts a negative octal member size and computes a backward seek that returns to the same 512-byte header. When the requested member name does not match, the parser repeatedly reads that header, consumes a full CPU core, and never returns. TarIO is reached only when an application directly uses PIL.TarIO.TarIO rather than the default Image.open() path. This issue is fixed in version 13.0.0.
- CWE
- CWE-835
- CVSS base score
- 7.1
- Published
- 2026-10-21
- OWASP
- A06 Vulnerable and Outdated Components
- Orthogonal defect classification
- Timing/Serialization
- Code defect classification
- Timing Issues
- Category
- Resource Management
- Subcategory
- Resource Exhaustion
- Accessibility scope
- Local
- Impact
- Denial of Service (DoS)
- Affected component
- Pillow
- Fixed by upgrading
- Yes
Solution
Upgrade Pillow to version 13.0.0 or later.
Vulnerable code sample
import io
from PIL import TarIO
def extract_member(tar_stream: io.BytesIO, member_name: str) -> bytes:
"""
Extracts a file from a tar archive using Pillow's TarIO.
Vulnerable to infinite loop when a header has a negative octal size.
"""
# VULNERABLE: does not validate member size, allowing negative octal values
tar = TarIO(tar_stream)
for hdr in tar:
if hdr.name == member_name:
return hdr.read()
raise FileNotFoundError(f"{member_name} not found")Patched code sample
import io
from PIL import TarIO
def extract_member(tar_stream: io.BytesIO, member_name: str) -> bytes:
"""
Extracts a file from a tar archive using Pillow's TarIO.
Fixed by rejecting negative member sizes.
"""
# FIX: ensure member size is non‑negative before processing
tar = TarIO(tar_stream)
for hdr in tar:
if hdr.size < 0:
continue # skip malformed header
if hdr.name == member_name:
return hdr.read()
raise FileNotFoundError(f"{member_name} not found")Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- Offset to next TAR block must be positive (#10012) (python-pillow/Pillow)
src/PIL/TarIO.py · TarIO.__init__
Cite this entry
@misc{vaitp:cve202696642,
title = {{Infinite loop in Pillow's TarIO due to negative octal size causing CPU hang.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-96642},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-96642/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
