Description
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.
Published: 2026-07-06
Score: 4.5 Medium
EPSS: < 1% Very Low
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

Pillow, a widely used Python imaging library, contains an OS command injection flaw in the WindowsViewer.get_command() function. The function builds a cmd.exe command by embedding a file path directly into an f‑string and passes it to subprocess.Popen with shell=True. Because the path is not escaped, any shell metacharacters present in the file path can be injected, allowing an attacker to run arbitrary cmd.exe commands. This vulnerability is classified as CWE‑78, representing an input validation weakness.

Affected Systems

The flaw affects all Windows installations that run Pillow versions older than 12.3.0. Any Python process that invokes WindowsViewer.get_command can trigger the issue, which means that many applications that load images are potentially vulnerable regardless of the host application.

Risk and Exploitability

The CVSS score of 4.5 reflects moderate severity, and the EPSS score is below 1%, indicating a low probability of exploitation in the wild. The vulnerability is not listed in CISA’s KEV catalog. Based on the description, the likely attack vector is local or remote when an application can receive an image file whose path is controlled by an attacker. An attacker would supply a file name or path containing shell metacharacters to the WindowsViewer.get_command function. The success of the exploit depends on the privileges of the Python process; elevated privileges could lead to system‑wide compromise, while lower privileges would limit the attacker to the application context. Because the flaw is not network exposed by itself, exploitation typically requires local code execution or an indirect path such as an uncontrolled image source within an application.

Generated by OpenCVE AI on July 26, 2026 at 20:22 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade Pillow to 12.3.0 or later to ensure proper escaping of file paths.
  • If upgrading is not possible, modify WindowsViewer.get_command to sanitize or quote the file path before passing it to cmd.exe, or replace subprocess.Popen with an invocation that does not use shell=True.
  • Run any image‑processing applications with the least privilege necessary to limit damage from a successful injection.

Generated by OpenCVE AI on July 26, 2026 at 20:22 UTC.

Tracking

Sign in to view the affected projects.

Advisories
Source ID Title
Github GHSA Github GHSA GHSA-4x4j-2g7c-83w6 Pillow: WindowsViewer.get_command() OS command injection via unescaped shell path
History

Wed, 08 Jul 2026 00:15:00 +0000

Type Values Removed Values Added
References
Metrics threat_severity

None

threat_severity

Moderate


Tue, 07 Jul 2026 16:30:00 +0000

Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'poc', 'Technical Impact': 'partial'}, 'version': '2.0.3'}


Mon, 06 Jul 2026 21:00:00 +0000

Type Values Removed Values Added
First Time appeared Python-pillow
Python-pillow pillow
Vendors & Products Python-pillow
Python-pillow pillow

Mon, 06 Jul 2026 19:15:00 +0000

Type Values Removed Values Added
Description 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.
Title Pillow: WindowsViewer.get_command() OS command injection via unescaped shell path
Weaknesses CWE-78
References
Metrics cvssV3_1

{'score': 4.5, 'vector': 'CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:L'}


Subscriptions

Python-pillow Pillow
cve-icon MITRE

Status: PUBLISHED

Assigner: GitHub_M

Published:

Updated: 2026-07-07T15:19:40.072Z

Reserved: 2026-06-17T14:40:28.381Z

Link: CVE-2026-55798

cve-icon Vulnrichment

Updated: 2026-07-07T15:19:15.419Z

cve-icon NVD

No data.

cve-icon Redhat

Severity : Moderate

Publid Date: 2026-07-06T18:44:38Z

Links: CVE-2026-55798 - Bugzilla

cve-icon OpenCVE Enrichment

Updated: 2026-07-26T20:30:03Z

Weaknesses
  • CWE-78

    Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')