CVE-2026-55798: Pillow Windows Command Injection Vulnerability (CVSS 4.5)
Pillow, a widely-used Python image processing library, contains a command injection vulnerability in its Windows image viewer functionality. When Pillow opens an image file on Windows, it constructs a system command to display the image, but fails to properly escape the file path before passing it to the shell. An attacker can craft a malicious image file with shell metacharacters in its name—such as ampersands or pipes—to inject and execute arbitrary Windows commands with the privileges of the user running the Python application. The vulnerability requires user interaction (opening a file) and is fixed in version 12.3.0 and later.
Source data · NVD / CISA · public domain
- CVSS
- 3.1 · 4.5 MEDIUM · CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:L
- Weaknesses (CWE)
- CWE-78
- Affected products
- 1 configuration(s)
- Published / Modified
- 2026-07-06 / 2026-07-07
NVD description (verbatim)
Pillow is a Python imaging library. Prior to 12.3.0, WindowsViewer.get_command() constructed a cmd.exe shell command by directly embedding a file path into an f-string without escaping and passed the result to subprocess.Popen(..., shell=True), allowing shell metacharacters in the file path to inject arbitrary cmd.exe commands. This issue is fixed in version 12.3.0.
6 reference(s) · View on NVD →
SEC.co analysis · AI-assisted, reviewed against source
Technical summary
CVE-2026-55798 is an OS command injection vulnerability (CWE-78) in Pillow's WindowsViewer.get_command() function. The vulnerable code embeds a file path directly into an f-string without shell escaping, then passes the constructed command to subprocess.Popen() with shell=True. This allows cmd.exe metacharacters in the file path to break out of the quoted context and execute arbitrary commands. The attack vector is local, requires user interaction (opening an image), and succeeds only under specific conditions (high complexity: file must be opened via Pillow's image viewer on Windows). The severity is rated MEDIUM (CVSS 4.5) with impacts on confidentiality, integrity, and availability limited to the user's session context.
Business impact
Organizations and developers relying on Pillow for image processing face risk if they deploy applications that accept user-supplied image files and open them using Pillow's default viewer on Windows systems. A compromised image filename could lead to execution of malware, lateral movement within a network, or data exfiltration. The impact is typically scoped to the user account running the Python process, but in scenarios where applications run with elevated privileges or process images from untrusted sources (web uploads, cloud storage), the business consequences could include unauthorized system access or compromise of sensitive data. The requirement for user interaction limits the attack surface compared to network-facing vulnerabilities.
Affected systems
Pillow versions prior to 12.3.0 are affected. The vulnerability is specific to Windows environments where the image viewer functionality is invoked. Python applications using Pillow to handle image files on Windows systems are at risk, particularly those that: (1) process images with user-controlled or untrusted filenames, (2) open images programmatically using Pillow's viewer, or (3) run with elevated privileges. Linux and macOS systems are not affected due to differences in command construction for those platforms.
Exploitability
Exploitation requires local system access and user interaction—specifically, the target user must open a specially-crafted image file via Pillow's viewer. The attack cannot be triggered remotely or without user action. However, the technical bar for exploitation is relatively low: an attacker need only craft a filename containing standard shell metacharacters (e.g., `image.jpg & malicious.exe`) and convince a user to open it. This could occur through file sharing, email attachments, or shared repositories. No authentication or special privileges are required to create or distribute a malicious filename. The CVSS complexity rating (High) reflects the user interaction requirement and the local-only nature of the attack.
Remediation
Upgrade Pillow to version 12.3.0 or later. This version fixes the command injection by properly escaping file paths before passing them to the shell. For organizations unable to immediately upgrade, reduce risk by: (1) restricting the use of Pillow's image viewer on Windows systems where feasible, (2) using alternative image viewers or handling image display through other libraries, (3) implementing file naming policies to prevent metacharacters in image filenames, and (4) running Python applications with minimal necessary privileges rather than as administrator.
Patch guidance
Pillow 12.3.0 and all subsequent versions contain the fix. Verify the installed version using `pip show pillow` and upgrade via `pip install --upgrade pillow`. Organizations using Pillow as a dependency should update their requirements.txt or lock files to specify version 12.3.0 or later. If Pillow is vendored or pinned to a specific version, remove the pin and allow automatic patching, or explicitly update to 12.3.0+. Test the patched version in a development environment against any custom image-handling workflows before deploying to production.
Detection guidance
Monitor for attempts to open image files with suspicious filenames containing shell metacharacters (ampersands, pipes, semicolons, backticks, etc.). In application logs, look for subprocess execution originating from Pillow's viewer process on Windows systems, particularly unexpected child processes launched from Python interpreters. File access logs may show creation or modification of image files with unusual naming patterns. On Windows, enable Windows Defender Application Guard or AppLocker rules to restrict execution of unexpected processes spawned from Python applications. Network behavior monitoring is less useful since the attack is local, but endpoint detection and response (EDR) tools should alert on unexpected process spawning from Pillow operations.
Why prioritize this
This vulnerability merits timely attention but does not require emergency response. The CVSS score of 4.5 (MEDIUM) and the requirement for local user interaction limit the immediate threat scope. However, organizations should prioritize patching if they: (1) operate web applications that accept user-uploaded images and process them on Windows backend servers, (2) deploy Pillow-dependent tools on multi-user systems where untrusted users can interact with image files, or (3) use Pillow in automated workflows that might consume images from untrusted sources. Standard patch cycles (30–60 days) are acceptable for most environments, but teams managing public-facing image processing should expedite to 2–4 weeks.
Risk score, explained
The CVSS 3.1 score of 4.5 reflects a local attack vector with high complexity (user interaction and conditional exploitation), limited scope, and moderate impact (partial confidentiality, integrity, and availability). The score appropriately captures that this is not a critical, easily-exploitable flaw; however, the vulnerability is not negligible because command injection on Windows can have serious consequences if the conditions are met. The lack of CVSS Environmental or Temporal modifiers means organizations should adjust their internal risk rating based on whether they store/process untrusted image files and the privilege level at which Pillow runs.
Frequently asked questions
Can this vulnerability be exploited remotely?
No. The attack requires local system access and user interaction. The target user must open a specially-crafted image file using Pillow's viewer. There is no network-based exploitation vector.
Which operating systems are affected?
Only Windows systems are vulnerable because the command injection is specific to how Pillow constructs cmd.exe commands on Windows. Linux and macOS implementations use different system calls and are not affected.
If I use Pillow only for image processing (reading, resizing, etc.) and never open images with the viewer, am I at risk?
Your risk is substantially lower. The vulnerability is in the WindowsViewer.get_command() function, which is invoked only when explicitly opening an image for display. If your application processes images without calling the viewer, you are likely unaffected. However, upgrading to 12.3.0 is still recommended for defense-in-depth and to mitigate risk if Pillow's internal behavior changes in the future.
What should I do if I can't upgrade immediately?
Mitigate risk by restricting which users can open image files, enforcing strict naming conventions to reject files with shell metacharacters, running Pillow with minimal privileges (non-administrator), and using alternative image viewers when possible. Implement file-upload validation if your application accepts user-supplied images. Plan an upgrade to 12.3.0+ within 30–60 days depending on your environment's risk profile.
This analysis is based on the published CVE data and vendor advisory. The vulnerability information, CVSS score, and affected versions are provided as-is. SEC.co does not guarantee that all systems, configurations, or edge cases are covered. Organizations should verify patch applicability against their specific deployment environment and consult the official Pillow security advisory for authoritative guidance. Internal risk assessments should incorporate environmental factors such as application privileges, user behavior, and data sensitivity. This document is for informational purposes and should not be construed as legal or compliance advice. Source: NVD (public-domain), retrieved 2026-08-15. Analysis generated by SEC.co (claude-haiku-4-5).
Related vulnerabilities
- CVE-2026-10279MEDIUMOS Command Injection in wezterm-mcp 0.1.0
- CVE-2026-10544MEDIUMDevolutions Server PAM Command Injection Vulnerability
- CVE-2026-10805MEDIUMNetworkManager Local Privilege Escalation via Malformed MUD URL
- CVE-2026-11341MEDIUMD-Link DWR-M920 Command Injection Vulnerability – Patch & Detection Guide
- CVE-2026-11408MEDIUMOS Command Injection in vertex-app Log Viewer Endpoint
- CVE-2026-12814MEDIUMComfast CF-WR631AX V3 Command Injection Vulnerability
- CVE-2026-12815MEDIUMOS Command Injection in Coolify 4.0.0 Image Name Handler
- CVE-2026-13560MEDIUMEdimax EW-7478APC Command Injection Vulnerability