Junglewise Threat Intelligence

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

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

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

Executive brief

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.

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

Timeline

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

References

Related threats