CVE-2024-21511
📋 TL;DR
CVE-2024-21511 is a critical code injection vulnerability in the mysql2 Node.js package. Attackers can execute arbitrary code by exploiting improper sanitization of the timezone parameter when calling MySQL date/time functions. All applications using vulnerable mysql2 versions are affected.
💻 Affected Systems
- mysql2 Node.js package
⚠️ Manual Verification Required
This CVE does not have specific version information in our database, so automatic vulnerability detection cannot determine if your system is affected.
Why? The CVE database entry doesn't specify which versions are vulnerable (no version ranges provided by the vendor/NVD).
🔒 Custom verification scripts are available for registered users. Sign up free to download automated test scripts.
- Review the CVE details at NVD
- Check vendor security advisories for your specific version
- Test if the vulnerability is exploitable in your environment
- Consider updating to the latest version as a precaution
⚠️ Risk & Real-World Impact
Worst Case
Remote code execution leading to complete system compromise, data exfiltration, and lateral movement within the network.
Likely Case
Database compromise, credential theft, and potential application takeover through code execution.
If Mitigated
Limited impact if proper input validation and network segmentation are in place, though risk remains significant.
🎯 Exploit Status
Exploitation requires the ability to control timezone parameters in mysql2 queries.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: 3.9.7
Vendor Advisory: https://github.com/sidorares/node-mysql2/releases/tag/v3.9.7
Restart Required: Yes
Instructions:
1. Update package.json to specify mysql2 version 3.9.7 or higher. 2. Run 'npm update mysql2' or 'yarn upgrade mysql2'. 3. Restart your Node.js application.
🔧 Temporary Workarounds
Input Validation Workaround
allImplement strict input validation for all timezone parameters passed to mysql2 functions
🧯 If You Can't Patch
- Implement strict input validation and sanitization for all user-controlled parameters
- Isolate mysql2 instances behind firewalls and restrict network access
🔍 How to Verify
Check if Vulnerable:
Check package.json or run 'npm list mysql2' to see installed version
Check Version:
npm list mysql2 | grep mysql2
Verify Fix Applied:
Confirm mysql2 version is 3.9.7 or higher using 'npm list mysql2'
📡 Detection & Monitoring
Log Indicators:
- Unusual timezone parameter values in mysql2 queries
- Unexpected process execution from Node.js applications
Network Indicators:
- Unusual outbound connections from application servers
- Database connections with suspicious parameters
SIEM Query:
source="application.logs" AND "mysql2" AND ("timezone" OR "TZ") AND suspicious_pattern
🔗 References
- https://github.com/sidorares/node-mysql2/commit/7d4b098c7e29d5a6cb9eac2633bfcc2f0f1db713
- https://github.com/sidorares/node-mysql2/pull/2608
- https://github.com/sidorares/node-mysql2/releases/tag/v3.9.7
- https://security.snyk.io/vuln/SNYK-JS-MYSQL2-6670046
- https://github.com/sidorares/node-mysql2/commit/7d4b098c7e29d5a6cb9eac2633bfcc2f0f1db713
- https://github.com/sidorares/node-mysql2/pull/2608
- https://github.com/sidorares/node-mysql2/releases/tag/v3.9.7
- https://security.snyk.io/vuln/SNYK-JS-MYSQL2-6670046