SQL Injection Vulnerability in node-mysql

node-mysql Updated 02 Oct 2025

Summary

29/05/2018
N/A
Yes i
Critical
9.8

CVE-2015-9244: Keys of objects in mysql node module v2.0.0-alpha7 and earlier are not escaped with mysql.escape() which could lead to SQL Injection. Affects node-mysql versions < 2.0.0~alpha8-1. Fixed in 2.0.0~alpha8-1. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

The node-mysql package is a popular Node.js module used for interacting with MySQL databases. It provides a convenient API for executing SQL queries and managing database connections. However, versions up to 2.0.0-alpha7 of the package suffer from a SQL injection vulnerability. This vulnerability arises from the failure to properly escape keys of objects, which can lead to malicious SQL queries being executed.

Vulnerability Detail

The SQL injection vulnerability in node-mysql (CVE-2015-9244) allows an attacker to inject malicious SQL code into queries executed by the application. By manipulating the keys of objects passed to the mysql module, an attacker can craft SQL queries that can bypass input validation and execute arbitrary SQL commands. This can result in unauthorized data access, data manipulation, or even the complete compromise of the database server.

How To Fix

Minimum fixed version

2.0.0~alpha8-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade node-mysql

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If upgrading to the fixed version is not immediately feasible, a temporary workaround can be implemented by manually escaping the keys before passing them to the mysql module. This can be done using a function similar to mysql.escape(), which properly escapes the keys to prevent SQL injection. Here's an example of how the workaround can be implemented in JavaScript:

const mysql = require('mysql');

function escapeKeys(obj) {
  const escapedObj = {};
  for (const key in obj) {
    if (obj.hasOwnProperty(key)) {
      escapedObj[mysql.escapeId(key)] = obj[key];
    }
  }
  return escapedObj;
}

const query = `SELECT * FROM users WHERE ${mysql.escape(escapeKeys(userInput))}`;

Conclusion

The SQL injection vulnerability in node-mysql (CVE-2015-9244) poses a significant risk to applications using vulnerable versions of the package. It is crucial to promptly upgrade to the fixed version (2.0.0-alpha8-1 or later) or implement the provided workaround to mitigate the risk of SQL injection attacks. For further assistance or support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for node-mysql →

Share this vulnerability

FAQ

The SQL injection vulnerability in node-mysql can have severe consequences. An attacker can exploit this vulnerability to execute arbitrary SQL commands, potentially leading to unauthorized data access, data manipulation, or even the complete compromise of the database server.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability. Vulert analyzes your package-lock.json file and provides real-time alerts for open-source vulnerabilities, including this SQL injection vulnerability in node-mysql.

Yes, a fix is available for this vulnerability. It is recommended to upgrade to version 2.0.0-alpha8-1 or later of the node-mysql package, which addresses the SQL injection issue by properly escaping keys.

Yes, if upgrading the package is not immediately feasible, you can implement a temporary workaround by manually escaping the keys before passing them to the mysql module. Refer to the 'workaround' section for an example of how to implement this workaround.

You can find more information about this vulnerability, including technical details and the CVE identifier, in the vulnerability report available at https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2015-9244.json.

Related vulnerabilities

Recent vulnerabilities recorded for node-mysql.

How To Fix

Minimum fixed version

2.0.0~alpha8-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade node-mysql

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback