Composer is vulnerable to Command Injection via Malicious Perforce Repository
Key facts
- Attack vector
- Local
- Privileges required
- None
- User interaction
- Required
- Attack complexity
- Low
- Impact type
- Code execution
- Confidentiality · integrity · availability
- High · High · High
- Fix status
- Fixed
Attack profile from CVSS 3.1 · CNA. Fix status from CNA, GitHub and Red Hat. Impact type from CWE-78.
Summary
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::generateP4Command() method, which constructs shell commands by interpolating user-supplied Perforce connection parameters (port, user, client) without proper escaping. An attacker can inject arbitrary commands through these values in a malicious composer.json declaring a Perforce VCS repository, leading to command execution in the context of the user running Composer, even if Perforce is not installed. VCS repositories are only loaded from the root composer.json or the composer config directory, so this cannot be exploited through composer.json files of packages installed as dependencies. Users are at risk if they run Composer commands on untrusted projects with attacker-supplied composer.json files. This issue has been fixed in Composer 2.2.27 (2.2 LTS) and 2.9.6 (mainline).
Why it matters now
SSVC decision points
CISA ADP · SSVC 2.0.3
- Exploitation
- None
- Automatable
- No
- Technical impact
- Total
The decision (Track, Attend, Act) also depends on your mission and well-being impact; see CISA's SSVC guide.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| composer | composer | 2.3 to before 2.9.6; 1.0 to before 2.2.27 | 2.9.6, 2.2.27 | Patch available | CNA |
| — | composer/composer (Packagist) | 2.3.0 to before 2.9.6 | 2.9.6 | Patch available | GHSA-wg36-wvj6-r67p |
| — | composer/composer (Packagist) | 1.0.0 to before 2.2.27 | 2.2.27 | Patch available | GHSA-wg36-wvj6-r67p |
- composer Vendorcomposer Affected 2.3 to before 2.9.6; 1.0 to before 2.2.27 Fixed in 2.9.6, 2.2.27 Patch available CNA
- composer/composer (Packagist) Vendor— Affected 2.3.0 to before 2.9.6 Fixed in 2.9.6 Patch available GHSA-wg36-wvj6-r67p
- composer/composer (Packagist) Vendor— Affected 1.0.0 to before 2.2.27 Fixed in 2.2.27 Patch available GHSA-wg36-wvj6-r67p
Remediation
- Fix · CNA composer (composer) Fixed in 2.9.6, 2.2.27
- Fix · GHSA-wg36-wvj6-r67p composer/composer (Packagist) Fixed in 2.9.6 Advisory →
- Fix · GHSA-wg36-wvj6-r67p composer/composer (Packagist) Fixed in 2.2.27 Advisory →
Red Hat 1 advisory
- RHSA-2026:8165 Released 2026-04-14 · Red Hat rating ImportantRed Hat Hardened Images RPMs bug fix and enhancement update
- Red Hat Hardened Images composer-2.9.7-1.hum1@noarch@public-hummingbird-aarch64-rpms, composer-2.9.7-1.hum1@noarch@public-hummingbird-x86_64-rpms, composer-2.9.7-1.hum1@src
Vendor assessments
Red Hat
Red Hat rating: Important. Red Hat's page for this CVE →
| Product | Status | Plan or fix |
|---|---|---|
| Red Hat Hardened Images | Fixed | RHSA-2026:8165 |
Timeline
- 2026-10-02 Threatist record created from CVE-2026-40176
- 2026-10-03 Alias added: GHSA-wg36-wvj6-r67p
- 2026-11-02 6 new references · CNA
- 2026-11-02 1 new reference · GHSA-wg36-wvj6-r67p
References
Advisory 2
Other 8
- https://access.redhat.com/errata/RHSA-2026:8165
- https://access.redhat.com/security/cve/CVE-2026-40176
- https://bugzilla.redhat.com/show_bug.cgi?id=2458828
- https://github.com/FriendsOfPHP/security-advisories/blob/master/composer/composer/CVE-2026-40176.yaml
- https://github.com/composer/composer/releases/tag/2.2.27
- https://github.com/composer/composer/releases/tag/2.9.6
- https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-40176.json
- https://github.com/composer/composer
More Composer vulnerabilities
- TI-2015-06892 Composer before 2016-02-10 allows cache poisoning from other projects built on the same… CVSS 3.1HIGH 8.8
- TI-2021-17955 Command injection in composer on Windows CVSS 3.1CRITICAL 9.8
- TI-2021-10185 Code injection in composer CVSS 3.1HIGH 8.8
- TI-2022-08641 Missing input validation can lead to command execution in composer CVSS 3.1HIGH 8.8
- TI-2026-29055 Composer has Command Injection via Malicious Perforce Reference CVSS 3.1HIGH 8.8
- TI-2023-23380 Remote Code Execution via web-accessible composer.phar CVSS 3.1HIGH 8.8
Sources
- CVE-2026-40176 · CVE Program
- CVE-2026-40176 · NVD
- FIRST EPSS
- GHSA-wg36-wvj6-r67p · GitHub Advisory Database · CC BY 4.0
- CVE-2026-40176 · Red Hat security data · CC BY 4.0
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences