CVE-2023-25813 Overview
CVE-2023-25813 is a SQL Injection vulnerability affecting Sequelize, a popular Node.js Object-Relational Mapping (ORM) tool. In versions prior to 6.19.1, parameters passed through the replacements option are not properly escaped, allowing attackers to inject arbitrary SQL commands depending on the specific queries in use. This vulnerability can lead to unauthorized data access, data manipulation, or complete database compromise.
Critical Impact
Unauthenticated attackers can exploit improper escaping in the replacements parameter to execute arbitrary SQL commands, potentially leading to full database compromise, data exfiltration, or data manipulation.
Affected Products
- Sequelize versions prior to 6.19.1
- Node.js applications using vulnerable Sequelize ORM
- sequelizejs sequelize
Discovery Timeline
- 2023-02-22 - CVE CVE-2023-25813 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2023-25813
Vulnerability Analysis
This SQL Injection vulnerability stems from improper input sanitization in Sequelize's replacement parameter handling. When developers use the replacements option in combination with the where clause in Sequelize queries, user-supplied values are not properly escaped before being interpolated into SQL statements. This allows an attacker to craft malicious input that breaks out of the intended query context and executes arbitrary SQL commands.
The vulnerability is particularly dangerous because Sequelize is widely used in Node.js applications as a database abstraction layer. Developers often trust the ORM to handle escaping automatically, making this type of vulnerability unexpected. The network-accessible attack vector means any application exposing Sequelize-backed endpoints to the internet is potentially at risk without requiring authentication or user interaction.
Root Cause
The root cause of CVE-2023-25813 lies in how Sequelize handles :replacements placeholders within SQL query strings. Prior to the fix, the replacement logic would substitute placeholders even when they appeared inside string literals, allowing attackers to inject SQL syntax through carefully crafted replacement values. The fix introduced the injectReplacements utility function that properly identifies and protects string boundaries, ensuring replacements only occur in safe contexts outside of quoted strings.
Attack Vector
The vulnerability is exploitable over the network by any attacker who can influence the values passed to Sequelize queries using the replacements option. Attack scenarios include:
- Web forms or API endpoints that accept user input and use it in Sequelize queries with replacements
- Search functionality where user-supplied terms are passed through replacement parameters
- Any dynamic query construction that combines replacements with the where option
An attacker can inject SQL metacharacters that escape the intended value context and append additional SQL commands, enabling data extraction, modification, or deletion.
The security patch addressed this by adding proper string boundary detection:
+import type { Dialect } from '../../sequelize.js';
+import type { AbstractQuery } from './query.js';
+
+export declare type DialectSupports = {
+ 'DEFAULT': boolean;
+ 'DEFAULT VALUES': boolean;
+ 'VALUES ()': boolean;
+ 'LIMIT ON UPDATE': boolean;
+ 'ON DUPLICATE KEY': boolean;
+ 'ORDER NULLS': boolean;
+ 'UNION': boolean;
+ 'UNION ALL': boolean;
+ 'RIGHT JOIN': boolean;
+ EXCEPTION: boolean;
+ forShare?: 'LOCK IN SHARE MODE' | 'FOR SHARE' | undefined;
+ lock: boolean;
+ lockOf: boolean;
+ lockKey: boolean;
+ lockOuterJoinFailure: boolean;
+ skipLocked: boolean;
+ finalTable: boolean;
+ returnValues: false | {
+ output: boolean;
+ returning: boolean;
+ };
+ autoIncrement: {
+ identityInsert: boolean;
+ defaultValue: boolean;
+ update: boolean;
+ };
Source: GitHub Commit Update
The fix also introduced the injectReplacements utility:
const HasOne = require('./associations/has-one');
const { BelongsToMany } = require('./associations/belongs-to-many');
const { HasMany } = require('./associations/has-many');
+const { injectReplacements } = require('./utils/sql');
/**
* This is the main class, the entry point to sequelize.
Source: GitHub Commit Update
Detection Methods for CVE-2023-25813
Indicators of Compromise
- Unusual database query patterns containing SQL metacharacters like single quotes, semicolons, or UNION statements
- Error logs showing SQL syntax errors from malformed injection attempts
- Unexpected database access patterns or data exfiltration activity
- Application logs containing suspicious input patterns targeting replacement parameters
Detection Strategies
- Implement Web Application Firewall (WAF) rules to detect SQL injection patterns in HTTP request parameters
- Enable detailed logging for all Sequelize queries and monitor for anomalous patterns
- Use database activity monitoring to identify unauthorized data access or modification attempts
- Deploy runtime application self-protection (RASP) solutions to detect and block SQL injection at the application layer
Monitoring Recommendations
- Monitor application logs for SQL syntax errors that may indicate injection attempts
- Set up alerts for unusual database query volumes or patterns
- Track dependency versions across your Node.js applications to identify vulnerable Sequelize installations
- Implement npm audit or similar tools in CI/CD pipelines to catch vulnerable dependencies
How to Mitigate CVE-2023-25813
Immediate Actions Required
- Upgrade Sequelize to version 6.19.1 or later immediately
- Audit all application code for usage of replacements combined with where options in Sequelize queries
- Implement input validation and sanitization as a defense-in-depth measure
- Review database access logs for signs of exploitation
Patch Information
The vulnerability has been fixed in Sequelize version 6.19.1. Users should upgrade to this version or later to remediate the vulnerability. The fix is available through npm and can be applied by updating the package dependency. For more details, see the GitHub Security Advisory GHSA-wrh9-cjv3-2hpw and the v6.19.1 Release Notes.
Workarounds
- Avoid using the replacements option and the where option in the same Sequelize query
- Use parameterized queries with bind parameters instead of replacements where possible
- Implement strict input validation to reject SQL metacharacters before they reach Sequelize
- Consider using stored procedures or prepared statements for sensitive database operations
# Upgrade Sequelize to patched version
npm update sequelize@6.19.1
# Or install specific patched version
npm install sequelize@6.19.1
# Verify installed version
npm list sequelize
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


