Skip to content

Composer code execution and possible privilege escalation via compromised InstalledVersions.php or installed.php

High severity GitHub Reviewed Published Feb 8, 2024 in composer/composer • Updated Feb 9, 2024

Package

composer composer/composer (Composer)

Affected versions

>= 2.0.0-alpha1, < 2.2.23
>= 2.3.0-rc1, < 2.7.0

Patched versions

2.2.23
2.7.0

Description

Impact

Several files within the local working directory are included during the invocation of Composer and in the context of the executing user.

As such, under certain conditions arbitrary code execution may lead to local privilege escalation, provide lateral user movement or malicious code execution when Composer is invoked within a directory with tampered files.

All Composer CLI commands are affected, including composer.phar's self-update.

The following are of high risk:

  • Composer being run with sudo.
  • Pipelines which may execute Composer on untrusted projects.
  • Shared environments with developers who run Composer individually on the same project.

Patches

2.7.0, 2.2.23

Workarounds

  • It is advised that the patched versions are applied at the earliest convenience.

Where not possible, the following should be addressed:

  • Remove all sudo composer privileges for all users to mitigate root privilege escalation.
  • Avoid running Composer within an untrusted directory, or if needed, verify that the contents of vendor/composer/InstalledVersions.php and vendor/composer/installed.php do not include untrusted code.

A reset can also be done on these files by the following:

rm vendor/composer/installed.php vendor/composer/InstalledVersions.php
composer install --no-scripts --no-plugins

References

@Seldaek Seldaek published to composer/composer Feb 8, 2024
Published to the GitHub Advisory Database Feb 8, 2024
Reviewed Feb 8, 2024
Published by the National Vulnerability Database Feb 9, 2024
Last updated Feb 9, 2024

Severity

High
8.8
/ 10

CVSS base metrics

Attack vector
Local
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Changed
Confidentiality
High
Integrity
High
Availability
High
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H

Weaknesses

CVE ID

CVE-2024-24821

GHSA ID

GHSA-7c6p-848j-wh5h

Source code

Credits

Checking history
See something to contribute? Suggest improvements for this vulnerability.