CVE-2024-21507: Mysql2 Mysql2 Cache Poisoning Vulnerability Vulnerability
MODERATECVE-2024-21507 is a MODERATE (CVSS 6.5) mysql2 cache poisoning vulnerability vulnerability (CWE-20: Improper Input Validation) affecting Mysql2 libraries in the npm ecosystem. The issue involves mysql2 cache poisoning vulnerability. Remediation is available by upgrading affected packages to version 3.9.3.
CVE-2024-21507 at a Glance
Security Impact
CVSS: 6.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:L).
How to Fix CVE-2024-21507
To remediate this vulnerability, upgrade all affected Mysql2 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install mysql2@3.9.3
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls mysql2
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2024-21507, inspect your project dependencies using npm:
npm ls mysql2
Analyze the terminal output to locate any version of Mysql2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.9.3), your application is affected.
Note: The npm ls mysql2 command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. In Mysql2, 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-21507 Affected Mysql2 Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
mysql2
|
npm |
< 3.9.3
|
3.9.3
|
References
Frequently Asked Questions
What is CVE-2024-21507?
Which Mysql2 versions are affected?
What version fixes CVE-2024-21507?
Is mysql2 affected?
What is the CVSS score of CVE-2024-21507?
What CWE is associated with CVE-2024-21507?
How can I check npm dependencies for CVE-2024-21507?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-mqr2-w7wj-jjgr",
"modified" : "2024-08-02T15:40:05Z",
"published" : "2024-04-10T15:30:39Z",
"aliases" : [ "CVE-2024-21507" ],
"summary" : "mysql2 cache poisoning vulnerability",
"details" : "Versions of the package mysql2 before 3.9.3 are vulnerable to Improper Input Validation through the `keyFromFields` function, resulting in cache poisoning. An attacker can inject a colon `:` character within a value of the attacker-crafted key.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:L"
}, {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:L/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "mysql2"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.9.3"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-21507"
}, {
"type" : "WEB",
"url" : "https://github.com/sidorares/node-mysql2/pull/2424"
}, {
"type" : "WEB",
"url" : "https://github.com/sidorares/node-mysql2/commit/0d54b0ca6498c823098426038162ef10df02c818"
}, {
"type" : "WEB",
"url" : "https://blog.slonser.info/posts/mysql2-attacker-configuration"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/sidorares/node-mysql2"
}, {
"type" : "WEB",
"url" : "https://security.snyk.io/vuln/SNYK-JS-MYSQL2-6591300"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-20" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2024-04-12T13:49:53Z",
"nvd_published_at" : "2024-04-10T05:15:48Z"
}
}