CVE-2015-9244: SQL Injection in mysql
Summary
CVE-2015-9244: SQL Injection in mysql. Affects mysql versions < 2.0.0-alpha8. Fixed in 2.0.0-alpha8. How to fix ↓
Also tracked for
- node-mysql · Debian:11
The same CVE-2015-9244 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
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.
No signup required · Results in about 60 seconds
Background
The mysql package is an npm package that provides a MySQL client for Node.js applications. It allows developers to interact with MySQL databases using JavaScript. The package is widely used in Node.js projects for database operations.
Vulnerability Detail
Versions of mysql prior to 2.0.0-alpha8 are affected by a SQL Injection vulnerability in the mysql.escape() function. This vulnerability arises due to improper escaping of object keys. An attacker can exploit this vulnerability by injecting malicious SQL queries through unescaped object keys, potentially leading to unauthorized access, data manipulation, or other malicious activities.
How To Fix
Minimum fixed version
2.0.0-alpha8
This is the first release that contains the fix.
npm install mysql@2.0.0-alpha8
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
There is no specific workaround mentioned for this vulnerability. However, developers can manually sanitize and escape object keys before passing them to the mysql.escape() function to prevent SQL Injection attacks. Here is an example of how to sanitize object keys using the mysql.escapeId() function:
const mysql = require('mysql');
const obj = {
'key1': 'value1',
'key2': 'value2',
'key3': 'value3'
};
const sanitizedObj = {};
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
sanitizedObj[mysql.escapeId(key)] = obj[key];
}
}
console.log(sanitizedObj);
Conclusion
The SQL Injection vulnerability in the mysql package prior to version 2.0.0-alpha8 can lead to unauthorized access, data manipulation, or other malicious activities on the MySQL database. It is crucial to update to the latest version to mitigate this vulnerability. For further support on vulnerability remediation, you can reach out to DevNack.com.
See every vulnerability recorded for mysql →
FAQ
This vulnerability can allow an attacker to execute arbitrary SQL queries, potentially leading to unauthorized access, data manipulation, or other malicious activities on the MySQL database.
No, only versions prior to 2.0.0-alpha8 are affected. Updating to version 2.0.0-alpha8 or later mitigates the vulnerability.
There is no known exploit available for this vulnerability at the moment. However, it is important to update to the latest version to prevent any potential exploitation.
Yes, you can manually sanitize and escape object keys before passing them to the mysql.escape() function. This can help prevent SQL Injection attacks. Refer to the provided workaround for an example.
You can find more information about this vulnerability in the GitHub Advisory Database at: https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2020/09/GHSA-fvq6-55gv-jx9f/GHSA-fvq6-55gv-jx9f.json
References
Related vulnerabilities
Recent vulnerabilities recorded for mysql.
Follow Vulert in Google
Get more Vulert vulnerability and dependency-security updates in Google Search and AI results.