CVE-2026-40261 — Vulnerability in composer/composer — CVE Details
Composer has a command injection via malicious perforce reference
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (1.98%). Schedule for your next planned update.
Does your project use an affected composer/composer version?
Paste your composer.lock to check it for CVE-2026-40261 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
Impact
The Perforce::syncCodeBase() method appended the $sourceReference parameter to a shell command without proper escaping, allowing an attacker to inject arbitrary commands through a crafted source reference containing shell metacharacters. Further as in GHSA-wg36-wvj6-r67p / CVE-2026-40176 the Perforce::generateP4Command() method constructed shell commands by interpolating user-supplied Perforce connection parameters (port, user, client) without proper escaping from the source url field. Composer would execute these injected commands even if Perforce is not installed.
The source reference and url are provided as part of package metadata. Any Composer package repository can serve package metadata declaring perforce as a source type with a malicious source reference or source url. This means the vulnerability can be exploited through any package served by a compromised or malicious Composer repository. An attack does not require Perforce to be installed on the client, as Composer will attempt to execute the constructed command regardless.
This vulnerability is exploitable when installing or updating dependencies from source (--prefer-source, default when installing dev prefixed versions), even if you do not use Perforce.
Patches
Fixed in Composer 2.2.27 (2.2 LTS) and 2.9.6 (mainline)
Note, the fix for the source url in the Perforce::generateP4Command() was addressed as part of the patches for GHSA-wg36-wvj6-r67p / CVE-2026-40176 in the same versions.
Workarounds
- Avoid installing dependencies from source by using
--prefer-distor thepreferred-install: distconfig setting. - Only use trusted Composer repositories.
Advisory Timeline
- First published April 14, 2026 (226 days ago).
- Last revised September 10, 2026 — 148 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
composer require "composer/composer:^2.9.6"
composer require "composer/composer:^2.2.27"
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (2)
Affects 1 ecosystem: Packagist (1).
| Package | Fixed In |
|---|---|
| composer/composer Packagist · Affected: 2.3.0, 2.3.1, 2.3.10, 2.3.2 (+59 more) | 2.9.6 |
| composer/composer Packagist · Affected: 1.0.0, 1.0.1, 1.0.2, 1.0.3 (+143 more) | 2.2.27 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 8.8 score means for each attack dimension.
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
References
- https://github.com/composer/composer/security/advisories/GHSA-gqw4-4w2p-838qWEB
- https://nvd.nist.gov/vuln/detail/CVE-2026-40261ADVISORY
- https://access.redhat.com/errata/RHSA-2026:8165WEB
- https://access.redhat.com/security/cve/CVE-2026-40261WEB
- https://bugzilla.redhat.com/show_bug.cgi?id=2458841WEB
- https://github.com/FriendsOfPHP/security-advisories/blob/master/composer/composer/CVE-2026-40261.yamlWEB
- https://github.com/composer/composerPACKAGE
- https://github.com/composer/composer/releases/tag/2.9.6WEB
- https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-40261.jsonWEB
Frequently Asked Questions
- What is CVE-2026-40261?
- Composer has a command injection via malicious perforce reference. This vulnerability has been assigned a severity rating of HIGH (CVSS score: 8.8/10).
- How do I check if my project is affected by CVE-2026-40261?
- CVE-2026-40261 affects composer/composer. It has a 2.0% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-40261 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Significant impact if exploited, or exploitable with modest effort.
This places it in the top quartile of EPSS-scored vulnerabilities — 81.2% of tracked vulnerabilities score at or below it, so it is more likely to be exploited than most of the tracked corpus.
Also Known As
Related CVEs
- CVE-2024-35241HIGH
Composer has a command injection via malicious git branch name
- CVE-2026-103035HIGH
TeamPass folder re-parenting authorization bypass
- CVE-2026-110782HIGH
SAML2: Incomplete fix of CVE-2026-49283: unsigned embedded Response bypasses HTTP-Artifact signature verification (no embedded-Issuer binding)
- CVE-2026-84361HIGH
Composer arbitrary command execution via a malicious package's Perforce source URL
- CVE-2024-35242HIGH
Composer has multiple command injections via malicious git/hg branch names