The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2022-22817

CVE-2022-22817: Python Pillow RCE Vulnerability

CVE-2022-22817 is a remote code execution vulnerability in Python Pillow that allows arbitrary code execution through PIL.ImageMath.eval. This article covers the technical details, affected versions, security impact, and mitigation.

Published: February 18, 2026

CVE-2022-22817 Overview

CVE-2022-22817 is a critical code injection vulnerability in the Python Pillow library, specifically affecting the PIL.ImageMath.eval function. In versions prior to 9.0.0, this function allows evaluation of arbitrary Python expressions, including those that use dangerous built-in methods like exec. Attackers can exploit this flaw to execute arbitrary code by supplying malicious expressions, potentially through lambda expressions or direct Python code injection.

Critical Impact

Remote attackers can achieve full system compromise by injecting arbitrary Python code through the ImageMath.eval function, leading to complete loss of confidentiality, integrity, and availability.

Affected Products

  • Python Pillow versions prior to 9.0.0
  • Debian Linux 9.0 (Stretch)
  • Debian Linux 10.0 (Buster)
  • Debian Linux 11.0 (Bullseye)

Discovery Timeline

  • 2022-01-10 - CVE CVE-2022-22817 published to NVD
  • 2024-11-21 - Last updated in NVD database

Technical Details for CVE-2022-22817

Vulnerability Analysis

The PIL.ImageMath.eval function in Pillow is designed to evaluate mathematical expressions on images for pixel manipulation and image processing operations. However, the implementation failed to properly restrict the Python built-in functions available during expression evaluation. This oversight allows attackers to leverage dangerous Python built-ins such as exec, eval, and __import__ within the expression context.

The vulnerability is particularly severe because the function accepts string input that is directly evaluated as Python code. When applications pass user-controlled input to ImageMath.eval, attackers can craft malicious expressions that escape the intended mathematical context and execute arbitrary Python code with the same privileges as the running application.

Root Cause

The root cause of this vulnerability lies in the insufficient restriction of Python built-in functions exposed to the ImageMath.eval evaluation environment. Prior to version 9.0.0, Pillow did not implement adequate sandboxing or filtering of dangerous built-ins, allowing the full Python runtime to be accessible through crafted expressions. This represents a classic case of unsafe code evaluation where input validation was insufficient to prevent code injection attacks.

Attack Vector

This vulnerability is exploitable over the network when applications accept untrusted input and pass it to the PIL.ImageMath.eval function. The attack requires no authentication and no user interaction, making it particularly dangerous for web applications that process user-supplied image manipulation parameters. An attacker can craft a malicious expression containing Python code using the exec method or lambda expressions to achieve arbitrary code execution.

The exploitation technique involves injecting Python expressions that invoke dangerous built-in functions. For example, an attacker could inject an expression using exec() to import system modules and execute shell commands, or use lambda functions to bypass simple keyword filtering. The attack surface extends to any application that uses ImageMath.eval with user-controllable input.

Detection Methods for CVE-2022-22817

Indicators of Compromise

  • Unusual process spawning from Python applications that use Pillow for image processing
  • Unexpected network connections originating from image processing services
  • Log entries showing errors related to PIL.ImageMath.eval with suspicious expression strings
  • Presence of shell commands or Python code in application logs where image parameters are expected

Detection Strategies

  • Monitor Python application logs for expressions containing dangerous keywords like exec, eval, __import__, or lambda in image processing contexts
  • Implement application-level input validation to detect and block potentially malicious mathematical expressions
  • Deploy runtime application self-protection (RASP) solutions to detect code injection attempts in Python applications
  • Use SentinelOne's behavioral AI to detect anomalous process behavior from Python applications

Monitoring Recommendations

  • Enable detailed logging for all applications utilizing the Pillow library's ImageMath module
  • Set up alerts for process execution chains that originate from Python web applications or image processing services
  • Monitor file system changes and network activity from processes handling image manipulation
  • Implement canary tokens in sensitive directories to detect lateral movement following exploitation

How to Mitigate CVE-2022-22817

Immediate Actions Required

  • Upgrade Python Pillow to version 9.0.1 or later immediately, as this version includes comprehensive fixes for the vulnerability
  • Audit all applications using the PIL.ImageMath.eval function to identify potential exposure to untrusted input
  • Implement input validation to sanitize any user-supplied data before passing it to image processing functions
  • Consider temporarily disabling features that rely on ImageMath.eval if immediate patching is not possible

Patch Information

The Pillow development team addressed this vulnerability in version 9.0.0 by restricting the built-in functions available to ImageMath.eval. Additional security hardening was included in version 9.0.1. Organizations should update to the latest stable Pillow release to ensure complete protection. Detailed information about the security fixes is available in the Pillow Release Notes 9.0.0 and Pillow Release Notes 9.0.1.

For Debian systems, security updates are available through the standard package repositories. Refer to Debian Security Advisory DSA-5053 for platform-specific guidance.

Workarounds

  • Avoid passing user-controllable input to PIL.ImageMath.eval until the library can be updated
  • Implement a whitelist-based input validation that only allows known-safe mathematical expressions
  • Run image processing services in isolated containers with restricted system access to limit the impact of potential exploitation
  • Use network segmentation to prevent lateral movement if image processing services are compromised
bash
# Upgrade Pillow to patched version
pip install --upgrade pillow>=9.0.1

# Verify installed version
pip show pillow | grep Version

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

  • Vulnerability Details
  • TypeRCE

  • Vendor/TechPython Pillow

  • SeverityCRITICAL

  • CVSS Score9.8

  • EPSS Probability2.78%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityHigh
  • CWE References
  • NVD-CWE-noinfo
  • Technical References
  • Debian LTS Announcement 2022

  • Debian LTS Announcement 2024

  • Gentoo GLSA 202211-10

  • Debian Security Advisory DSA-5053
  • Vendor Resources
  • Pillow Release Notes 9.0.0

  • Pillow Release Notes 9.0.1
  • Related CVEs
  • CVE-2023-50447: Python Pillow RCE Vulnerability

  • CVE-2024-28219: Python Pillow Buffer Overflow Vulnerability

  • CVE-2025-48379: Python Pillow Buffer Overflow Vulnerability

  • CVE-2023-44271: Python Pillow DOS Vulnerability
Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English