CVE-2026-40176: Composer command injection in Perforce repository handling

CVE-2026-40176 · Severity: high · CVSS 7.8 · Published 2026-04-15

Composer, a popular dependency manager for PHP, is vulnerable to a security flaw that allows a malicious project file to execute unauthorized commands on a user's computer. If a developer runs Composer on a project containing a specially crafted configuration file, an attacker could gain control over the system. This risk exists even if the user does not have the Perforce version control software installed.

Technologies: Composer (Packagist), composer/composer (Packagist). Vendors: Packagist.

Quick answers

Is CVE-2026-40176 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-40176 being exploited in the wild.
How severe is CVE-2026-40176?
High severity, with a CVSS score of 7.8, published 15 April 2026.
Which products and versions are affected?
Composer (Packagist) >= 1.0, < 2.2.27; >= 2.3, < 2.9.6, >= 1.0.0, < 2.2.27; >= 2.3.0, < 2.9.6; composer/composer (Packagist) ECOSYSTEM:introduced=2.3.0,fixed=2.9.6.
Is there a fix for CVE-2026-40176?
Yes. composer/composer (Packagist): upgrade to 2.9.6 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-40176 attacked?
It is attacked with local access, in a software library.
Am I affected by CVE-2026-40176?
Check whether you run Composer (Packagist) or composer/composer (Packagist) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • composer/composer (Packagist): upgrade to 2.9.6 or later
    composer require composer/composer:^2.9.6

Technical details

A command injection vulnerability exists in the `Perforce::generateP4Command()` method of Composer. The root cause is the improper neutralization of user-supplied Perforce connection parameters (port, user, and client) before they are interpolated into shell commands. An attacker can exploit this by providing a malicious `composer.json` file that defines a Perforce VCS repository with injected shell characters. The exploit occurs when a user executes Composer commands in the directory containing the malicious file, leading to arbitrary command execution in the context of the local user. This vulnerability is fixed in versions 2.2.27 and 2.9.6.

Affected products

  • Composer composer/composer >= 1.0.0, < 2.2.27; >= 2.3.0, < 2.9.6

Identifiers

  • CVE-2026-40176
  • GHSA-wg36-wvj6-r67p

Timeline

  • 2026-04-14: disclosed
  • 2026-04-14: advisory
  • 2026-04-14: patched

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.