PHP Composer Perforce Flaws Allow Arbitrary Command Execution
Vulnerability Disclosure · 8 sources · Updated 5mo ago · First seen Apr 14, 2026

Two high-severity vulnerabilities in PHP Composer could let attackers execute arbitrary commands through the package manager’s Perforce VCS driver. The flaws, tracked as CVE-2026-40176 and CVE-2026-40261, were caused by improper input validation and insufficient escaping when Composer built shell commands from repository configuration and source metadata. One issue can be triggered by a malicious composer.json in an untrusted root project, while the other can be exploited through a crafted source reference from a malicious or compromised repository.
The bugs affect Composer versions >= 2.3 and < 2.9.6, as well as >= 2.0 and < 2.2.27, and were patched in 2.9.6 and 2.2.27 LTS. Maintainers said injected commands could run even if Perforce is not installed on the target system. Composer, Packagist.org, and Private Packagist reported no evidence of active exploitation, but Packagist disabled publication of Perforce source metadata and the Perforce VCS driver as a precaution. Users were urged to update immediately, scrutinize composer.json files, rely only on trusted repositories, and avoid dependency installation via --prefer-dist or the preferred-install: dist setting.


