Read the docs
TI-2026-29055 Aliases CVE-2026-40261GHSA-gqw4-4w2p-838q

Composer has Command Injection via Malicious Perforce Reference

Priority MEDIUM 43CWE-20Published · Updated

Key facts

Attack vector
Network
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::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.

Why it matters now

Exploitation None reported CISA SSVC · not in CISA KEV
EPSS 0.01688 77th percentileScored 2026-11-07
Fix Fixed composer (composer): 2.9.6, 2.2.27composer/composer (Packagist): 2.9.6, 2.2.27Red Hat: 1 advisory

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

VendorProductAffected versionsFixed inStatusSource
composercomposer2.3.0 to before 2.9.6; 1.0.0 to before 2.2.272.9.6, 2.2.27Patch availableCNA
—composer/composer (Packagist)2.3.0 to before 2.9.62.9.6Patch availableGHSA-gqw4-4w2p-838q
—composer/composer (Packagist)1.0.0 to before 2.2.272.2.27Patch availableGHSA-gqw4-4w2p-838q
  • composer Vendorcomposer Affected 2.3.0 to before 2.9.6; 1.0.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-gqw4-4w2p-838q
  • composer/composer (Packagist) Vendor— Affected 1.0.0 to before 2.2.27 Fixed in 2.2.27 Patch available GHSA-gqw4-4w2p-838q

CPE configurations NVD · 1

CPEVersionsRoleVendor
cpe:2.3:a:getcomposer:composer:*:*:*:*:*:*:*:*1.0.0 – 2.2.26; 2.3.0 – 2.9.5Vulnerablecomposer
  • cpe:2.3:a:getcomposer:composer:*:*:*:*:*:*:*:* Versions 1.0.0 – 2.2.26; 2.3.0 – 2.9.5 Vulnerable ·composer

Remediation

  • Fix · CNA composer (composer) Fixed in 2.9.6, 2.2.27
  • Fix · GHSA-gqw4-4w2p-838q composer/composer (Packagist) Fixed in 2.9.6 Advisory →
  • Fix · GHSA-gqw4-4w2p-838q composer/composer (Packagist) Fixed in 2.2.27 Advisory →

Red Hat 1 advisory

  • RHSA-2026:8165 Released 2026-04-14 · Red Hat rating Important
    Red 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 →

ProductStatusPlan or fix
Red Hat Hardened ImagesFixed RHSA-2026:8165

Timeline

  1. 2026-10-02 Threatist record created from CVE-2026-40261
  2. 2026-10-03 Alias added: GHSA-gqw4-4w2p-838q

References

  • 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-2023-23380 Remote Code Execution via web-accessible composer.phar CVSS 3.1HIGH 8.8
  • TI-2024-16338 Code execution and possible privilege escalation via compromised InstalledVersions.php or installed.php in Composer CVSS 3.1HIGH 8.8
See all 8 →

Sources