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

> Attackers can execute arbitrary code and escalate privileges by tampering with Composer's local installation files, affecting CLI commands and self-updates.

- **Severity:** High 8.8 (`CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 8 Feb 2024
- **Updated:** 17 Jun 2025
- **Also known as:** BIT-composer-2024-24821, CLEANSTART-2024-JY83809, DEBIAN-CVE-2024-24821, DSA-5632-1, GHSA-7c6p-848j-wh5h, SUSE-SU-2024:0592-1, UBUNTU-CVE-2024-24821, openSUSE-SU-2024:13681-1

## What is CVE-2024-24821?

CVE-2024-24821 is a high-severity code injection vulnerability in composer, published on 8 Feb 2024. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

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
```

Weakness: CWE-829 (Inclusion of Functionality from Untrusted Control Sphere)

## Which versions are affected by CVE-2024-24821?

5 open source packages ship an affected version, including composer/composer and composer. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `composer/composer` | Packagist | From 2.0.0-alpha1 | 2.2.23 |
| `composer/composer` | Packagist | From 2.0.0-alpha1 | 2.2.23 |
| `composer/composer` | Packagist | From 2.3.0-rc1 | 2.7.0 |
| `composer/composer` | Packagist | From 2.3.0-rc1 | 2.7.0 |
| `composer` | Bitnami | From 2.0.0 | 2.2.23, 2.7.0 |
| `php-composer2` | SUSE:Linux Enterprise High Performance Computing 15 SP4-ESPOS | All versions | 2.2.3-150400.3.9.1 |
| `php-composer2` | SUSE:Linux Enterprise High Performance Computing 15 SP4-LTSS | All versions | 2.2.3-150400.3.9.1 |
| `php-composer2` | SUSE:Linux Enterprise Module for Web and Scripting 15 SP5 | All versions | 2.2.3-150400.3.9.1 |
| `php-composer2` | SUSE:Linux Enterprise Server 15 SP4-LTSS | All versions | 2.2.3-150400.3.9.1 |
| `php-composer2` | SUSE:Linux Enterprise Server for SAP Applications 15 SP4 | All versions | 2.2.3-150400.3.9.1 |
| `php-composer2` | SUSE:Manager Server 4.3 | All versions | 2.2.3-150400.3.9.1 |
| `php-composer2` | openSUSE:Leap 15.5 | All versions | 2.2.3-150400.3.9.1 |
| `php-composer2` | openSUSE:Tumbleweed | All versions | 2.7.1-1.1 |

Products: Getcomposer Composer.

## How do I fix CVE-2024-24821?

Upgrade composer/composer to a fixed version for your release line: 2.2.23 or 2.7.0.

## Is CVE-2024-24821 being exploited?

There is no known exploitation of CVE-2024-24821 in the wild and no public exploit code.

## Other vulnerabilities in composer

- [CVE-2026-40261](https://insights.sbomify.com/CVE-2026-40261/): Composer has Command Injection via Malicious Perforce Reference (high 8.8)
- [CVE-2015-8371](https://insights.sbomify.com/CVE-2015-8371/): Composer allows cache poisoning from other projects built on the same host (high 8.8)
- [CVE-2021-41116](https://insights.sbomify.com/CVE-2021-41116/): Command injection in composer on Windows (high 8.2)
- [CVE-2026-40176](https://insights.sbomify.com/CVE-2026-40176/): Composer is vulnerable to Command Injection via Malicious Perforce Repository (high 7.8)
- [CVE-2025-67746](https://insights.sbomify.com/CVE-2025-67746/): Composer vulnerable to ANSI sequence injection (low 1.3)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-24821 and fix it if it is affected.

What it is: CVE-2024-24821 is a high-severity code injection vulnerability in composer, published on 8 Feb 2024. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2024-24821 in the wild and no public exploit code.

Affected packages and fixed versions:
- composer/composer (Packagist): affected from 2.0.0-alpha1; fixed in 2.2.23
- composer/composer (Packagist): affected from 2.0.0-alpha1; fixed in 2.2.23
- composer/composer (Packagist): affected from 2.3.0-rc1; fixed in 2.7.0
- composer/composer (Packagist): affected from 2.3.0-rc1; fixed in 2.7.0
- composer (Bitnami): affected from 2.0.0; fixed in 2.2.23, 2.7.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-24821/ (Markdown: https://insights.sbomify.com/CVE-2024-24821/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-24821
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-24821
- OSV: https://osv.dev/vulnerability/CVE-2024-24821

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-24821/
Summaries are generated and may contain mistakes; the official description above is the record.
