MySQLjs SQL Injection Authentication Bypass

high Web App Scanning Plugin ID 113162

Synopsis

MySQLjs SQL Injection Authentication Bypass

Description

An SQL injection occurs when a value originating from the client's request is used within a SQL query without prior sanitisation. Typically, query escape functions or placeholders are known to prevent SQL injections. However, mysqljs/mysql is known to have different escape methods over different value types, and it could eventually cause unexpected behaviors when the attacker passes the parameter with a different value type.

This injection was detected as scanner was able to bypass the authentication mechanism and access an authenticated page.

Solution

Add stringifyObjects option when calling createConnection, or adding a type control before the SQL query is executed.

See Also

https://flattsecurity.medium.com/finding-an-unseen-sql-injection-by-bypassing-escape-functions-in-mysqljs-mysql-90b27f6542b4

https://github.com/mysqljs/mysql

Plugin Details

Severity: High

ID: 113162

Type: remote

Family: Injection

Published: 3/1/2022

Updated: 1/29/2025

Scan Template: pci, scan

Risk Information

VPR

Risk Factor: Medium

Score: 6.2

CVSS v2

Risk Factor: High

Base Score: 9

Vector: CVSS2#AV:N/AC:L/Au:N/C:C/I:P/A:P

CVSS Score Source: Tenable

CVSS v3

Risk Factor: High

Base Score: 8.6

Vector: CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L

CVSS Score Source: Tenable

CVSS v4

Risk Factor: High

Base Score: 7.2

Vector: CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:L/VA:L/SC:L/SI:L/SA:L

CVSS Score Source: Tenable

Reference Information