CVE-2024-35242: Composer/composer Composer Has Multiple Command Injections Vulnerability

HIGH
Advisory Identifier: GHSA-v9qv-c7wm-wgmf
CVSS 8.8
CWE-77
Published
Advisory Summary

CVE-2024-35242 is a HIGH (CVSS 8.8) composer has multiple command injections 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 multiple command injections via malicious git/hg branch names. Remediation is available by upgrading affected packages to version 2.2.24, 2.7.7.

CVE-2024-35242 at a Glance

CVE Identifier CVE-2024-35242
GHSA Identifier GHSA-v9qv-c7wm-wgmf
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection')
Affected Product Composer/composer
Package Ecosystem Packagist
Published Date
Last Updated

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

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2024-35242

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.

composer/composer fixed: 2.2.24
Upgrade composer/composer to 2.2.24
composer/composer fixed: 2.7.7
Upgrade composer/composer to 2.7.7
Verify Direct and Transitive Dependencies

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-35242, 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

### Impact The `composer install` command running inside a git/hg repository which has specially crafted branch names can lead to command injection. So this requires cloning untrusted repositories. ### Patches 2.2.24 for 2.2 LTS or 2.7.7 for mainline ### Workarounds Avoid cloning potentially compromised repositories.

CVE-2024-35242 Affected Composer/composer Versions

2 component(s)
Fixed Versions:
2.2.242.7.7
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-35242?
CVE-2024-35242 is a security vulnerability in Composer/composer involving Composer has multiple command injections via malicious git/hg branch names under CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection').
Which Composer/composer versions are affected?
Affected versions include releases prior to 2.2.24, 2.7.7 across affected packages: composer/composer.
What version fixes CVE-2024-35242?
Upgrading to 2.2.24, 2.7.7 (or the latest patched release for your respective branch) resolves the vulnerability.
Is composer/composer affected?
Yes, composer/composer is affected in releases prior to 2.2.24, 2.7.7. Upgrade your dependency to 2.2.24, 2.7.7 or later.
What is the CVSS score of CVE-2024-35242?
CVE-2024-35242 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2024-35242?
CVE-2024-35242 is classified under CWE-77: Improper Neutralization of Special Elements used in a Command ('Command Injection') (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.).
How can I check Packagist dependencies for CVE-2024-35242?
Run the dependency tree command: 'inspect dependencies for composer/composer'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-v9qv-c7wm-wgmf",
  "modified" : "2025-02-13T18:50:48Z",
  "published" : "2024-06-10T21:36:25Z",
  "aliases" : [ "CVE-2024-35242" ],
  "summary" : "Composer has multiple command injections via malicious git/hg branch names",
  "details" : "### Impact\n\nThe `composer install` command running inside a git/hg repository which has specially crafted branch names can lead to command injection. So this requires cloning untrusted repositories.\n\n### Patches\n\n2.2.24 for 2.2 LTS or 2.7.7 for mainline\n\n### Workarounds\n\nAvoid cloning potentially compromised repositories.",
  "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-v9qv-c7wm-wgmf"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-35242"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/composer/composer/commit/6bd43dff859c597c09bd03a7e7d6443822d0a396"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/composer/composer/commit/fc57b93603d7d90b71ca8ec77b1c8a9171fdb467"
  }, {
    "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"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-77" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-06-10T21:36:25Z",
    "nvd_published_at" : "2024-06-10T22:15:09Z"
  }
}