CVE-2024-24821: Composer/composer Composer Code Execution And Possible Vulnerability
HIGHCVE-2024-24821 is a HIGH (CVSS 8.8) composer code execution and possible vulnerability (CWE-829: Inclusion of Functionality from Untrusted Control Sphere) affecting Composer/composer libraries in the Packagist ecosystem. The issue involves composer code execution and possible privilege escalation via compromised installedversions.php or installed.php. Remediation is available by upgrading affected packages to version 2.2.23, 2.7.0.
CVE-2024-24821 at a Glance
Security Impact
CVSS: 8.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H).
How to Fix CVE-2024-24821
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.
Upgrade composer/composer to 2.2.23
Upgrade composer/composer to 2.7.0
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-24821, 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.23), 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-829: Inclusion of Functionality from Untrusted Control Sphere, where the product imports, requires, or includes executable functionality (such as a library) from a source that is outside of the intended control sphere. 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
CVE-2024-24821 Affected Composer/composer Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
composer/composer
|
Packagist |
≥ 2.0.0-alpha1
< 2.2.23
|
2.2.23
|
|
composer/composer
|
Packagist |
≥ 2.3.0-rc1
< 2.7.0
|
2.7.0
|
References
Frequently Asked Questions
What is CVE-2024-24821?
Which Composer/composer versions are affected?
What version fixes CVE-2024-24821?
Is composer/composer affected?
What is the CVSS score of CVE-2024-24821?
What CWE is associated with CVE-2024-24821?
How can I check Packagist dependencies for CVE-2024-24821?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-7c6p-848j-wh5h",
"modified" : "2024-02-09T17:49:02Z",
"published" : "2024-02-08T15:06:38Z",
"aliases" : [ "CVE-2024-24821" ],
"summary" : "Composer code execution and possible privilege escalation via compromised InstalledVersions.php or installed.php",
"details" : "### Impact\n\nSeveral files within the local working directory are included during the invocation of Composer and in the context of the executing user.\n\nAs 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.\n\nAll Composer CLI commands are affected, including composer.phar's self-update.\n\nThe following are of high risk:\n\n- Composer being run with sudo.\n- Pipelines which may execute Composer on untrusted projects.\n- Shared environments with developers who run Composer individually on the same project.\n\n### Patches\n\n2.7.0, 2.2.23\n\n### Workarounds\n\n- It is advised that the patched versions are applied at the earliest convenience.\n\nWhere not possible, the following should be addressed:\n- Remove all sudo composer privileges for all users to mitigate root privilege escalation. \n- 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. \n\nA reset can also be done on these files by the following:\n\n```sh\nrm vendor/composer/installed.php vendor/composer/InstalledVersions.php\ncomposer install --no-scripts --no-plugins\n```",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Packagist",
"name" : "composer/composer"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.0.0-alpha1"
}, {
"fixed" : "2.2.23"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Packagist",
"name" : "composer/composer"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.3.0-rc1"
}, {
"fixed" : "2.7.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/composer/composer/security/advisories/GHSA-7c6p-848j-wh5h"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-24821"
}, {
"type" : "WEB",
"url" : "https://github.com/composer/composer/commit/64e4eb356b159a30c766cd1ea83450a38dc23bf5"
}, {
"type" : "WEB",
"url" : "https://github.com/composer/composer/commit/77e3982918bc1d886843dc3d5e575e7e871b27b7"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/composer/composer"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-829" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2024-02-08T15:06:38Z",
"nvd_published_at" : "2024-02-09T00:15:08Z"
}
}