cve.bz

CVE-2026-40176 getcomposer composer: OS Command Injection

7.8 highEPSS 1.1%Fix available

High (7.8) in getcomposer composer. EPSS 1.1% 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::generateP4Command() method, which constructs shell commands by interpolating user-supplied Perforce connection parameters (port, user, client) without proper escaping. An attacker can inject arbitrary commands through these values in a malicious composer.json declaring a Perforce VCS repository, leading to command execution in the context of the user running Composer, even if Perforce is not installed. VCS repositories are only loaded from the root composer.json or the composer config directory, so this cannot be exploited through composer.json files of packages installed as dependencies. Users are at risk if they run Composer commands on untrusted projects with attacker-supplied composer.json files. This issue has been fixed in Composer 2.2.27 (2.2 LTS) and 2.9.6 (mainline).

Severity

CVSS 3.1

7.8 high
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
EPSS
1.1% (unchanged from 1.1% a week ago; 1.0% 30 days ago) estimated probability of exploitation activity in the next 30 days; 65th 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-40176 for an engineer deciding whether to act. Use https://cve.bz/api/public/cves/CVE-2026-40176?via=ask-ai-copy and https://cve.bz/cve/CVE-2026-40176?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-40176 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-wg36-wvj6-r67pPackagistcomposer/composer>=2.3.0 <2.9.62.9.6
GHSA-wg36-wvj6-r67pPackagistcomposer/composer>=1.0.0 <2.2.272.2.27

Linux distributions

DistributionReleasePackageFixed inAdvisory
Debian12composer2.5.5-1+deb12u4DEBIAN-CVE-2026-40176
Debian13composer2.8.8-1+deb13u2DEBIAN-CVE-2026-40176
Debian14composer2.9.7-1DEBIAN-CVE-2026-40176
Ubuntu25.10, 26.04:LTS, 26.10 and 5 morecomposerno fix listedUBUNTU-CVE-2026-40176
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-40176

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

To exploit this vulnerability, a user needs to run Composer commands on untrusted projects with attacker-supplied composer.json files. VCS repositories are only loaded from the root composer.json or the composer config directory, so this issue cannot be exploited through composer.json files of packages installed as dependencies. This issue can cause arbitrary command execution but it is limited to the context of the user running Composer. Due to these reasons, this flaw has been rated with an important severity.

Red Hat's mitigation

To mitigate this vulnerability, only run Composer commands on projects from trusted sources. Also, inspect composer.json files before running Composer commands on them, specifically checking that Perforce-related fields contain valid values.

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

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