Skip to content
OpenAdvisories
High · 8.8 Public exploit CVE-2026-40261 BIT-composer-2026-40261EUVD-2026-23119GHSA-gqw4-4w2p-838q

Composer has Command Injection via Malicious Perforce Reference

Published Apr 15, 2026 · Updated Jul 15, 2026 · Assigned by GitHub_M

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.

Affected products

VendorProductAffectedFixed
composer composer >= 2.3.0, < 2.9.6, >= 1.0.0, < 2.2.27 —

Fixed in Linux distributions

Distributions backport fixes, so the version that fixes this vulnerability differs per release — upgrade to at least the version shown. From the distributions' security trackers and advisories.

ReleasePackageFixed inAdvisory
Debian 14 composer 2.9.7-1 —
Debian 13 composer 2.8.8-1+deb13u2 —
Debian 12 composer 2.5.5-1+deb12u4 —
ReleasePackageFixed inAdvisory
Ubuntu 26.10 composer No fix yet —
Ubuntu 26.04 LTS composer No fix yet —
Ubuntu 25.10 composer No fix yet —
Show 5 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
Ubuntu Pro 24.04 LTS composer No fix yet —
Ubuntu Pro 22.04 LTS composer No fix yet —
Ubuntu Pro 20.04 LTS composer No fix yet —
Ubuntu Pro 18.04 LTS composer No fix yet —
Ubuntu Pro 16.04 LTS composer No fix yet —
ReleasePackageFixed inAdvisory
Red Hat Hardened Images 1 composer 2.9.7-1.hum1 RHSA-2026:8165
ReleasePackageFixed inAdvisory
SLES 15 SP7 php-composer2 2.6.4-150600.3.12.1 SUSE-SU-2026:3105-1
SLES 15 SP6 php-composer2 2.6.4-150600.3.12.1 SUSE-SU-2026:3105-1
Show 3 more (older releases, extended support, other products)
ReleasePackageFixed inAdvisory
SLES for SAP 16.0 php-composer2 2.8.9-160000.4.1 SUSE-SU-2026:23138-1, SUSE-SU-2026:23116-1
SLES for SAP 15 SP6 php-composer2 2.6.4-150600.3.12.1 SUSE-SU-2026:3105-1
SLES 16.0 php-composer2 2.8.9-160000.4.1 SUSE-SU-2026:23138-1, SUSE-SU-2026:23116-1
ReleasePackageFixed inAdvisory
openSUSE Tumbleweed php-composer2 2.9.7-1.1 openSUSE-SU-2026:10643-1
openSUSE Leap 16.0 php-composer2 2.8.9-160000.4.1 openSUSE-SU-2026:21520-1
ReleasePackageFixed inAdvisory
Alpine v3.24 composer 2.9.6-r0 —
Alpine v3.23 composer 2.9.6-r0 —

Amazon Linux

ReleasePackageFixed inAdvisory
Amazon Linux 2023 composer 2.9.7-1.amzn2023.0.1 ALAS2023-2026-1625

Wolfi

ReleasePackageFixed inAdvisory
Wolfi rolling composer 2.9.7-r0 —

Public exploits

Exploit or proof-of-concept code for this vulnerability is publicly available, which lowers the bar for attackers. Treat it as a reason to patch sooner.

Third-party code, not reviewed by us. Public PoCs are sometimes fake or contain malware. Read the code first and run it only in an isolated lab, against systems you are authorised to test.

GitHub 1 repository

Sources: PoC-in-GitHub, Metasploit Framework, Exploit-DB — updated daily. Only links are listed; no exploit code is hosted here.

Affected packages

EcosystemPackageAffectedFixedRecord
Packagist composer/composer >= 2.3.0, < 2.9.6 2.9.6 GHSA-gqw4-4w2p-838q
Packagist composer/composer >= 1.0.0, < 2.2.27 2.2.27 GHSA-gqw4-4w2p-838q

Advisories 8

References