CVE-2024-24821: Code execution and possible privilege escalation via compromised InstalledVersions.php or installed.php in Composer

Published Feb 8, 2024
·
Updated

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:

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

Other sources

Composer is a dependency Manager for the PHP language. In affected versions 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 scenarios 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. This vulnerability has been addressed in versions 2.7.0 and 2.2.23. 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, and 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:sh rm vendor/composer/installed.php vendor/composer/InstalledVersions.php composer install --no-scripts --no-plugins

MITRE

Affected Software

4 affected componentsFixes available
composer/composer/composer>=2.3.0-rc1<2.7.0
2.7.0
composer/composer/composer>=2.0.0-alpha1<2.2.23
2.2.23
Getcomposer Composer>=2.0.0<2.2.23
Getcomposer Composer>=2.3.0<2.7.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade composer/composer/composer to a version that resolves this vulnerability.

    Fixed in 2.7.0
  2. Upgrade

    Upgrade composer/composer/composer to a version that resolves this vulnerability.

    Fixed in 2.2.23
  3. Upgrade

    Upgrade composer to a version that resolves this vulnerability.

    Fixed in 2.7.0
  4. Upgrade

    Upgrade composer to a version that resolves this vulnerability.

    Fixed in 2.2.23
  5. Remove

    Remove vendor/composer/installed.php and vendor/composer/InstalledVersions.php from your environment.

    Delete the files `vendor/composer/installed.php` and `vendor/composer/InstalledVersions.php` (e.g., `rm vendor/composer/installed.php vendor/composer/InstalledVersions.php`) to reset them as described.

  6. Configuration

    Remove all sudo composer privileges for all users to mitigate root privilege escalation.

    Composer (privilege usage) sudo execution = disabled
  7. Configuration

    When applicable, run Composer with `composer install --no-scripts --no-plugins` as a workaround.

    Composer CLI invocation flags = --no-scripts --no-plugins
  8. Compensating control

    Avoid running Composer within an untrusted directory; if needed, verify that `vendor/composer/InstalledVersions.php` and `vendor/composer/installed.php` do not include untrusted code before invoking Composer.

Event History

Feb 8, 2024
Advisory Published
via GitHub·03:06 PM
CVE Published
via MITRE·11:54 PM
Data Sourced
via MITRE·11:54 PM
DescriptionSeverityWeakness
Feb 9, 2024
Data Sourced
via NVD·12:15 AM
RemedyDescriptionSeverityWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2024-24821?

CVE-2024-24821 has a high severity due to the potential for arbitrary code execution and local privilege escalation.

2

How do I fix CVE-2024-24821?

To fix CVE-2024-24821, upgrade Composer to version 2.7.0 or 2.2.23 or later.

3

Which versions of Composer are affected by CVE-2024-24821?

CVE-2024-24821 affects Composer versions between 2.0.0-alpha1 and 2.2.23, as well as between 2.3.0-rc1 and 2.7.0.

4

What impact does CVE-2024-24821 have on system security?

CVE-2024-24821 can lead to local privilege escalation and lateral movement within the user environment.

5

Is CVE-2024-24821 exploitable remotely?

CVE-2024-24821 is not primarily a remote vulnerability, but it can be exploited locally under specific conditions.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203