---
title: "CVE-2024-21508: mysql2 Remote Code Execution (RCE) via the readCodeFor function"
url: https://erroneo.us/security/cve/CVE-2024-21508/
description: "CVE-2024-21508 (mysql2 (npm)): Versions of the package mysql2 before 3.9.4 are vulnerable to Remote Code Execution (RCE) via the readCodeFor function due to…"
type: vulnerability-record
section: "Security Digest"
date_published: 2024-04-11
date_modified: 2024-08-01
publisher: erroneo.us
author: erroneo.us Security Desk
cve: "CVE-2024-21508"
kev: false
cvss: 9.8
epss: 0.02554
license: All rights reserved. Quote with attribution and a link.
---

# CVE-2024-21508: mysql2 Remote Code Execution (RCE) via the readCodeFor function

**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?

- No confirmed exploitation. It is not in CISA’s KEV catalog and CISA’s SSVC assessment records no known exploitation. That can change quickly after a public write-up; re-check if you are affected.
- EPSS 2.6% , percentile 85: FIRST’s model estimates a 2.6% chance of exploitation activity in the next 30 days, higher than 85% of all scored CVEs (elevated). 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.4, fixed in 3.9.4 . Check your lockfile, including transitive dependencies.

## What it is

Versions of the package mysql2 before 3.9.4 are vulnerable to Remote Code Execution (RCE) via the readCodeFor function due to improper validation of the supportBigNumbers and bigNumberStrings values.

## Affected packages

- npm `mysql2` < 3.9.4 → fixed: 3.9.4

## Affected products (CVE record)

- n/a mysql2: < 3.9.4

## 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 none , automatable yes , technical impact total .
- FIRST EPSS (model of 2026-10-21): 2.55% probability of exploitation activity in the next 30 days; percentile 85.

## Sources

- [GitHub Advisory GHSA-fpw7-j2hg-69v5](https://github.com/advisories/GHSA-fpw7-j2hg-69v5)
- [CVE.org record CVE-2024-21508](https://www.cve.org/CVERecord?id=CVE-2024-21508)
- [NVD entry CVE-2024-21508](https://nvd.nist.gov/vuln/detail/CVE-2024-21508)
- [security.snyk.io](https://security.snyk.io/vuln/SNYK-JS-MYSQL2-6591085)
- [blog.slonser.info](https://blog.slonser.info/posts/mysql2-attacker-configuration/)
- [github.com](https://github.com/sidorares/node-mysql2/blob/1609b5393516d72a4ae47196837317fbe75e0c13/lib/parsers/text_parser.js%23L14C10-L14C21)
- [github.com](https://github.com/sidorares/node-mysql2/pull/2572)
- [github.com](https://github.com/sidorares/node-mysql2/commit/74abf9ef94d76114d9a09415e28b496522a94805)
- [github.com](https://github.com/sidorares/node-mysql2/releases/tag/v3.9.4)

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