# CVE-2026-40176: Composer is vulnerable to Command Injection via Malicious Perforce Repository

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** HIGH 7.8
- **CVSS:** 7.8 (v3.1, CNA) `CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: None; User interaction: Required; Scope: Unchanged; Confidentiality impact: High; Integrity impact: High; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 1.04% (percentile 63, 2026-11-26)
- **CWE:** CWE-20, CWE-78
- **Aliases:** BIT-composer-2026-40176, GHSA-wg36-wvj6-r67p
- **Published:** 2026-04-14T20:03:08.000Z
- **Modified:** 2026-11-02T23:17:20.667Z

## Who should check

- Projects that depend on Packagist package composer/composer (\>= 2.3.0, \< 2.9.6)
- Anyone running composer \>= 2.3, \< 2.9.6; \>= 1.0, \< 2.2.27

## Description

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).

## Affected and fixed versions

- Packagist `composer/composer`: affected \>= 2.3.0, \< 2.9.6; fixed 2.9.6, 2.2.27 (osv)
- composer: \>= 2.3, \< 2.9.6; \>= 1.0, \< 2.2.27 (cvelist)

## Mitigation

- Upgrade composer/composer to one of 2.9.6, 2.2.27 (or later in the same release line).

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2026-40176. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2026-40176.md
Affected: composer/composer >= 2.3.0, < 2.9.6
Fixed in: 2.9.6, 2.2.27

Steps:
1. Search this machine and project for composer/composer (Packagist), composer: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2026-40176 being exploited?

There is no confirmed exploitation: CVE-2026-40176 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 1.04% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2026-40176?

High: CVSS 7.8 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed). A user has to take an action, such as opening a link, for the attack to work.

### Which versions are affected by CVE-2026-40176?

composer/composer \>= 2.3.0, \< 2.9.6.

### Is there a fix for CVE-2026-40176?

Yes. Fixed in 2.9.6, 2.2.27. Upgrade composer/composer to one of 2.9.6, 2.2.27 (or later in the same release line).

### How do I check if I'm affected by CVE-2026-40176?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- vendor: <https://github.com/composer/composer/security/advisories/GHSA-wg36-wvj6-r67p>
- vendor: <https://access.redhat.com/errata/RHSA-2026:8165>
- vendor: <https://nvd.nist.gov/vuln/detail/CVE-2026-40176>
- other: <https://access.redhat.com/security/cve/CVE-2026-40176>
- other: <https://bugzilla.redhat.com/show_bug.cgi?id=2458828>
- other: <https://github.com/FriendsOfPHP/security-advisories/blob/master/composer/composer/CVE-2026-40176.yaml>
- other: <https://github.com/composer/composer/releases/tag/2.2.27>
- other: <https://github.com/composer/composer/releases/tag/2.9.6>
- other: <https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-40176.json>
- other: <https://github.com/composer/composer>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2026-40176>
- OSV: CC-BY 4.0 <https://osv.dev/vulnerability/GHSA-wg36-wvj6-r67p> (license: <https://creativecommons.org/licenses/by/4.0/>)

HTML: <https://flawdb.com/CVE-2026-40176> · JSON: <https://flawdb.com/api/v1/entries/CVE-2026-40176>
