Cloudanix VulnDB

CVE-2024-35241

High · 8.8

CVSS

8.8

EPSS

1.1%

Published

Jun 10, 2024

CISA due date

—

Cloudanix analysis

Schedule a fix SSVC: Track

A bug in the Composer tool lets attackers run their own code on a developer's computer if that computer uses certain commands on packages downloaded directly from specially prepared code repositories.

Exploitation
Requires User Interaction
Attacker needs
User Interaction
Complexity
Moderate
Impact
Remote Code Execution
Component
Application
Class
Command Injection
Remediation
Upgrade
Effort
Medium
Patch risk
Low

What it actually does

Command injection vulnerability allowing arbitrary code execution when Composer executes git commands on repositories containing specially crafted branch names during status, reinstall, or remove operations on source-installed packages.

Why it matters to the business

Attackers can gain remote code execution on developer workstations and build systems that manage PHP dependencies, potentially leading to supply-chain compromise, data theft, or deployment of malware into production software.

How an attack unfolds

An attacker publishes a malicious PHP package on a git repository with a branch name containing shell metacharacters. When a victim runs composer status, reinstall, or remove on a project depending on that package installed from source, Composer passes the branch name unsafely to a shell command, resulting in code execution.

How to fix it

Upgrade to Composer 2.2.24 or 2.7.7. As a workaround, configure preferred-install to dist or pass --prefer-dist to avoid source installations from git.

How to confirm the fix worked

Verify Composer version is at least 2.2.24 or 2.7.7; test by attempting to run the affected commands against a repository with a known-malicious branch name in a controlled environment; confirm that git operations no longer expand untrusted branch names into shell commands.

Typical attack path

  1. Attacker creates a git repository with a package and a branch name embedding shell commands
  2. Victim adds the malicious package as a dependency installed from source via git
  3. Victim executes composer status, reinstall, or remove
  4. Composer invokes git with the crafted branch name, triggering command injection
  5. Arbitrary code executes under the privileges of the Composer process

How to detect it

Review Composer logs, git command history, and shell audit logs for unexpected branch names or shell metacharacters during status/reinstall/remove operations; look for processes spawned by Composer that perform unexpected network or file activity.

What your security team should do

  • Immediately upgrade all Composer installations to 2.2.24 (LTS) or 2.7.7
  • Enforce preferred-install: dist in composer.json or use --prefer-dist in CI pipelines
  • Scan dependency manifests and lockfiles for any packages installed from git source
  • Add Composer version checks to build pipelines and developer onboarding
  • Monitor for new Composer releases given the package manager's central role in PHP ecosystems

The record

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.

Affected packages

Ecosystem Package Introduced Fixed
Packagist composer/composer 2.0 2.2.24
Packagist composer/composer 2.3 2.7.7
Bitnami composer 2.0.0 2.2.24
Chainguard composer 0 2.7.7-r0
Debian:10 composer 0 1.8.4-1+deb10u4
Debian:11 composer 0 2.0.9-2+deb11u3
Debian:12 composer 0 2.5.5-1+deb12u2
Debian:13 composer 0 2.7.7-1
SUSE:Linux Enterprise High Performance Computing 15 SP4-ESPOS php-composer2 0 2.2.3-150400.3.12.1
SUSE:Linux Enterprise High Performance Computing 15 SP4-LTSS php-composer2 0 2.2.3-150400.3.12.1
SUSE:Linux Enterprise Module for Web and Scripting 15 SP5 php-composer2 0 2.2.3-150400.3.12.1
SUSE:Linux Enterprise Module for Web and Scripting 15 SP6 php-composer2 0 2.6.4-150600.3.3.1
SUSE:Linux Enterprise Server 15 SP4-LTSS php-composer2 0 2.2.3-150400.3.12.1
SUSE:Linux Enterprise Server for SAP Applications 15 SP4 php-composer2 0 2.2.3-150400.3.12.1
SUSE:Manager Server 4.3 php-composer2 0 2.2.3-150400.3.12.1
Ubuntu:20.04:LTS composer 0 No fix
Ubuntu:22.04:LTS composer 0 No fix
Ubuntu:24.04:LTS composer 0 No fix
Ubuntu:24.10 composer 0 2.7.7-2
Ubuntu:Pro:16.04:LTS composer 0 No fix
Ubuntu:Pro:16.04:LTS composer 0 1.0.0~beta2-1ubuntu0.1~esm2
Ubuntu:Pro:18.04:LTS composer 0 No fix
Ubuntu:Pro:18.04:LTS composer 0 1.6.3-1ubuntu0.1~esm2
Ubuntu:Pro:20.04:LTS composer 0 1.10.1-1ubuntu0.1~esm2
Ubuntu:Pro:22.04:LTS composer 0 2.2.6-2ubuntu4+esm1
Ubuntu:Pro:24.04:LTS composer 0 2.7.1-2ubuntu0.1~esm1
Wolfi composer 0 2.7.7-r0
openSUSE:Leap 15.5 php-composer2 0 2.2.3-150400.3.12.1
openSUSE:Leap 15.6 php-composer2 0 2.6.4-150600.3.3.1
openSUSE:Tumbleweed php-composer2 0 2.7.7-1.1
packagist composer/composer 2.0 2.2.24
packagist composer/composer 2.3 2.7.7

Related vulnerabilities