CVE-2026-40261Composer has Command Injection via Malicious Perforce Reference
Composer is a dependency manager for PHP. Versions 1.0 through 2.2.26 and 2.3 through 2.9.5 contain a command injection vulnerability in the Perforce::syncCodeBase() method, which appends the $sourceReference parameter to a shell command without proper escaping, and additionally in the Perforce::generateP4Command() method as in GHSA-wg36-wvj6-r67p / CVE-2026-40176, which interpolates user-supplied Perforce connection parameters (port, user, client) from the source url field without proper escaping. An attacker can inject arbitrary commands through crafted source reference or source url values containing shell metacharacters, even if Perforce is not installed. Unlike CVE-2026-40176, the source reference and url are provided as part of package metadata, meaning any compromised or malicious Composer repository can serve package metadata declaring perforce as a source type with malicious values. This vulnerability is exploitable when installing or updating dependencies from source, including the default behavior when installing dev-prefixed versions. This issue has been fixed in Composer 2.2.27 (2.2 LTS) and 2.9.6 (mainline). If developers are unable to immediately update, they can avoid installing dependencies from source by using --prefer-dist or the preferred-install: dist config setting, and only use trusted Composer repositories as a workaround.
What to do
Fixed builds are available from Alpine, Debian, Packagist: see the table below for the fixed version per release.
Ubuntu has not shipped a fix for every release yet.
Is your server affected? One read-only command checks every installed package against this CVE and all others, using each vendor's fixed versions. Get started or get a free API key.
curl -sS "https://api.cvefocus.com/v1/check?format=text" -H "Authorization: Bearer $CVEFOCUS_KEY" \ -H "Content-Type: text/plain" --data-binary @inventory.txt
Vendor status at a glance
Status by vendor and release
From each vendor's own security data and VEX statements. "Fixed" means a fixed build is published for that release.
| Release | Package | Status | Fixed version | Advisory |
|---|---|---|---|---|
| Ubuntu 26.10 | composer | Fix pending | UBUNTU-CVE-2026-40261 | |
| Ubuntu 26.04 | composer | Under investigation | UBUNTU-CVE-2026-40261 | |
| Ubuntu 25.10 | composer | Will not fix Ubuntu decided not to fix this in this release | UBUNTU-CVE-2026-40261 | |
| Ubuntu 24.04 | composer | Fix pending | UBUNTU-CVE-2026-40261 | |
| Ubuntu 22.04 | composer | Fix pending | UBUNTU-CVE-2026-40261 | |
| Ubuntu 20.04 | composer | Fix pending | UBUNTU-CVE-2026-40261 | |
| Ubuntu 18.04 | composer | Fix pending | UBUNTU-CVE-2026-40261 | |
| Ubuntu 16.04 | composer | Fix pending | UBUNTU-CVE-2026-40261 | |
| Debian 14 | composer | Fixed | 2.9.7-1 | DEBIAN-CVE-2026-40261 |
| Debian 13 | composer | Fixed | 2.8.8-1+deb13u2 | DEBIAN-CVE-2026-40261 |
| Debian 12 | composer | Fixed | 2.5.5-1+deb12u4 | DEBIAN-CVE-2026-40261 |
| Alpine Linux 3.24 | composer | Fixed | 2.9.6-r0 | ALPINE-CVE-2026-40261 |
| Alpine Linux 3.23 | composer | Fixed | 2.9.6-r0 | ALPINE-CVE-2026-40261 |
| Packagist library | composer/composer | Fixed | 2.2.27 | GHSA-gqw4-4w2p-838q |
What the vendor says
As published in the CVE record by GitHub_M, the CVE's assigner (usually the vendor). Check the vendor's advisory before acting.
- composer: affected: >= 2.3.0, < 2.9.6, >= 1.0.0, < 2.2.27
References
- https://github.com/composer/composer/security/advisories/GHSA-gqw4-4w2p-838q
- https://github.com/composer/composer/releases/tag/2.9.6
About this page
Compiled by CVEfocus from the CVE List, the security data and VEX statements of Ubuntu, Debian, Red Hat, AlmaLinux, Rocky Linux and Microsoft, CISA's Known Exploited Vulnerabilities catalog and FIRST EPSS, refreshed several times a day (data status). Information only; see the disclaimer. Official record: cve.org · NVD.