CVE-2023-22578: Sequelize SQL injection via unescaped parentheses in attributes

CVE-2023-22578 · Severity: low · CVSS 3.1 · Published 2023-02-24

Sequelize is an Object-Relational Mapping (ORM) library used to interact with databases in Node.js applications. A vulnerability allows developers to accidentally enable SQL injection when building database queries with user-provided attribute names containing parentheses. An attacker could exploit this to read, modify, or delete database records if an application passes untrusted input directly to Sequelize's attribute option.

Technologies: @sequelize/core (npm), sequelize (npm). Vendors: npm.

Quick answers

Is CVE-2023-22578 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2023-22578 being exploited in the wild.
How severe is CVE-2023-22578?
Low severity, with a CVSS score of 3.1, published 24 February 2023.
Which products and versions are affected?
@sequelize/core (npm) SEMVER:introduced=0,fixed=7.0.0-alpha.20; sequelize (npm) SEMVER:introduced=0,fixed=6.29.0.
Is there a fix for CVE-2023-22578?
Yes. @sequelize/core (npm): upgrade to 7.0.0-alpha.20 or later; sequelize (npm): upgrade to 6.29.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2023-22578 attacked?
It is attacked over the network.
Am I affected by CVE-2023-22578?
Check whether you run @sequelize/core (npm) or sequelize (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • @sequelize/core (npm): upgrade to 7.0.0-alpha.20 or later
    npm install @sequelize/core@7.0.0-alpha.20
  • sequelize (npm): upgrade to 6.29.0 or later
    npm install sequelize@6.29.0

Technical details

This vulnerability exists in Sequelize's handling of attribute specifications when using the tuple syntax (e.g., ['count(id)', 'count']). Prior to the patch, Sequelize would treat strings containing parentheses as "raw" SQL expressions and inject them directly into the query without escaping, enabling SQL injection. The vulnerability affects all versions of Sequelize 6 prior to 6.29.0 and all versions of @sequelize/core prior to 7.0.0-alpha.20. Exploitation requires the application to pass user-controlled input or insufficiently validated data into the attributes parameter of find operations. The attack vector is network-based with no authentication or user interaction required. The patch either escapes all attribute strings (Sequelize 7) or requires explicit opt-in to the unsafe behavior with a breaking change (Sequelize 6.29.0).

Affected products

  • Sequelize sequelize < 6.29.0
  • Sequelize @sequelize/core < 7.0.0-alpha.20

Identifiers

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

Timeline

  • 2023-02-24: disclosed: Security advisory published
  • 2023-02-24: patched: Sequelize 6.29.0 and @sequelize/core 7.0.0-alpha.20 released

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.