CVE-2026-40176
published high CVSS 3.1 · 7.8Composer is vulnerable to Command Injection via Malicious Perforce Repository
Package status and fixes
| Distro / vendor | Release | Package / product | Publisher status | Fixed build | Source |
|---|---|---|---|---|---|
| composer | — | composer>= 2.3, < 2.9.6 · >= 1.0, < 2.2.27 | Affected | Not stated | GitHub_M |
| Red Hat | — | composer-mainRed Hat Hardened Images · 2.9.7-1.hum1 and later · Other versions: affected | Unaffected | Not stated | redhat-SADP |
| Amazon Linux | AL2023 | Release evaluationALAS2023-2026-1625 | Fixed | Not stated | Amazon Linux assessment |
| Alpine Linux | edge | composer | Fixed | 2.9.6-r0 | Package fix record |
| SUSE / openSUSE | SLE-15-SP4 | php-composer2noarch | Advisory build | 2.2.27-150400.3.18.1 | SUSE-SU-2026:1970-1 |
| Amazon Linux | AL2023 | composernoarch | Listed in advisory | Not stated | ALAS2023-2026-1625 |
| Alpine Linux | v3.23 | composer | Fixed | 2.9.6-r0 | Package fix record |
| Alpine Linux | v3.24 | composer | Fixed | 2.9.6-r0 | Package fix record |
Show 15 more entries
| Distro / vendor | Release | Package / product | Publisher status | Fixed build | Source |
|---|---|---|---|---|---|
| SUSE / openSUSE | SLE-15-SP5 | php-composer2noarch | Advisory build | 2.2.27-150400.3.18.1 | SUSE-SU-2026:1970-1 |
| SUSE / openSUSE | SLE-15-SP6 | php-composer2noarch | Advisory build | 2.6.4-150600.3.12.1 | SUSE-SU-2026:3105-1 |
| SUSE / openSUSE | SLE-15-SP6 | php-composer2noarch | Advisory build | 2.6.4-150600.3.9.1 | SUSE-SU-2026:1784-1 |
| SUSE / openSUSE | SLE-15-SP7 | php-composer2noarch | Advisory build | 2.6.4-150600.3.12.1 | SUSE-SU-2026:3105-1 |
| SUSE / openSUSE | SLE-15-SP7 | php-composer2noarch | Advisory build | 2.6.4-150600.3.9.1 | SUSE-SU-2026:1784-1 |
| SUSE / openSUSE | SLE-16 | php-composer2noarch | Advisory build | 2.8.9-160000.3.1 | SUSE-SU-2026:21542-1 |
| SUSE / openSUSE | SLE-16 | php-composer2noarch | Advisory build | 2.8.9-160000.4.1 | SUSE-SU-2026:23116-1 |
| SUSE / openSUSE | SLE-16 | php-composer2noarch | Advisory build | 2.8.9-160000.4.1 | SUSE-SU-2026:23138-1 |
| SUSE / openSUSE | openSUSE-Leap-16.0 | php-composer2noarch | Advisory build | 2.8.9-160000.3.1 | OPENSUSE-SU-2026:20670-1 |
| SUSE / openSUSE | openSUSE-Leap-16.0 | php-composer2noarch | Advisory build | 2.8.9-160000.4.1 | OPENSUSE-SU-2026:21520-1 |
| SUSE / openSUSE | openSUSE-Tumbleweed | php-composer2aarch64 | Advisory build | 2.9.7-1.1 | OPENSUSE-SU-2026:10643-1 |
| SUSE / openSUSE | openSUSE-Tumbleweed | php-composer2ppc64le | Advisory build | 2.9.7-1.1 | OPENSUSE-SU-2026:10643-1 |
| SUSE / openSUSE | openSUSE-Tumbleweed | php-composer2s390x | Advisory build | 2.9.7-1.1 | OPENSUSE-SU-2026:10643-1 |
| SUSE / openSUSE | openSUSE-Tumbleweed | php-composer2x86_64 | Advisory build | 2.9.7-1.1 | OPENSUSE-SU-2026:10643-1 |
| Amazon Linux | AL2023 | composersrc | Listed in advisory | Not stated | ALAS2023-2026-1625 |
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::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).
A flaw was found in Composer. `Perforce::generateP4Command()` constructs shell commands by interpolating user-supplied Perforce connection parameters (port, user, client) without proper escaping, allowing an attacker to inject arbitrary commands through these values in a malicious composer.json declaring a Perforce VCS repository.
Related advisories
Vendor advisories explicitly linked to this CVE.
Assessment
CVSS risk assessment and additional context for this vulnerability.
- CVSS version
- 3.1
- Base score
- 7.8 / 10
- Severity
- high
- Provider
- GitHub_M · cna
- Vector string
- CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
Additional Assessments
| Version | Score | Severity | Provider | Vector | Scenarios |
|---|---|---|---|---|---|
| 3.1 | 7.8 | high | redhat-SADP · adp | CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H | — |
Publisher product statements
Version ranges and default statuses as reported by each provider.
| Vendor | Product | Version status | Source |
|---|---|---|---|
| composer | composer | >= 2.3, < 2.9.6 (affected)>= 1.0, < 2.2.27 (affected) | GitHub_M · cna |
| Red Hat | Red Hat Hardened Images | 2.9.7-1.hum1 and later (unaffected · rpm)Default: affected | redhat-SADP · adp |
Weaknesses
3- CWE-20 CWE-20: Improper Input Validation
- CWE-78 CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
- CWE-78 Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
References
8- https://access.redhat.com/errata/RHSA-2026:8165
- https://access.redhat.com/security/cve/CVE-2026-40176
- https://bugzilla.redhat.com/show_bug.cgi?id=2458828
- https://github.com/FriendsOfPHP/security-advisories/blob/master/composer/composer/CVE-2026-40176.yaml
- https://github.com/composer/composer/releases/tag/2.2.27
- https://github.com/composer/composer/releases/tag/2.9.6
- https://github.com/composer/composer/security/advisories/GHSA-wg36-wvj6-r67p
- https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-40176.json
Provider assertions
3GitHub_M · cna
Composer is vulnerable to Command Injection via Malicious Perforce Repository
redhat-SADP · adp
composer: command injection via malicious Perforce repository definition
CISA-ADP · adp
CISA ADP Vulnrichment
Provenance
- Schema
- 5.2
- Searchable
- yes
- Content hash
- f8b07a7b1af669a1a4416dba941fdb537dd677294b387cf0debf29963964b4f5
- Ingested
- 02 Nov 2026, 23:14:50 UTC
- Source record
- Official CVE record