Skip to main content
Vulnerability Database/CVE-2026-96642

CVE-2026-96642: Pillow TarIO DOS Vulnerability

CVE-2026-96642 is a denial of service vulnerability in Pillow Python imaging library that causes infinite loops and CPU exhaustion. This post covers the technical details, affected versions, and mitigation strategies.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2026-96642 Overview

CVE-2026-96642 is a denial-of-service vulnerability in Pillow, the widely used Python imaging library. The flaw resides in the TarIO initializer within src/PIL/TarIO.py. The parser accepts a negative octal member size and computes a backward seek that returns the file handle to the same 512-byte header. When the requested member name does not match, the loop re-reads the identical header indefinitely. This consumes a full CPU core and never returns control to the caller. The vulnerability is reached only when an application directly invokes PIL.TarIO.TarIO, not through the default Image.open() path. Pillow version 13.0.0 contains the fix.

Critical Impact

A crafted TAR archive with a negative octal member size causes an infinite loop in TarIO, exhausting a CPU core and producing a sustained denial-of-service condition in affected applications.

Affected Products

  • Python Pillow (PIL fork) versions prior to 13.0.0
  • Applications that directly call PIL.TarIO.TarIO to extract images from TAR archives
  • Downstream Python packages that re-export Pillow's TarIO interface

Discovery Timeline

  • 2026-10-21 - CVE CVE-2026-96642 published to NVD
  • 2026-10-22 - Last updated in NVD database

Technical Details for CVE-2026-96642

Vulnerability Analysis

The vulnerability is classified as an infinite loop condition [CWE-835], falling under the broader category of resource exhaustion denial of service. TarIO parses TAR archive headers to locate a named member containing an image. For each member, it reads a 512-byte header, extracts the declared member name and size, and advances the file pointer past the member body to reach the next header.

The size field in a TAR header is an octal ASCII string. Pillow converted this value without validating its sign. When the parsed size is negative, the alignment calculation (size + 511) & (~511) produces a non-positive offset. The subsequent io.SEEK_CUR call seeks backward to the same header the parser just processed. Because the attacker-chosen member name does not match the one requested by the caller, the loop restarts, re-reads the identical header, and repeats forever.

The EPSS score is 0.333%, reflecting low observed exploitation probability, but the triggering input is trivial to construct.

Root Cause

The root cause is missing input validation on the TAR member size field in TarIO.__init__. The parser trusted the octal size value directly from the archive header and used it to compute a relative seek. No sign or bounds check was performed before advancing the file handle, allowing a negative offset to reset parser progress.

Attack Vector

Exploitation requires an application to open an attacker-supplied TAR archive via PIL.TarIO.TarIO. The attacker crafts a TAR header whose size field encodes a negative octal value and whose member name does not match the caller's requested name. On parse, the worker thread enters an infinite loop and pins a CPU core. Repeated submissions can exhaust server capacity. The attack requires user interaction (UI:P) and no privileges.

python
# Patch from src/PIL/TarIO.py - validate the computed offset is positive
# Source: https://github.com/python-pillow/Pillow/commit/19b695fdcc5eddc37374e2b1645fc4185edaf71d
            if file == name:
                break

-            self.fh.seek((size + 511) & (~511), io.SEEK_CUR)
+            offset = (size + 511) & ~511
+            if offset <= 0:
+                msg = "offset must be positive"
+                raise ValueError(msg)
+            self.fh.seek(offset, io.SEEK_CUR)

        # Open region
        super().__init__(self.fh, self.fh.tell(), size)

The patch computes the aligned offset once, rejects any non-positive value with a ValueError, and only then performs the relative seek. See the GitHub Pillow Commit Update and GitHub Pillow Pull Request #10012 for the full change.

Detection Methods for CVE-2026-96642

Indicators of Compromise

  • Python worker processes sustaining 100% CPU on a single core while handling user-supplied TAR archives.
  • Request timeouts or hung image-processing jobs correlated with TAR uploads invoking PIL.TarIO.TarIO.
  • TAR archive headers whose size field decodes to a negative octal value when parsed.

Detection Strategies

  • Inventory Python environments and dependency manifests for Pillow releases earlier than 13.0.0 using pip list or SBOM scanners.
  • Audit application source code for direct imports of PIL.TarIO or from PIL import TarIO, which is the only reachable attack path.
  • Validate uploaded TAR archives at an application gateway by parsing headers and rejecting entries with non-positive size fields before passing them to Pillow.

Monitoring Recommendations

  • Alert on Python worker threads whose CPU time exceeds expected image-processing durations by a configurable threshold.
  • Log and sample TAR archives submitted to image-processing endpoints for offline analysis of malformed headers.
  • Enforce per-request CPU and wall-clock timeouts on image parsing to bound the impact of hung workers.

How to Mitigate CVE-2026-96642

Immediate Actions Required

  • Upgrade Pillow to version 13.0.0 or later across all production, staging, and build environments.
  • Identify applications that call PIL.TarIO.TarIO directly and prioritize patching those services first.
  • Add request-level timeouts to any endpoint that invokes Pillow on user-controlled input.

Patch Information

The fix is included in Pillow 13.0.0, released via GitHub Pillow Release 13.0.0. The underlying code change is tracked in GitHub Pillow Pull Request #10012 and the GitHub Security Advisory GHSA-3j72-p6qg-6xp7. Install the fixed release with pip install --upgrade "Pillow>=13.0.0".

Workarounds

  • Avoid calling PIL.TarIO.TarIO on untrusted archives; use Image.open() on extracted files instead, since the default path does not reach the vulnerable code.
  • Pre-validate TAR archive headers and reject members whose declared size is negative or exceeds expected bounds before handing them to Pillow.
  • Run image-processing workers under strict CPU-time and wall-clock limits using resource.setrlimit or container-level cgroup constraints to contain hung processes.
bash
# Upgrade Pillow to the patched release across environments
pip install --upgrade "Pillow>=13.0.0"

# Verify the installed version
python -c "import PIL; print(PIL.__version__)"

# Audit a codebase for direct TarIO usage
grep -RIn --include='*.py' -E 'from PIL import TarIO|PIL\.TarIO\.TarIO' .

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.