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.04% (12th 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-16066747
  • published15 Apr 2026
  • disclosed14 Apr 2026
  • creditkodareef5

Introduced: 14 Apr 2026

NewCVE-2026-40261  (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 Perforce::syncCodeBase and Perforce::generateP4Command methods, which append user-controlled input from package metadata directly to shell commands without proper escaping. An attacker can execute arbitrary system commands by supplying crafted source references or URLs containing shell metacharacters in a malicious Composer repository. This is only exploitable if dependencies are installed or updated from source (such as with the --prefer-source flag or when installing dev-prefixed versions).

Workaround

This vulnerability can be mitigated by avoiding installation of dependencies from source by using the --prefer-dist flag or setting preferred-install: dist in configuration, and by only using trusted Composer repositories.

CVSS Base Scores

version 4.0
version 3.1