CVE-2024-35241: Composer/composer Composer Has A Command Injection Vulnerability
HIGHCVE-2024-35241 is a HIGH (CVSS 8.8) composer has a command injection vulnerability (CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection')) affecting Composer/composer libraries in the Packagist ecosystem. The issue involves composer has a command injection via malicious git branch name. Remediation is available by upgrading affected packages to version 2.2.24, 2.7.7.
CVE-2024-35241 at a Glance
Security Impact
CVSS: 8.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H).
How to Fix CVE-2024-35241
To remediate this vulnerability, upgrade all affected Composer/composer dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade composer/composer to 2.2.24
Upgrade composer/composer to 2.7.7
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for composer/composer
How to Check if You Are Affected
To determine whether your application is affected by CVE-2024-35241, inspect your project dependencies for Composer/composer:
inspect dependencies for composer/composer
Analyze the terminal output to locate any version of Composer/composer in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.2.24), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection'), where the product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component. In Composer/composer, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-35241 Affected Composer/composer Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
composer/composer
|
Packagist |
≥ 2.0
< 2.2.24
|
2.2.24
|
|
composer/composer
|
Packagist |
≥ 2.3
< 2.7.7
|
2.7.7
|
References
Frequently Asked Questions
What is CVE-2024-35241?
Which Composer/composer versions are affected?
What version fixes CVE-2024-35241?
Is composer/composer affected?
What is the CVSS score of CVE-2024-35241?
What CWE is associated with CVE-2024-35241?
How can I check Packagist dependencies for CVE-2024-35241?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-47f6-5gq3-vx9c",
"modified" : "2025-04-23T14:38:49Z",
"published" : "2024-06-10T21:36:32Z",
"aliases" : [ "CVE-2024-35241" ],
"summary" : "Composer has a command injection via malicious git branch name",
"details" : "### Impact\n\nThe `status`, `reinstall` and `remove` commands with packages installed from source via git containing specially crafted branch names in the repository can be used to execute code.\n\n### Patches\n\n2.2.24 for 2.2 LTS or 2.7.7 for mainline\n\n### Workarounds\n\nAvoid installing dependencies via git by using `--prefer-dist` or the `preferred-install: dist` config setting.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Packagist",
"name" : "composer/composer"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.0"
}, {
"fixed" : "2.2.24"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Packagist",
"name" : "composer/composer"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.3"
}, {
"fixed" : "2.7.7"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/composer/composer/security/advisories/GHSA-47f6-5gq3-vx9c"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-35241"
}, {
"type" : "WEB",
"url" : "https://github.com/composer/composer/commit/b93fc6ca437da35ae73d667d0618749c763b67d4"
}, {
"type" : "WEB",
"url" : "https://github.com/composer/composer/commit/ee28354ca8d33c15949ad7de2ce6656ba3f68704"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/composer/composer"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/PO4MU2BC7VR6LMHEX4X7DKGHVFXZV2MC"
}, {
"type" : "WEB",
"url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/VLPJHM2WWSYU2F6KHW2BYFGYL4IGTKHC"
}, {
"type" : "WEB",
"url" : "https://www.vicarius.io/vsociety/posts/cve-2024-35241-detect-composer-vulnerability"
}, {
"type" : "WEB",
"url" : "https://www.vicarius.io/vsociety/posts/cve-2024-35241-mitigate-vulnerable-composer"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-77" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2024-06-10T21:36:32Z",
"nvd_published_at" : "2024-06-10T22:15:09Z"
}
}