Command Injection Affecting composer/composer package, versions >=2.0.0, <2.2.27>=2.3.0, <2.9.6


Severity

Recommended
0.0
high
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

EPSS
0.01% (2nd percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Command Injection vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PHP-COMPOSERCOMPOSER-16066745
  • published15 Apr 2026
  • disclosed14 Apr 2026
  • creditSaku0512

Introduced: 14 Apr 2026

NewCVE-2026-40176  (opens in a new tab)
CWE-78  (opens in a new tab)

How to fix?

Upgrade composer/composer to version 2.2.27, 2.9.6 or higher.

Overview

composer/composer is a Dependency Manager for PHP. Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

Affected versions of this package are vulnerable to Command Injection via the generateP4Command function. An attacker can execute arbitrary commands in the context of the user running the process by supplying malicious Perforce connection parameters in a crafted configuration file. This is only exploitable if Composer commands are run on untrusted projects with attacker-supplied configuration files.

Workaround

This vulnerability can be mitigated by carefully inspecting configuration files before running Composer and ensuring Perforce-related fields contain valid values, and by only running Composer commands on projects from trusted sources.

CVSS Base Scores

version 4.0
version 3.1