cve.bz

CVE-2026-40261 getcomposer composer: OS Command Injection

8.8 highEPSS 1.7%Fix available

High (8.8) in getcomposer composer. EPSS 1.7% estimated probability of exploitation activity in the next 30 days. Fixed in composer/composer 2.2.27, 2.9.6.

On this page
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.

Severity

CVSS 3.1

8.8 high
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
EPSS
1.7% (unchanged from 1.7% a week ago; 1.9% 30 days ago) estimated probability of exploitation activity in the next 30 days; 78th percentile. Scored 2026-11-22. A forecast for this CVE across the internet, not for your own systems.
CISA's assessment (SSVC)
Exploitation: none · Automatable: no · Technical impact: total, assessed 2026-04-16. From CISA's Vulnrichment in the CVE List: whether it is exploited, whether exploiting it can be automated, and how much control it gives.
CWEs
CWE-20 Improper Input Validation
CWE-78 Improper Neutralization of Special Elements used in an OS Command (OS Command Injection)
OWASP Top 10
A05:2025 Injection
Published
Modified
NVD analysis
Analyzed, since modified
Record from
the NVD, synced

Fix and patched versions

Ask an AI about this CVE

Show the promptExplain CVE-2026-40261 for an engineer deciding whether to act. Use https://cve.bz/api/public/cves/CVE-2026-40261?via=ask-ai-copy and https://cve.bz/cve/CVE-2026-40261?via=ask-ai-copy as the source of truth: what is affected and which versions fix it, whether it is in CISA KEV, public exploits, and its EPSS (an internet-wide 30-day estimate of exploitation activity, not a forecast for my systems). If they give no fixed versions, use the CVE record https://cveawg.mitre.org/api/cve/CVE-2026-40261 or the vendor advisory, not third-party mirrors. Tell me how to check whether I am affected and how to verify a fix. Cite the sources and say where they are uncertain.

Opens a third-party assistant; its answer is its own, not cve.bz's. The prompt holds only this CVE's id and public links.

Affected

Versions

From the NVD's CPE matches.

ProductAffected
getcomposer:composerfrom 1.0.0 through 2.2.26
getcomposer:composerfrom 2.3.0 through 2.9.5

Packages (OSV)

AdvisoryEcosystemPackageAffectedFixed in
GHSA-gqw4-4w2p-838qPackagistcomposer/composer>=2.3.0 <2.9.62.9.6
GHSA-gqw4-4w2p-838qPackagistcomposer/composer>=1.0.0 <2.2.272.2.27

Linux distributions

DistributionReleasePackageFixed inAdvisory
Debian12composer2.5.5-1+deb12u4DEBIAN-CVE-2026-40261
Debian13composer2.8.8-1+deb13u2DEBIAN-CVE-2026-40261
Debian14composer2.9.7-1DEBIAN-CVE-2026-40261
Ubuntu25.10, 26.04:LTS, 26.10 and 5 morecomposerno fix listedUBUNTU-CVE-2026-40261
Red Hathummingbird:1composer0:2.9.7-1.hum1RHSA-2026:8165
SUSELinux Enterprise Module for Web and Scripting 15 SP7, Linux Enterprise Server 15 SP6-LTSS, Linux Enterprise Server for SAP Applications 15 SP6php-composer22.6.4-150600.3.12.1SUSE-SU-2026:3105-1
SUSELinux Enterprise Server 16.0, Linux Enterprise Server for SAP applications 16.0php-composer22.8.9-160000.4.1SUSE-SU-2026:23116-1 SUSE-SU-2026:23138-1
openSUSELeap 16.0php-composer22.8.9-160000.4.1openSUSE-SU-2026:21520-1
openSUSETumbleweedphp-composer22.9.7-1.1openSUSE-SU-2026:10643-1
Alpinev3.23, v3.24composer2.9.6-r0ALPINE-CVE-2026-40261

From the distributions' data via OSV.dev: the Debian Security Tracker; Ubuntu Security Notices © Canonical Ltd., CC BY-SA 4.0; Red Hat Security Data © Red Hat, Inc., CC BY 4.0; SUSE security data, CC BY 4.0; the Alpine secdb, CC BY-SA 4.0. Modified: reformatted and linked to CVE records. Credits. On the distributions' own pages: Debian · Ubuntu · Red Hat · SUSE · openSUSE · Alpine.

Red Hat

Red Hat rates this Important.

Red Hat's statement

This issue can be exploited via any package served by a compromised or malicious Composer repository when installing or updating dependencies from source, including the default behavior when installing dev-prefixed versions. Exploitation results in arbitrary command execution. Due to these reasons, this flaw has been rated with an important severity.

Red Hat's mitigation

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

ProductPackageStateAdvisory
Red Hat Hardened Imagescomposer-main-2.9.7-1.hum1Fixed 2026-04-14RHSA-2026:8165

Contains Red Hat Security Data © Red Hat, Inc., licensed under CC BY 4.0. Source: https://access.redhat.com/security/data. Modified: reformatted. Red Hat's page for CVE-2026-40261.

GitHub PoC

Repositories on GitHub named after this CVE or listed for it by the PoC-in-GitHub index. For those marked Harbor Check: matches CVE, Flawharbor read the code and found it implements this CVE's exploitation technique: read, not run, and its dependencies only checked for warning signs, so a pointer and no guarantee. The rest are unverified: some hold a working proof of concept, some nothing useful, and some malware made to look like one. Read the code before you run any of it. How Harbor Check reads them, and what it found.

Attack patterns (CAPEC)

  • CAPEC-6 Argument Injection Likelihood: High · Severity: High
  • CAPEC-15 Command Delimiters Likelihood: High · Severity: High
  • CAPEC-43 Exploiting Multiple Input Interpretation Layers Likelihood: Medium · Severity: High
  • CAPEC-88 OS Command Injection Likelihood: High · Severity: High
  • CAPEC-108 Command Line Execution through SQL Injection Likelihood: Low · Severity: Very High

The attack patterns MITRE's CAPEC relates to this record's weaknesses, as MITRE names them. Credits. More on the page of CWE-20 (51).

References

Check your stackJSON