Skip to main content
Public proof of conceptFix available

CVE-2026-40261

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

Timeline

dates in UTC
  1. 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.0, < 2.9.6no fix stated
    • = >= 1.0.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

18 more package ranges on OSV.dev

Vendor advisories

  • CVE-2026-40261 Red Hat Product Security2 products fixed

    composer: command injection via malicious Perforce source reference/url

  • 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-40261 · 2 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-40261 · 2 productsTo mitigate this issue, only run Composer commands on projects and dependencies from trusted sources. Also, use the '--prefer-dist' or the 'preferred-install: dist' configuration setting to prevent Composer from installing dependencies from source.

Advisories and patches

Detection

read 2026-11-01 01:02 UTC
Nuclei template
none so far
ProjectDiscovery
Exploit-DB
no entry
Exploit-DB
Proof of concept
Metasploit modules
none listed
Metasploit Framework

Sources

  • CISA-ADPSSVC decisionnone2026-04-16
  • CNACVSS 3.18.8known since 2026-10-23
  • CNAweakness (CWE)CWE-20, CWE-78known since 2026-10-23
  • NVDweakness (CWE)CWE-78read 2026-10-23
  • FIRST EPSSEPSS score1.7 %2026-11-08
  • PoC-in-GitHubproof of concept1known since 2026-11-01
  • OSVaffected packages—
  • GitHub AdvisoriesadvisoryHIGH2026-04-14

Identifiers

Technical details

CVSS v3 Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
Published
2026-04-15
Last Modified
2026-07-15
NVD status
Modified
GitHub Advisory
GHSA-gqw4-4w2p-838q

Frequently asked questions

What is CVE-2026-40261?

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.

Is CVE-2026-40261 actively exploited?

Active exploitation of CVE-2026-40261 has not been confirmed. Its EPSS score was 1.7% on 2026-11-08, the estimated probability of exploitation in the next 30 days.

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

CVE-2026-40261 has a CVSS v3 base score of 8.8 (HIGH severity), with vector string CVSS:3.1/AV:N/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 lookups · 250 API requests/month

Sources for this record