Executive brief
Composer, a popular dependency manager for PHP, is vulnerable to a flaw that allows malicious package repositories to execute unauthorized commands on a user's computer. By providing specially crafted package metadata, an attacker can gain control over systems that are installing or updating software dependencies. This risk exists even if the user does not have the Perforce version control system installed.
Technical details
Composer's Perforce implementation contains two command injection vectors. The `Perforce::syncCodeBase()` method fails to properly escape the `$sourceReference` parameter before appending it to a shell command. Additionally, the `Perforce::generateP4Command()` method interpolates user-supplied connection parameters (port, user, client) from the source URL field without neutralization. An attacker controlling a Composer repository can serve malicious metadata that triggers these injections during a `composer install` or `update` when `--prefer-source` is used. The vulnerability is exploitable regardless of whether the Perforce binary is actually present on the host system. Fixes are available 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: advisory: GitHub Advisory GHSA-gqw4-4w2p-838q published
- 2026-04-14: patched: Fixed in versions 2.2.27 and 2.9.6