Skip to main content
Public proof of conceptFix available

CVE-2026-40176

Composer is vulnerable to Command Injection via Malicious Perforce Repository

A public proof of concept exists; no exploitation attested.

  • Published2026-04-15
  • Fixed in2.9.6 · 2.2.27
  • WeaknessCWE-20 · CWE-78

Am I affected?

With a domain, we read the version its public headers and pages expose. A distribution build can carry the fix under an older number.

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

Timeline

dates in UTC
  1. 2026-04-1520:47CVE publishedCNA
  2. 2026-04-1521:17CVE publishedNVD

Versions per branch

OSV · NVD
composer
BranchAffectedFixed in
2.x≥ 2.3.0, < 2.9.62.9.6
2.2≥ 1.0.0, < 2.2.272.2.27
Getcomposer composer
BranchAffectedFixed in
2.2≥ 1.0.0, ≤ 2.2.26no fix published
2.x≥ 2.3.0, ≤ 2.9.5no fix published
composer/composer
BranchAffectedFixed in
2.x≥ 2.3.0, < 2.9.62.9.6
2.2≥ 1.0.0, < 2.2.272.2.27

as publishedRanges as NVD and OSV publish them; a distribution’s build can be fixed under an older number.

Products declared by the CNA1 product

As GitHub_M, the CNA that assigned this CVE, declared them in the CVE record; versions as written.

  • composer
    Affected
    • = >= 2.3, < 2.9.6no fix stated
    • = >= 1.0, < 2.2.27no fix stated

Source: the CNA record (CVE Program), © The MITRE Corporation,CVE terms of useCVE recordupdated 2026-04-15

Distribution builds and vendor advisories

Packages from OSV.dev and products from the vendors' CSAF advisories.

version not verifiedVersions not verified: read as OSV.dev and the vendors publish them, not checked against each vendor's release list.

Packages

  • composerWolfiall versions · fixed in 2.9.7-r0
  • composerUbuntu:Pro:24.04:LTSall versions · no fixed version listed
  • composerUbuntu:Pro:22.04:LTSall versions · no fixed version listed
  • composerUbuntu:Pro:20.04:LTSall versions · no fixed version listed
  • composerUbuntu:Pro:18.04:LTSall versions · no fixed version listed
  • composerUbuntu:Pro:16.04:LTSall versions · no fixed version listed
  • composerUbuntu:26.10all versions · no fixed version listed
  • composerUbuntu:26.04:LTSall versions · no fixed version listed

20 more package ranges on OSV.dev

Vendor advisories

  • CVE-2026-40176 Red Hat Product Security3 products fixed

    composer: command injection via malicious Perforce repository definition

  • RHSA-2026:8165 Red Hat Product Security3 products fixed

    Red Hat Security Advisory: Red Hat Hardened Images RPMs bug fix and enhancement update

Full record on NVD

Fix

  1. Update composer to 2.9.6 · 2.2.27
  2. Vendor fix Red Hat Product Security CVE-2026-40176 · 3 productsFor details on how to apply this update, which includes the changes described in this advisory, refer to: https://images.redhat.com/
  3. Workaround from the vendor Red Hat Product Security CVE-2026-40176 · 3 productsTo mitigate this vulnerability, only run Composer commands on projects from trusted sources. Also, inspect composer.json files before running Composer commands on them, specifically checking that Perforce-related fields contain valid values.

Advisories and patches

Detection

read 2026-12-04 21:57 UTC
Nuclei template
none so far
ProjectDiscovery
Exploit-DB
no entry
Exploit-DB
Proof of concept
Metasploit modules
none listed
Metasploit Framework

Sources

Identifiers

Technical details

CVSS v3 vector
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
Published
2026-04-15
Last modified
2026-11-02
NVD status
Modified
GitHub advisory
GHSA-wg36-wvj6-r67p

Frequently asked questions

What is CVE-2026-40176?

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

Is CVE-2026-40176 actively exploited?

Active exploitation of CVE-2026-40176 has not been confirmed. Its EPSS score was 1.1% on 2026-12-04, the estimated probability of exploitation in the next 30 days.

What is the CVSS score for CVE-2026-40176?

CVE-2026-40176 has a CVSS v3 base score of 7.8 (High severity), with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H.

Running composer? Hear about its next vulnerability

Surveillance reads the versions in your stack — a domain, a lockfile or a list — checks each CVE against the ranges its sources publish, and alerts you when one you run is exploited or enters CISA KEV. A version it cannot read stays « version not verified ».

No credit card required · No monthly cap on website checks · 250 API requests/month

Sources for this record