CVE-2024-35241: CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection') in composer composer
Composer is a dependency manager for PHP. On the 2.x branch prior to versions 2.2.24 and 2.7.7, the `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. Patches for this issue are available in version 2.2.24 for 2.2 LTS or 2.7.7 for mainline. As a workaround, avoid installing dependencies via git by using `--prefer-dist` or the `preferred-install: dist` config setting.
AI Analysis
Technical Summary
CVE-2024-35241 is a command injection vulnerability affecting Composer, a widely used dependency manager for PHP projects. The vulnerability exists in Composer versions 2.x prior to 2.2.24 (for the 2.2 LTS branch) and prior to 2.7.7 (for the mainline branch). Specifically, the flaw is triggered when using the `status`, `reinstall`, or `remove` commands on packages installed from source via Git repositories that contain specially crafted branch names. These malicious branch names can include shell metacharacters or other special elements that are not properly neutralized, allowing an attacker to execute arbitrary commands on the host system where Composer is running. This is classified under CWE-77, which relates to improper neutralization of special elements used in commands, commonly known as command injection. The vulnerability arises because Composer executes Git commands internally and fails to sanitize branch names correctly, leading to injection of unintended commands. The issue can be mitigated by upgrading Composer to versions 2.2.24 or later on the 2.2 LTS branch, or 2.7.7 or later on the mainline branch. As a workaround, users can avoid installing dependencies directly from Git repositories by using the `--prefer-dist` option or setting the `preferred-install: dist` configuration, which installs packages from distribution archives rather than source. There are currently no known exploits in the wild, but the vulnerability poses a significant risk due to the widespread use of Composer in PHP development environments and continuous integration pipelines. Attackers who can influence the source repositories or branch names could leverage this flaw to execute arbitrary code, potentially compromising developer machines, build servers, or production environments where Composer is used.
Potential Impact
For European organizations, this vulnerability could lead to unauthorized code execution on systems running Composer, which is commonly used in PHP development and deployment workflows. The impact includes potential compromise of development workstations, continuous integration/continuous deployment (CI/CD) servers, and production environments if Composer is used to manage dependencies directly from Git sources. This could result in data breaches, unauthorized access to internal systems, insertion of malicious code into software builds, and disruption of software delivery processes. Organizations relying heavily on PHP applications, especially those using Composer to install packages from Git repositories, face increased risk. The vulnerability could also be exploited to move laterally within networks if attackers gain initial footholds via compromised developer machines or build servers. Given the integration of Composer in many European software development ecosystems, the threat could affect a broad range of sectors including finance, government, healthcare, and technology. The absence of known exploits in the wild currently reduces immediate risk, but the ease of exploitation through crafted branch names and the potential for automation make it a credible threat that warrants prompt remediation.
Mitigation Recommendations
1. Upgrade Composer immediately to version 2.2.24 or later if using the 2.2 LTS branch, or to 2.7.7 or later if on the mainline branch. 2. As an interim measure, configure Composer to avoid installing dependencies from Git source repositories by using the `--prefer-dist` flag or setting `preferred-install: dist` in the Composer configuration file. 3. Audit existing projects and CI/CD pipelines to identify any dependencies installed from Git sources and assess exposure. 4. Implement strict access controls and monitoring on developer machines and build servers to detect unusual command executions or process behaviors. 5. Educate development teams about the risks of installing dependencies directly from Git repositories with untrusted sources or branches. 6. Integrate Composer usage into security scanning tools to detect vulnerable versions and risky installation methods. 7. Review and harden Git repository management policies to prevent malicious branch names from being introduced, including validation and sanitization of branch names in internal repositories. 8. Monitor security advisories and Composer release notes for any updates or related vulnerabilities.
Affected Countries
Germany, France, United Kingdom, Netherlands, Italy, Spain, Poland, Sweden, Belgium, Ireland
CVE-2024-35241: CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection') in composer composer
Description
Composer is a dependency manager for PHP. On the 2.x branch prior to versions 2.2.24 and 2.7.7, the `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. Patches for this issue are available in version 2.2.24 for 2.2 LTS or 2.7.7 for mainline. As a workaround, avoid installing dependencies via git by using `--prefer-dist` or the `preferred-install: dist` config setting.
AI-Powered Analysis
Technical Analysis
CVE-2024-35241 is a command injection vulnerability affecting Composer, a widely used dependency manager for PHP projects. The vulnerability exists in Composer versions 2.x prior to 2.2.24 (for the 2.2 LTS branch) and prior to 2.7.7 (for the mainline branch). Specifically, the flaw is triggered when using the `status`, `reinstall`, or `remove` commands on packages installed from source via Git repositories that contain specially crafted branch names. These malicious branch names can include shell metacharacters or other special elements that are not properly neutralized, allowing an attacker to execute arbitrary commands on the host system where Composer is running. This is classified under CWE-77, which relates to improper neutralization of special elements used in commands, commonly known as command injection. The vulnerability arises because Composer executes Git commands internally and fails to sanitize branch names correctly, leading to injection of unintended commands. The issue can be mitigated by upgrading Composer to versions 2.2.24 or later on the 2.2 LTS branch, or 2.7.7 or later on the mainline branch. As a workaround, users can avoid installing dependencies directly from Git repositories by using the `--prefer-dist` option or setting the `preferred-install: dist` configuration, which installs packages from distribution archives rather than source. There are currently no known exploits in the wild, but the vulnerability poses a significant risk due to the widespread use of Composer in PHP development environments and continuous integration pipelines. Attackers who can influence the source repositories or branch names could leverage this flaw to execute arbitrary code, potentially compromising developer machines, build servers, or production environments where Composer is used.
Potential Impact
For European organizations, this vulnerability could lead to unauthorized code execution on systems running Composer, which is commonly used in PHP development and deployment workflows. The impact includes potential compromise of development workstations, continuous integration/continuous deployment (CI/CD) servers, and production environments if Composer is used to manage dependencies directly from Git sources. This could result in data breaches, unauthorized access to internal systems, insertion of malicious code into software builds, and disruption of software delivery processes. Organizations relying heavily on PHP applications, especially those using Composer to install packages from Git repositories, face increased risk. The vulnerability could also be exploited to move laterally within networks if attackers gain initial footholds via compromised developer machines or build servers. Given the integration of Composer in many European software development ecosystems, the threat could affect a broad range of sectors including finance, government, healthcare, and technology. The absence of known exploits in the wild currently reduces immediate risk, but the ease of exploitation through crafted branch names and the potential for automation make it a credible threat that warrants prompt remediation.
Mitigation Recommendations
1. Upgrade Composer immediately to version 2.2.24 or later if using the 2.2 LTS branch, or to 2.7.7 or later if on the mainline branch. 2. As an interim measure, configure Composer to avoid installing dependencies from Git source repositories by using the `--prefer-dist` flag or setting `preferred-install: dist` in the Composer configuration file. 3. Audit existing projects and CI/CD pipelines to identify any dependencies installed from Git sources and assess exposure. 4. Implement strict access controls and monitoring on developer machines and build servers to detect unusual command executions or process behaviors. 5. Educate development teams about the risks of installing dependencies directly from Git repositories with untrusted sources or branches. 6. Integrate Composer usage into security scanning tools to detect vulnerable versions and risky installation methods. 7. Review and harden Git repository management policies to prevent malicious branch names from being introduced, including validation and sanitization of branch names in internal repositories. 8. Monitor security advisories and Composer release notes for any updates or related vulnerabilities.
For access to advanced analysis and higher rate limits, contact root@offseq.com
Technical Details
- Data Version
- 5.1
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2024-05-14T15:39:41.786Z
- Cisa Enriched
- true
Threat ID: 682d984bc4522896dcbf7cb5
Added to database: 5/21/2025, 9:09:31 AM
Last enriched: 6/21/2025, 2:36:16 PM
Last updated: 7/30/2025, 5:16:46 PM
Views: 12
Related Threats
CVE-2025-36088: CWE-79 Improper Neutralization of Input During Web Page Generation (XSS or 'Cross-site Scripting') in IBM Storage TS4500 Library
MediumCVE-2025-43490: CWE-59 Improper Link Resolution Before File Access ('Link Following') in HP, Inc. HP Hotkey Support Software
MediumCVE-2025-9060: CWE-20 Improper Input Validation in MSoft MFlash
CriticalCVE-2025-8675: CWE-918 Server-Side Request Forgery (SSRF) in Drupal AI SEO Link Advisor
MediumCVE-2025-8362: CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') in Drupal GoogleTag Manager
MediumActions
Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.
External Links
Need enhanced features?
Contact root@offseq.com for Pro access with improved analysis and higher rate limits.