CVE-2022-24303

9.1 CRITICAL

📋 TL;DR

This vulnerability in Pillow (Python Imaging Library) allows attackers to delete arbitrary files on the system due to improper handling of spaces in temporary pathnames. Attackers can exploit this by crafting malicious filenames that cause the library to misinterpret temporary file paths. Any application using vulnerable versions of Pillow for image processing is affected.

💻 Affected Systems

Products:
  • Pillow (Python Imaging Library)
Versions: All versions before 9.0.1
Operating Systems: All operating systems where Pillow is installed
Default Config Vulnerable: ⚠️ Yes
Notes: Any Python application using Pillow for image processing is vulnerable if it processes user-supplied images or filenames.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete system compromise through deletion of critical system files, potentially causing system crashes, data loss, or enabling further attacks by removing security controls.

🟠

Likely Case

Data loss or application disruption through deletion of application files, configuration files, or user data, leading to service outages or corrupted data.

🟢

If Mitigated

Limited impact with proper file permissions and sandboxing, potentially only affecting non-critical temporary files within the application's scope.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

The vulnerability is in the core library and can be triggered by processing specially crafted filenames. Public proof-of-concept exists in the GitHub pull request.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 9.0.1 and later

Vendor Advisory: https://pillow.readthedocs.io/en/stable/releasenotes/9.0.1.html#security

Restart Required: No

Instructions:

1. Update Pillow using pip: 'pip install --upgrade pillow>=9.0.1' 2. Verify the update with: 'pip show pillow' 3. Restart any running Python applications using Pillow.

🔧 Temporary Workarounds

Input Validation

all

Validate and sanitize all user-supplied filenames before passing to Pillow functions

Sandbox Execution

linux

Run Pillow in a container or sandbox with restricted file system access

docker run --read-only -v /tmp:/tmp:ro your_app

🧯 If You Can't Patch

  • Implement strict input validation to reject filenames containing spaces or special characters
  • Run the application with minimal file system permissions and in a chroot/jail environment

🔍 How to Verify

Check if Vulnerable:

Check Pillow version with: python -c "import PIL; print(PIL.__version__)" and verify it's below 9.0.1

Check Version:

python -c "import PIL; print(PIL.__version__)" or pip show pillow

Verify Fix Applied:

After updating, verify version is 9.0.1 or higher with: python -c "import PIL; print(PIL.__version__)"

📡 Detection & Monitoring

Log Indicators:

  • Unexpected file deletion errors
  • Permission denied errors for system files
  • Application crashes during image processing

Network Indicators:

  • None - this is a local file system vulnerability

SIEM Query:

source="application_logs" AND ("Permission denied" OR "FileNotFoundError" OR "OSError") AND process="python"

🔗 References

📤 Share & Export