Skip to content

GHSA-f598-mfpv-gmfx CVE-2023-22578

Sequelize - Default support for “raw attributes” when using parentheses

Critical npm
Severity
10.0 / 10
Critical · CVSS 3.1
Exploit chance (EPSS)
0.83%
Chance of exploitation in the next 30 days. Higher than 57.60% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-790 Improper Filtering of Special Elements
Fix
Available
2 packages have a fixed version

Description

Impact

Sequelize 6.28.2 and prior has a dangerous feature where using parentheses in the attribute option would make Sequelize use the string as-is in the SQL

User.findAll({
  attributes: [
    ['count(id)', 'count']
  ]
});

Produced

SELECT count(id) AS "count" FROM "users"

Patches

This feature was deprecated in Sequelize 5, and using it prints a deprecation warning.

This issue has been patched in @sequelize/core@7.0.0.alpha-20 and sequelize@6.29.0.

In Sequelize 7, it now produces the following:

SELECT "count(id)" AS "count" FROM "users"

In Sequelize 6, it throws an error explaining that we had to introduce a breaking change, and requires the user to explicitly opt-in to either the Sequelize 7 behavior (always escape) or the Sequelize 5 behavior (inline attributes that include () without escaping). See https://github.com/sequelize/sequelize/pull/15710 for more information.

Mitigations

Do not use user-provided content to build your list or attributes. If you do, make sure that attribute in question actually exists on your model by checking that it exists in the rawAttributes property of your model first.


A discussion thread about this issue is open at https://github.com/sequelize/sequelize/discussions/15694 CVE: CVE-2023-22578

Affected versions

npm

PackageVulnerableFixed in
@sequelize/core
< 7.0.0-alpha.20
7.0.0-alpha.20
sequelize
< 6.29.0
6.29.0

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

@sequelize/core npm → 7.0.0-alpha.20

npm
npm install @sequelize/core@7.0.0-alpha.20
yarn
yarn add @sequelize/core@7.0.0-alpha.20
pnpm
pnpm add @sequelize/core@7.0.0-alpha.20

sequelize npm → 6.29.0

npm
npm install sequelize@6.29.0
yarn
yarn add sequelize@6.29.0
pnpm
pnpm add sequelize@6.29.0

Severity breakdown

CVSS 3.1 10.0

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Changed
Confidentiality
High
Integrity
High
Availability
High

Weakness

CWE-790: Improper Filtering of Special Elements

The product receives data from an upstream component, but does not filter or incorrectly filters special elements before sending it to a downstream component.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-v8fg-2rw7-q452
Sequelize: SQL Injection (Oracle DB)
Critical Also affects sequelize
GHSA-6457-6jrx-69cr
Sequelize v6 Vulnerable to SQL Injection via JSON Column Cast Type
High Also affects sequelize
GHSA-wrh9-cjv3-2hpw
Sequelize vulnerable to SQL Injection via replacements
Critical Also affects sequelize
GHSA-8c25-f3mj-v6h8
Sequelize information disclosure vulnerability
High Also affects sequelize
GHSA-vqfx-gj96-3w95
Unsafe fall-through in getWhereConditions
High Also affects sequelize
GHSA-fw4p-36j9-rrj3
Denial of Service in sequelize
Medium Also affects sequelize
GHSA-5v9h-q3gj-c32x
SQL Injection via GeoJSON in sequelize
Critical Also affects sequelize
GHSA-2598-2f59-rmhq
SQL Injection in sequelize
Critical Also affects sequelize
Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor