---
title: "CVE-2024-21511: MySQL2 for Node Arbitrary Code Injection"
url: https://erroneo.us/security/cve/CVE-2024-21511/
description: "CVE-2024-21511 (mysql2 (npm)): Versions of the package mysql2 before 3.9.7 are vulnerable to Arbitrary Code Injection due to improper sanitization of the…"
type: vulnerability-record
section: "Security Digest"
date_published: 2024-04-23
date_modified: 2024-08-01
publisher: erroneo.us
author: erroneo.us Security Desk
cve: "CVE-2024-21511"
kev: false
cvss: 9.8
epss: 0.01034
license: All rights reserved. Quote with attribution and a link.
---

# CVE-2024-21511: MySQL2 for Node Arbitrary Code Injection

**Signal:** Critical and remotely reachable. No known exploitation yet, but it is network-reachable without credentials. (Computed from CISA KEV, EPSS and CVSS; not an editorial verdict.)

## Should you act?

- Not in CISA KEV , but CISA’s SSVC assessment records a public proof-of-concept, so attack code exists.
- EPSS 1.0% , percentile 63: FIRST’s model estimates a 1.0% chance of exploitation activity in the next 30 days, higher than 63% of all scored CVEs (moderate). EPSS is a probability, not a verdict.
- Remotely reachable with no login and no user interaction. If the vulnerable service is exposed to the internet, prioritize it.
- Only applies if your dependency tree includes mysql2 (npm) < 3.9.7, fixed in 3.9.7 . Check your lockfile, including transitive dependencies.

## What it is

Versions of the package mysql2 before 3.9.7 are vulnerable to Arbitrary Code Injection due to improper sanitization of the timezone parameter in the readCodeFor function by calling a native MySQL Server date/time function.

## Affected packages

- npm `mysql2` < 3.9.7 → fixed: 3.9.7

## Affected products (CVE record)

- n/a mysql2: < 3.9.7

## Severity

- snyk CVSS 3.1: 9.8 `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H/E:P`
- GitHub CVSS 3.1: 9.8 `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`

## Exploitation

- CISA KEV: not listed (no confirmed in-the-wild exploitation known to CISA).
- CISA SSVC assessment: exploitation poc , automatable yes , technical impact total .
- FIRST EPSS (model of 2026-10-21): 1.03% probability of exploitation activity in the next 30 days; percentile 63.

## Sources

- [GitHub Advisory GHSA-4rch-2fh8-94vw](https://github.com/advisories/GHSA-4rch-2fh8-94vw)
- [CVE.org record CVE-2024-21511](https://www.cve.org/CVERecord?id=CVE-2024-21511)
- [NVD entry CVE-2024-21511](https://nvd.nist.gov/vuln/detail/CVE-2024-21511)
- [security.snyk.io](https://security.snyk.io/vuln/SNYK-JS-MYSQL2-6670046)
- [github.com](https://github.com/sidorares/node-mysql2/releases/tag/v3.9.7)
- [github.com](https://github.com/sidorares/node-mysql2/pull/2608)
- [github.com](https://github.com/sidorares/node-mysql2/commit/7d4b098c7e29d5a6cb9eac2633bfcc2f0f1db713)

---
Source page: https://erroneo.us/security/cve/CVE-2024-21511/ · Security Digest: https://erroneo.us/security/ · More: https://erroneo.us/llms.txt
