Join the Cyber Forum: Threat Intel on May 12, 2026 to learn how AI is reshaping threat defense.Join the Virtual Cyber Forum: Threat IntelRegister Now
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • AI Data Pipelines
      Security Data Pipeline for AI SIEM and Data Optimization
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2024-21511

CVE-2024-21511: mysql2 Package RCE Vulnerability

CVE-2024-21511 is a remote code execution flaw in the mysql2 package affecting versions before 3.9.7. Improper timezone parameter sanitization enables arbitrary code injection. This article covers technical details, impact, and mitigation.

Published: April 1, 2026

CVE-2024-21511 Overview

CVE-2024-21511 is an Arbitrary Code Injection vulnerability affecting the mysql2 Node.js package in versions prior to 3.9.7. The vulnerability exists due to improper sanitization of the timezone parameter in the readCodeFor function, which allows attackers to inject and execute arbitrary code by manipulating native MySQL Server date/time function calls.

Critical Impact

This vulnerability allows remote attackers to execute arbitrary code on systems running vulnerable versions of the mysql2 package without requiring authentication, potentially leading to complete system compromise.

Affected Products

  • mysql2 npm package versions before 3.9.7
  • Node.js applications using vulnerable mysql2 versions
  • Backend services relying on mysql2 for MySQL database connectivity

Discovery Timeline

  • April 23, 2024 - CVE-2024-21511 published to NVD
  • November 21, 2024 - Last updated in NVD database

Technical Details for CVE-2024-21511

Vulnerability Analysis

This Code Injection vulnerability (CWE-94) exists in the mysql2 package's binary and text parser modules. The vulnerability stems from unsafe handling of the timezone parameter when constructing dynamic code strings that are subsequently executed. When processing date/time fields from MySQL, the parser functions build code strings that include the timezone value without proper escaping or sanitization. An attacker who can control the timezone configuration value can inject malicious JavaScript code that will be executed when the parser processes date/time data from the database.

The attack is particularly dangerous because it requires no privileges to exploit and can be triggered remotely across the network. Successful exploitation results in complete compromise of confidentiality, integrity, and availability of the affected system.

Root Cause

The root cause lies in the readCodeFor function within both lib/parsers/binary_parser.js and lib/parsers/text_parser.js. These parsers construct JavaScript code strings by directly interpolating the timezone parameter value using template literals without proper escaping. When the timezone value contains malicious code, it gets executed as part of the dynamically generated parser function.

Attack Vector

The attack exploits the network-accessible nature of applications using the mysql2 package. An attacker can inject arbitrary JavaScript code through a maliciously crafted timezone parameter. Since the parser dynamically generates and executes code containing this parameter, any injected payload will be executed with the privileges of the Node.js application. This could allow an attacker to:

  1. Execute arbitrary system commands
  2. Access sensitive data and environment variables
  3. Establish persistent backdoors
  4. Pivot to other systems on the network
javascript
// Security patch in lib/parsers/binary_parser.js
     case Types.TIMESTAMP:
     case Types.NEWDATE:
       if (helpers.typeMatch(field.columnType, dateStrings, Types)) {
-        return `packet.readDateTimeString(${field.decimals});`;
+        return `packet.readDateTimeString(${parseInt(field.decimals, 10)});`;
       }
-      return `packet.readDateTime('${timezone}');`;
+      return `packet.readDateTime(${helpers.srcEscape(timezone)});`;
     case Types.TIME:
       return 'packet.readTimeString()';
     case Types.DECIMAL:

Source: GitHub Commit Details

javascript
// Security patch in lib/parsers/text_parser.js
       if (helpers.typeMatch(type, dateStrings, Types)) {
         return 'packet.readLengthCodedString("ascii")';
       }
-      return `packet.parseDate('${timezone}')`;
+      return `packet.parseDate(${helpers.srcEscape(timezone)})`;
     case Types.DATETIME:
     case Types.TIMESTAMP:
       if (helpers.typeMatch(type, dateStrings, Types)) {
         return 'packet.readLengthCodedString("ascii")';
       }
-      return `packet.parseDateTime('${timezone}')`;
+      return `packet.parseDateTime(${helpers.srcEscape(timezone)})`;
     case Types.TIME:
       return 'packet.readLengthCodedString("ascii")';
     case Types.GEOMETRY:

Source: GitHub Commit Details

Detection Methods for CVE-2024-21511

Indicators of Compromise

  • Unexpected outbound network connections from Node.js application processes
  • Anomalous system command execution originating from Node.js processes
  • Unusual modifications to timezone configuration values in database connection settings
  • Suspicious child processes spawned by the Node.js application

Detection Strategies

  • Monitor for package versions in package.json or package-lock.json files containing mysql2 versions below 3.9.7
  • Implement runtime application self-protection (RASP) to detect code injection attempts
  • Use software composition analysis (SCA) tools to identify vulnerable dependencies
  • Deploy web application firewalls (WAF) with rules to detect code injection patterns in timezone-related parameters

Monitoring Recommendations

  • Enable detailed logging for database connection configurations and parameter values
  • Monitor Node.js process behavior for unexpected code execution patterns
  • Set up alerts for modifications to database connection settings, particularly timezone values
  • Implement integrity monitoring for application dependencies and lock files

How to Mitigate CVE-2024-21511

Immediate Actions Required

  • Upgrade the mysql2 package to version 3.9.7 or later immediately
  • Audit all applications using mysql2 to identify vulnerable deployments
  • Review database connection configurations for any suspicious timezone values
  • Implement input validation for any user-controllable configuration parameters

Patch Information

The vulnerability has been fixed in mysql2 version 3.9.7. The fix introduces proper sanitization of the timezone parameter using the helpers.srcEscape() function and applies parseInt() to numeric parameters like decimals. The patch can be reviewed in the GitHub Pull Request and the GitHub Release Version 3.9.7.

Workarounds

  • If immediate patching is not possible, ensure timezone configuration values come only from trusted, hardcoded sources
  • Implement strict input validation and sanitization for any configuration parameters that could influence database connections
  • Consider temporarily disabling dynamic timezone configuration until the patch can be applied
  • Deploy network segmentation to limit the blast radius of potential exploitation
bash
# Update mysql2 package to patched version
npm update mysql2@3.9.7

# Or install the specific patched version
npm install mysql2@3.9.7

# Verify installed version
npm list mysql2

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypeRCE

  • Vendor/TechMysql

  • SeverityCRITICAL

  • CVSS Score9.8

  • EPSS Probability0.13%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityHigh
  • CWE References
  • CWE-94
  • Technical References
  • GitHub Commit Details

  • GitHub Pull Request

  • GitHub Release Version 3.9.7

  • Snyk Vulnerability Report
  • Related CVEs
  • CVE-2026-34271: Oracle MySQL Server DoS Vulnerability

  • CVE-2026-34272: Oracle MySQL Server DoS Vulnerability

  • CVE-2026-22001: Oracle MySQL Server Information Disclosure

  • CVE-2026-34318: MySQL Shell Information Disclosure Flaw
Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English